Ignore:
Timestamp:
05/09/05 22:55:21 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/work/ogre_changes/RenderSystem/Direct3D9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.