Ignore:
Timestamp:
05/13/05 15:14:12 (19 years ago)
Author:
mattausch
Message:

ogre: changed from occlusion_query_nv to occlusion_query_arb (in ogre_changes)

Location:
trunk/VUT/work/ogre_changes/RenderSystems
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/ogre_changes/RenderSystems/Direct3D9/src/OgreD3D9HardwareOcclusionQuery.cpp

    r88 r97  
    7171} 
    7272 
     73#ifndef GTP_VISIBILITY_MODIFIED_OGRE 
    7374//------------------------------------------------------------------ 
    7475// Occlusion query functions (see base class documentation for this) 
     
    7879        if( m_bHWOcclusionSupport )             // Make it fail silently if hardware occlusion isn't supported 
    7980        { 
    80                 m_pD3DQuery->Issue(D3DISSUE_BEGIN);  
    81         } 
    82 } 
    83 //------------------------------------------------------------------ 
     81                if  ( m_SkipCounter ==  m_Skip ) { m_SkipCounter = 0; };                // Counter starts at 0 again at m_Skip  
     82                 
     83                if ( m_SkipCounter == 0 && m_uintPixelCount != 0 )      // New or none visable objects must allways be tested but visable objects can be skiped 
     84                { 
     85                        m_pD3DQuery->Issue(D3DISSUE_BEGIN);  
     86                } 
     87        } 
     88} 
     89         
    8490void D3D9HardwareOcclusionQuery::endOcclusionQuery()  
    8591{  
    8692        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    8793        { 
    88                 m_pD3DQuery->Issue(D3DISSUE_END);  
     94                if (m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 
     95                { 
     96                        m_pD3DQuery->Issue(D3DISSUE_END);  
     97                } 
     98                m_SkipCounter++;                                                                 // The skip counter is increased  
    8999        } 
    90100} 
     
    95105// Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 
    96106//-- 
    97 bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult )  
    98 { 
    99         return pullOcclusionQuery(NumOfFragments, waitForResult, HWOCCLUSIONQUERY_FLUSH); 
     107bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments)  
     108{ 
     109        HRESULT hr; 
     110         
     111        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     112        { 
     113                hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 
     114 
     115                if ( hr != S_OK )  
     116                        { 
     117                                return false;  
     118                        } 
     119                        else  
     120                        {  
     121                                m_uintPixelCount = *NumOfFragments;  
     122                                return true;  
     123                        } 
     124        } 
     125        else 
     126        { 
     127                m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 
     128                return true; 
     129        } 
    100130} 
    101131 
     
    106136// Note: OpenGL dosn't use this flag at all so the application running OpenGL won't display any different behaviour. 
    107137//-- 
     138bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  )  
     139{ 
     140        HRESULT hr; 
     141 
     142        // TO DO: USE lockOpts= D3D9Mappings::get(options); instead of RS_OCCLUSIONQUERY enum 
     143 
     144        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     145        { 
     146         
     147                switch( flag ) 
     148                { 
     149                        case HWOCCLUSIONQUERY_FLUSH :    
     150                                hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), D3DGETDATA_FLUSH ); 
     151                        break; 
     152 
     153                        case HWOCCLUSIONQUERY_NOFLUSH :  
     154                                hr = m_pD3DQuery->GetData( NumOfFragments, sizeof( NumOfFragments ), 0 ); 
     155                        break; 
     156                }; 
     157 
     158 
     159 
     160                if ( hr != S_OK )  
     161                        { 
     162                                return false;  
     163                        } 
     164                        else  
     165                        {  
     166                                m_uintPixelCount = *NumOfFragments;  
     167                                return true;  
     168                        } 
     169        } 
     170        else  
     171        { 
     172                m_uintPixelCount = 100000; // Fails quitlly if hardware occlusion is not supported - every object is visable 
     173                return true; 
     174        } 
     175} 
     176#else // GTP_VISIBILITY_MODIFIED_OGRE 
     177//------------------------------------------------------------------ 
     178void D3D9HardwareOcclusionQuery::beginOcclusionQuery()  
     179{  
     180        if( m_bHWOcclusionSupport )             // Make it fail silently if hardware occlusion isn't supported 
     181        { 
     182                m_pD3DQuery->Issue(D3DISSUE_BEGIN);  
     183        } 
     184} 
     185//------------------------------------------------------------------ 
     186void D3D9HardwareOcclusionQuery::endOcclusionQuery()  
     187{  
     188        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     189        { 
     190                m_pD3DQuery->Issue(D3DISSUE_END);  
     191        } 
     192} 
     193//------------------------------------------------------------------ 
     194bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult )  
     195{ 
     196        return pullOcclusionQuery(NumOfFragments, waitForResult, HWOCCLUSIONQUERY_FLUSH); 
     197} 
     198 
     199//------------------------------------------------------------------ 
    108200bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,  
    109201                                                                                                     const HW_OCCLUSIONQUERY flag  )  
     
    114206        return pullOcclusionQuery(NumOfFragments, waitForResult, queryFlag); 
    115207} 
     208 
    116209//------------------------------------------------------------------ 
    117210bool D3D9HardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,  
     
    137230        return hr == S_OK; 
    138231} 
     232 
     233 
     234#endif // GTP_VISIBILITY_MODIFIED_OGRE 
     235 
    139236} // namespace OGre 
  • trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp

    r88 r97  
    5050*/ 
    5151 
    52  
     52#ifndef GTP_VISIBILITY_MODIFIED_OGRE 
    5353/** 
    5454  * Default object constructor 
     
    9595        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    9696        { 
    97                 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
     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                } 
    98102        } 
    99103} 
     
    103107        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    104108        { 
    105                 glEndOcclusionQueryNV_ptr(); 
    106         } 
    107 } 
    108  
    109 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult)  
    110 { 
    111         unsigned int isAvailable = GL_TRUE; 
    112  
    113         if( m_bHWOcclusionSupport )      
    114         { 
    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                 } 
     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++; 
     114        } 
     115} 
     116 
     117bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments)  
     118{ 
     119        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     120        { 
     121                glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
    124122        }  
    125123        else 
    126124        { 
    127                 // In case hardware occlusion isn't supported, every object is set visible. 
    128                 *NumOfFragments = 100000;                
     125                *NumOfFragments = 100000;               // Fails quitlly -> every object tested is visable. 
    129126        } 
    130127 
    131128        m_uintPixelCount = *NumOfFragments;  
    132129 
    133         return isAvailable == GL_TRUE;   
    134 } 
    135  
    136 //------------------------------------------------------------------ 
    137 // OpenGL doesn't use the flag, but to implement the abstract interface we need to include this function. 
     130        return true; 
     131} 
     132 
     133//------------------------------------------------------------------ 
     134// OpenGL dosn't use the flag, but to fulfil the abstract interface we need to include this function. 
    138135// Using this function in OpenGL mode simple works the same way as calling the other function without the flag parameter, 
    139136// but in DX9 it works differentlly, see notes in the DX9 implementation. 
    140137//-- 
     138bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  )  
     139{ 
     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; 
     152} 
     153 
     154#else // GTP_VISIBILITY_MODIFIED_OGRE 
     155 
     156//------------------------------------------------------------------ 
     157GLHardwareOcclusionQuery::GLHardwareOcclusionQuery()  
     158{  
     159        m_uintPixelCount = 0;  
     160        m_SkipCounter = 0; 
     161 
     162        // Check for hardware occlusion support 
     163    // if( glDeleteOcclusionQueriesNV_ptr != 0 )        // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 
     164        if( glDeleteQueriesARB_ptr != 0 ) 
     165        { 
     166                m_bHWOcclusionSupport = true; 
     167        } 
     168        else 
     169        { 
     170                m_bHWOcclusionSupport = false; 
     171        } 
     172 
     173        if( m_bHWOcclusionSupport ) 
     174        { 
     175                //glGenOcclusionQueriesNV_ptr( 1, m_uintQuery );         
     176                glGenQueriesARB_ptr(1, m_uintQuery); 
     177        } 
     178} 
     179 
     180 
     181//------------------------------------------------------------------ 
     182GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery()  
     183{  
     184        if( m_bHWOcclusionSupport ) 
     185        { 
     186                //glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] );   
     187                glDeleteQueriesARB_ptr(1, &m_uintQuery[0]); 
     188        }        
     189} 
     190 
     191//------------------------------------------------------------------ 
     192void GLHardwareOcclusionQuery::beginOcclusionQuery()  
     193{  
     194        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     195        { 
     196                // do the actual occlusion query for this node 
     197                //glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
     198                glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, m_uintQuery[0]); 
     199        } 
     200} 
     201         
     202void GLHardwareOcclusionQuery::endOcclusionQuery()  
     203{  
     204        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     205        { 
     206                //glEndOcclusionQueryNV_ptr(); 
     207                glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 
     208        } 
     209} 
     210//------------------------------------------------------------------ 
     211bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult)  
     212{ 
     213        //unsigned int isAvailable = GL_TRUE; 
     214        int isAvailable = GL_TRUE; 
     215 
     216        if( m_bHWOcclusionSupport )      
     217        { 
     218                if(!waitForResult) 
     219                { 
     220                        //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 
     221                        glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
     222                } 
     223 
     224                if(isAvailable == GL_TRUE) 
     225                { 
     226                        glGetQueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments); 
     227                        //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     228                } 
     229        }  
     230        else 
     231        { 
     232                // In case hardware occlusion isn't supported, every object is set visible. 
     233                *NumOfFragments = 100000;                
     234        } 
     235 
     236        m_uintPixelCount = *NumOfFragments;  
     237 
     238        return isAvailable == GL_TRUE;   
     239} 
     240 
     241//------------------------------------------------------------------ 
    141242bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag  )  
    142243{ 
     
    144245} 
    145246 
    146 } 
    147  
    148  
     247#endif // GTP_VISIBILITY_MODIFIED_OGRE 
     248 
     249 
     250} 
     251 
     252 
Note: See TracChangeset for help on using the changeset viewer.