Changeset 88 for trunk/VUT


Ignore:
Timestamp:
05/09/05 22:55:21 (20 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/work/ogre_changes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h

    r61 r88  
    103103          *        0 will generate all the levels till 1x1. [default: 0] 
    104104      */ 
    105         virtual bool pullOcclusionQuery( unsigned int* NumOfFragments ) = 0; 
     105        virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ) = 0; 
    106106 
    107107        /** 
     
    112112          * In OpenGL mode it makes no difference if you specify OCCLUSIONQUERY_FLUSH or OCCLUSIONQUERY_NOFLUSH. 
    113113      */ 
    114         virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  ) = 0; 
     114        virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,  
     115                                                                         const HW_OCCLUSIONQUERY flag  ) = 0; 
    115116 
    116117        /** 
     
    133134        virtual void    setSkipRate( int skip ) = 0; 
    134135        virtual int             getSkipRate() = 0; 
    135  
    136 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    137         /** 
    138           *    
    139           * @Remarks This function returns true if the result of the  
    140           * query is already availbable, false otherwise. 
    141           */ 
    142         virtual bool resultAvailable() = 0; 
    143 #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    144  
    145136//---------------------------------------------------------------------- 
    146137// Private members 
  • trunk/VUT/work/ogre_changes/RenderSystem/Direct3D9/include/OgreD3D9HardwareOcclusionQuery.h

    r61 r88  
    7171        void beginOcclusionQuery();      
    7272        void endOcclusionQuery(); 
    73         bool pullOcclusionQuery( unsigned int* NumOfFragments); 
    74         bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  ); 
     73        bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ); 
     74        bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 
     75                                                         const HW_OCCLUSIONQUERY flag  );  
     76 
    7577        unsigned int getLastQuerysPixelcount() { return m_uintPixelCount; } 
    76 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    77         bool resultAvailable(); 
    78 #endif 
    79         // This functions are optional, it's a simple filter that simply skipps some hardware occlusion tests on visable objects only 
     78         
     79        // This functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visable objects only 
    8080        // It's easy to use if you don't have to keep track on which objects are visable (can be skipped) and what objects arn't visable.. 
    8181        // (None visable objects and object you introduce for the first time have allways to be tested allthough the cheepest possible  
     
    9393 
    9494 
    95         void setSkipRate( int skip ) { m_Skip = skip; }                 // Using 2 only 50 % of the tests are actully made and 3 results in only 33% of the tests. So on. 
     95        void setSkipRate( int skip ) { m_Skip = skip; }                 // Using 2 only 50 % of the tests are actually made and 3 results in only 33% of the tests. So on. 
    9696        int      getSkipRate() { return m_Skip; }  
    9797 
     
    100100//-- 
    101101protected: 
     102 
     103        bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,  
     104                                                     const DWORD queryFlag ); 
    102105 
    103106        unsigned int            m_uintPixelCount;                
  • trunk/VUT/work/ogre_changes/RenderSystem/Direct3D9/src/OgreD3D9HardwareOcclusionQuery.cpp

    r61 r88  
    7878        if( m_bHWOcclusionSupport )             // Make it fail silently if hardware occlusion isn't supported 
    7979        { 
    80                 if  ( m_SkipCounter ==  m_Skip ) { m_SkipCounter = 0; };                // Counter starts at 0 again at m_Skip  
    81                  
    82                 if ( m_SkipCounter == 0 && m_uintPixelCount != 0 )      // New or none visable objects must allways be tested but visable objects can be skiped 
    83                 { 
    84                         m_pD3DQuery->Issue(D3DISSUE_BEGIN);  
    85                 } 
     80                m_pD3DQuery->Issue(D3DISSUE_BEGIN);  
    8681        } 
    8782} 
    88          
     83//------------------------------------------------------------------ 
    8984void D3D9HardwareOcclusionQuery::endOcclusionQuery()  
    9085{  
    9186        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    9287        { 
    93                 if (m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 
    94                 { 
    95                         m_pD3DQuery->Issue(D3DISSUE_END);  
    96                 } 
    97                 m_SkipCounter++;                                                                 // The skip counter is increased  
     88                m_pD3DQuery->Issue(D3DISSUE_END);  
    9889        } 
    9990} 
     
    10495// Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 
    10596//-- 
    106 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments)  
     97bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult )  
    10798{ 
    108         HRESULT hr; 
    109          
    110         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    111         { 
    112                 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 
    113  
    114                 if ( hr != S_OK )  
    115                         { 
    116                                 return false;  
    117                         } 
    118                         else  
    119                         {  
    120                                 m_uintPixelCount = *NumOfFragments;  
    121                                 return true;  
    122                         } 
    123         } 
    124         else 
    125         { 
    126                 m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 
    127                 return true; 
    128         } 
     99        return pullOcclusionQuery(NumOfFragments, waitForResult, HWOCCLUSIONQUERY_FLUSH); 
    129100} 
    130101 
     
    135106// Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 
    136107//-- 
    137 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  )  
     108bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,  
     109                                                                                                     const HW_OCCLUSIONQUERY flag  )  
    138110{ 
    139         HRESULT hr; 
    140  
     111        DWORD queryFlag = flag == HWOCCLUSIONQUERY_FLUSH ? D3DGETDATA_FLUSH : 0; 
    141112        // TO DO: USE lockOpts= D3D9Mappings::get(options); instead of RS_OCCLUSIONQUERY enum 
    142113 
    143         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     114        return pullOcclusionQuery(NumOfFragments, waitForResult, queryFlag); 
     115} 
     116//------------------------------------------------------------------ 
     117bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,  
     118                                                                                                     const DWORD queryFlag )  
     119{ 
     120        HRESULT hr = S_OK; 
     121 
     122        if( m_bHWOcclusionSupport )     // In case hardware occlusion isn't supported 
     123        {        
     124                do 
     125                { 
     126                        hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), queryFlag ); 
     127                } 
     128                while(waitForResult && (hr == S_FALSE)); 
     129                 
     130                m_uintPixelCount = *NumOfFragments;  
     131        } 
     132        else 
    144133        { 
     134                m_uintPixelCount = 100000; // every object is visible 
     135        } 
    145136         
    146                 switch( flag ) 
    147                 { 
    148                         case HWOCCLUSIONQUERY_FLUSH :    
    149                                 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 
    150                         break; 
    151  
    152                         case HWOCCLUSIONQUERY_NOFLUSH :  
    153                                 hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), 0 ); 
    154                         break; 
    155                 }; 
    156  
    157  
    158  
    159                 if ( hr != S_OK )  
    160                         { 
    161                                 return false;  
    162                         } 
    163                         else  
    164                         {  
    165                                 m_uintPixelCount = *NumOfFragments;  
    166                                 return true;  
    167                         } 
    168         } 
    169         else  
    170         { 
    171                 m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 
    172                 return true; 
    173         } 
     137        return hr == S_OK; 
    174138} 
    175  
    176  
    177 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    178  
    179 bool D3D9HardwareOcclusionQuery::resultAvailable() 
    180 { 
    181         bool result = true; 
    182  
    183         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    184         {       //TODO: implement 
    185                 //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, &result ); 
    186         } 
    187  
    188         return result; 
    189 } 
    190  
    191 #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    192  
    193 } 
     139} // namespace OGre 
  • trunk/VUT/work/ogre_changes/RenderSystem/GL/include/OgreGLHardwareOcclusionQuery.h

    r61 r88  
    8888        void beginOcclusionQuery(); 
    8989        void endOcclusionQuery(); 
    90         bool pullOcclusionQuery( unsigned int* NumOfFragments); 
    91         bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  );  
    92 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    93         bool resultAvailable(); 
    94 #endif 
     90        bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ); 
     91        bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, 
     92                                                         const HW_OCCLUSIONQUERY flag  );  
     93 
    9594        unsigned int getLastQuerysPixelcount() { return m_uintPixelCount; } 
    9695 
  • trunk/VUT/work/ogre_changes/RenderSystem/GL/src/OgreGLHardwareOcclusionQuery.cpp

    r61 r88  
    9595        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    9696        { 
    97                 //if  ( m_SkipCounter ==  m_Skip ) { m_SkipCounter = 0; };              // Counter starts at 0 again at m_Skip  
    98                 //if ( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 
    99                 //{ 
    100                         glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
    101                 //} 
     97                glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
    10298        } 
    10399} 
     
    107103        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    108104        { 
    109                 //if( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 
    110                 //{ 
    111                         glEndOcclusionQueryNV_ptr(); 
    112                 //} 
    113                 //m_SkipCounter++; 
     105                glEndOcclusionQueryNV_ptr(); 
    114106        } 
    115107} 
    116108 
    117 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments)  
     109bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult)  
    118110{ 
    119         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     111        unsigned int isAvailable = GL_TRUE; 
     112 
     113        if( m_bHWOcclusionSupport )      
    120114        { 
    121                 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     115                if(!waitForResult) 
     116                { 
     117                        glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 
     118                } 
     119 
     120                if(isAvailable == GL_TRUE) 
     121                { 
     122                        glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     123                } 
    122124        }  
    123125        else 
    124126        { 
    125                 *NumOfFragments = 100000;               // Fails quitlly -> every object tested is visable. 
     127                // In case hardware occlusion isn't supported, every object is set visible. 
     128                *NumOfFragments = 100000;                
    126129        } 
    127130 
    128131        m_uintPixelCount = *NumOfFragments;  
    129132 
    130         return true; 
     133        return isAvailable == GL_TRUE;   
    131134} 
    132135 
    133136//------------------------------------------------------------------ 
    134 // OpenGL dosn't use the flag, but to fulfil the abstract interface we need to include this function. 
     137// OpenGL doesn't use the flag, but to implement the abstract interface we need to include this function. 
    135138// Using this function in OpenGL mode simple works the same way as calling the other function without the flag parameter, 
    136139// but in DX9 it works differentlly, see notes in the DX9 implementation. 
    137140//-- 
    138 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  )  
     141bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag  )  
    139142{ 
    140         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    141         { 
    142                 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
    143         } 
    144         else 
    145         { 
    146                 *NumOfFragments = 100000;               // Fails quitlly -> every object tested is visable. 
    147         } 
    148  
    149         m_uintPixelCount = *NumOfFragments;  
    150          
    151         return true; 
     143        return pullOcclusionQuery(NumOfFragments, waitForResult); 
    152144} 
    153145 
    154 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    155 bool GLHardwareOcclusionQuery::resultAvailable() 
    156 { 
    157         unsigned int result = GL_TRUE; 
    158  
    159         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    160         { 
    161                 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, &result ); 
    162         } 
    163  
    164         return result == GL_TRUE; 
    165 } 
    166 #endif 
    167146} 
    168147 
Note: See TracChangeset for help on using the changeset viewer.