Ignore:
Timestamp:
10/20/05 18:49:11 (19 years ago)
Author:
mattausch
Message:

added switch between NV and ARB queries in the render system and in the demos.
Fixed render queue bug: when clearing queue, we traversed through all priority groups
to clear the passmaps. This became very slow because had to traverse many elements (over 1000
for city demo). Now all we destroy the priority groups for each rendering (per hierarchy node).

Location:
trunk/VUT/work/ogre_changes/RenderSystems/GL/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp

    r193 r343  
    2929namespace Ogre { 
    3030 
     31bool GLHardwareOcclusionQuery::sUseArbQueries = false; 
    3132/** 
    3233  * This is a class that is the base class of the query class for  
     
    5152        // Check for hardware occlusion support 
    5253        // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 
    53 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 
    54         if (glGenQueriesARB_ptr != 0) 
    55 #else 
    56         if (glGenOcclusionQueriesNV_ptr != 0) 
    57 #endif 
    58     { 
    59                 mHasOcclusionSupport = true; 
    60         } 
    61         else 
    62         { 
    63                 mHasOcclusionSupport = false; 
    64         } 
     54        mHasOcclusionSupportARB = (glGenQueriesARB_ptr != 0); 
     55        mHasOcclusionSupportNV = (glGenOcclusionQueriesNV_ptr != 0); 
    6556 
    66         if(mHasOcclusionSupport) 
    67         { 
    68 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 
     57        if (sUseArbQueries && mHasOcclusionSupportARB) 
    6958                glGenQueriesARB_ptr(1, &mQueryID );      
    70 #else 
     59        else if (!sUseArbQueries && mHasOcclusionSupportNV) 
    7160                glGenOcclusionQueriesNV_ptr(1, &mQueryID); 
    72 #endif 
    73         } 
    7461} 
    7562 
     
    7966GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery()  
    8067{  
    81         if( mHasOcclusionSupport ) 
    82         { 
    83 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 
     68        if (sUseArbQueries && mHasOcclusionSupportARB) 
    8469                glDeleteQueriesARB_ptr(1, &mQueryID); 
    85 #else 
     70        else if (!sUseArbQueries && mHasOcclusionSupportNV) 
    8671                glDeleteOcclusionQueriesNV_ptr(1, &mQueryID);   
    87 #endif 
    88         }        
    8972} 
    9073 
     
    9477void GLHardwareOcclusionQuery::beginOcclusionQuery()  
    9578{  
    96         // Make it fail silently if hardware occlusion isn't supported 
    97         if(mHasOcclusionSupport) 
    98         { 
    99                 // Counter starts at 0 again at mSkipInterval  
    100 #ifndef GTP_VISIBILITY_MODIFIED_OGRE 
    101                 if(mSkipCounter == mSkipInterval)  
    102 #else 
    103                 if (mSkipCounter >= mSkipInterval)  // otherwise no query ever issued if mSkipInterval = 0 ! 
    104 #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    105         { 
    106                         mSkipCounter = 0;  
    107                 } 
     79        //if (mSkipCounter >= mSkipInterval)  // otherwise no query ever issued if mSkipInterval = 0 ! 
     80        //      mSkipCounter = 0; if (mSkipCounter != 0) return; 
    10881 
    109                 if (mSkipCounter == 0) 
    110                 { 
    111 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 
     82        if (sUseArbQueries && mHasOcclusionSupportARB) 
    11283                        glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, mQueryID); 
    113 #else 
     84        else if (!sUseArbQueries && mHasOcclusionSupportNV) 
    11485                        glBeginOcclusionQueryNV_ptr(mQueryID); 
    115 #endif 
    116                 } 
    117         } 
    11886} 
    11987         
    12088void GLHardwareOcclusionQuery::endOcclusionQuery()  
    12189{  
    122         // Make it fail silently if hardware occlusion isn't supported 
    123         if(mHasOcclusionSupport) 
    124         { 
    125                 if( mSkipCounter == 0) 
    126                 { 
    127 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 
     90        //if( mSkipCounter != 0) return; 
     91        if (sUseArbQueries && mHasOcclusionSupportARB) 
    12892                        glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 
    129 #else 
     93        else if (!sUseArbQueries && mHasOcclusionSupportNV) 
    13094                        glEndOcclusionQueryNV_ptr(); 
    131 #endif 
     95//      mSkipCounter++; 
    13296                } 
    13397 
    134                 mSkipCounter++; 
    135         }  
    136 } 
    137  
    138 //------------------------------------------------------------------ 
    139 // OpenGL dosn't use the flag paramter. 
    140 //------------------------------------------------------------------ 
    14198bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  )  
    14299{ 
    143         if( mHasOcclusionSupport )      // Make it fail silently if hardware occlusion isn't supported 
    144         { 
    145 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 
     100        if (sUseArbQueries && mHasOcclusionSupportARB) 
    146101                glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 
    147 #else 
     102        else if (!sUseArbQueries && mHasOcclusionSupportNV) 
    148103glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 
    149 #endif 
    150         } 
    151104        else 
    152         { 
    153                 *NumOfFragments = 100000;               // Fails quitlly -> every object tested is visable. 
    154         } 
     105                *NumOfFragments = 100000;               // Fails quietly 
    155106 
    156107        mPixelCount = *NumOfFragments;  
     
    161112#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    162113        //------------------------------------------------------------------ 
    163         bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag)  
     114bool GLHardwareOcclusionQuery::pullOcclusionQuery(unsigned int * NumOfFragments,  
     115                                                                                                  const bool waitForResult,  
     116                                                                                                  const HW_OCCLUSIONQUERY flag)  
    164117{ 
    165         unsigned int isAvailable = GL_TRUE; 
     118        if (sUseArbQueries && mHasOcclusionSupportARB)   
     119        { 
     120                int isAvailable = GL_TRUE; 
    166121 
    167                 if (mHasOcclusionSupport)        
    168         { 
    169122                if (!waitForResult) 
     123                        glGetQueryivARB_ptr(mQueryID, GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
     124                 
     125                if (isAvailable == GL_TRUE) 
     126                        glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 
     127 
     128                mPixelCount = *NumOfFragments; 
     129 
     130                return isAvailable == GL_TRUE; 
     131        }  
     132        else if (!sUseArbQueries && mHasOcclusionSupportNV) 
    170133                { 
    171                         // use nv queries rather that arb because they are faster (no flush) 
    172                                 //glGetQueryivARB_ptr(mQueryID, GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
     134                unsigned int isAvailable = GL_TRUE; 
     135 
     136                if (!waitForResult) 
    173137                                glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable); 
    174                 } 
    175138 
    176139                if (isAvailable == GL_TRUE) 
    177                 { 
    178                                 //glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 
    179140                                glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 
    180                 } 
    181         }  
    182         else 
    183         { 
    184                 // In case hardware occlusion isn't supported, every object is set visible. 
    185                 *NumOfFragments = 100000;                
    186         } 
    187141 
    188142                mPixelCount = *NumOfFragments;  
    189143 
    190         return isAvailable == GL_TRUE;   
     144                return isAvailable == GL_TRUE; 
     145                } 
     146         
     147                // In case hardware occlusion isn't supported, every object is set visible. 
     148                *NumOfFragments = 100000;                
     149                mPixelCount = *NumOfFragments;  
     150 
     151        return GL_TRUE;  
    191152} 
    192153 
  • trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp

    r316 r343  
    281281    void GLRenderSystem::setConfigOption(const String &name, const String &value) 
    282282    { 
     283                // set occlusion query 
     284#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     285                if ( name == "ArbQueries" ) 
     286                { 
     287                        if ( value == "No" ) 
     288                        { 
     289                                GLHardwareOcclusionQuery::sUseArbQueries = false; 
     290                        } 
     291                        else if  ( value == "Yes" ) 
     292                        { 
     293                                GLHardwareOcclusionQuery::sUseArbQueries = true; 
     294                        } 
     295                        return; 
     296                } 
     297#endif 
     298 
    283299        mGLSupport->setConfigOption(name, value); 
    284300    } 
Note: See TracChangeset for help on using the changeset viewer.