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
Files:
6 edited

Legend:

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

    r193 r343  
    202202#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    203203         
    204                 /** Clears solids in this group of renderables. Leaves transparents in group. 
    205         */ 
    206         void clearSolids(void); 
    207  
    208204                enum {SOLID_PASSES = 1, 
    209205                          SOLID_PASSES_DECAL = 2, 
     
    221217                */ 
    222218                void clear(const int leavePassesInQueue); 
     219                /** Destroys passes determined by parameter. 
     220                        @param passes can be one or several (combined by |) of: 
     221                        SOLID_PASSES  
     222                        SOLID_PASSES_DECAL  
     223                        SOLID_PASSES_DIFFUSE_SPECULAR 
     224                        SOLID_PASSES_NOSHADOW 
     225                        TRANSPARENT_PASSES 
     226                */ 
     227                void destroyPassMaps(const int leavePassesInQueue); 
     228 
    223229#endif // GTP_VISIBILITY_MODIFIED_OGRE           
    224230        /** Sets whether or not the queue will split passes by their lighting type, 
     
    337343 
    338344        } 
    339                 /** Clears only solid renderables. Leaves transparents in queue. */ 
    340                 void clearSolids(void) 
     345         
     346                void destroyPasses(int passes) 
    341347        { 
    342348            PriorityMap::iterator i, iend; 
     
    344350            for (i = mPriorityGroups.begin(); i != iend; ++i) 
    345351            { 
    346                 i->second->clearSolids(); 
    347             } 
     352                i->second->destroyPassMaps(passes); 
     353            } 
     354 
    348355        } 
    349356#endif // GTP_VISIBILITY_MODIFIED_OGRE           
  • trunk/VUT/work/ogre_changes/OgreMain/src/OgreRenderQueueSortingGrouping.cpp

    r139 r343  
    278278#ifdef GTP_VISIBILITY_MODIFIED_OGRE      
    279279        //----------------------------------------------------------------------- 
    280     void RenderPriorityGroup::clearSolids(void) 
    281     { 
    282         /*SolidRenderablePassMap::iterator i, iend; 
    283         // Delete queue groups which are using passes which are to be 
    284         // deleted, we won't need these any more and they clutter up  
    285         // the list and can cause problems with future clones 
    286         const Pass::PassSet& graveyardList = Pass::getPassGraveyard(); 
    287         Pass::PassSet::const_iterator gi, giend; 
    288         giend = graveyardList.end(); 
    289         for (gi = graveyardList.begin(); gi != giend; ++gi) 
    290         { 
    291             removeSolidPassEntry(*gi); 
    292         } 
    293  
    294         // Now remove any dirty passes, these will have their hashes recalculated 
    295         // by the parent queue after all groups have been processed 
    296         // If we don't do this, the std::map will become inconsistent for new insterts 
    297         const Pass::PassSet& dirtyList = Pass::getDirtyHashList(); 
    298         Pass::PassSet::const_iterator di, diend; 
    299         diend = dirtyList.end(); 
    300         for (di = dirtyList.begin(); di != diend; ++di) 
    301         { 
    302             removeSolidPassEntry(*di); 
    303         }*/ 
    304         // NB we do NOT clear the graveyard or the dirty list here, because  
    305         // it needs to be acted on for all groups, the parent queue takes  
    306         // care of this afterwards 
    307  
    308         // We do not clear the unchanged solid pass maps, only the contents of each list 
    309         // This is because we assume passes are reused a lot and it saves resorting 
    310         clearSolidPassMap(mSolidPasses); 
    311         clearSolidPassMap(mSolidPassesDecal); 
    312         clearSolidPassMap(mSolidPassesDiffuseSpecular); 
    313         clearSolidPassMap(mSolidPassesNoShadow); 
    314     } 
    315         //----------------------------------------------------------------------- 
    316280    void RenderPriorityGroup::clear(const int leavePassesInQueue) 
    317281    { 
    318                 SolidRenderablePassMap::iterator i, iend; 
    319         
    320                 // -- standard method if no passes are left in queue 
     282                //-- standard method if no passes are left in queue 
    321283                if (leavePassesInQueue == 0) 
    322284                { 
     
    328290        // This is because we assume passes are reused a lot and it saves resorting 
    329291                if (!(leavePassesInQueue & SOLID_PASSES)) 
    330                         clearSolidPassMap(mSolidPasses); 
     292                        destroySolidPassMap(mSolidPasses); 
    331293                if (!(leavePassesInQueue & SOLID_PASSES_DECAL)) 
    332                         clearSolidPassMap(mSolidPassesDecal); 
     294                        destroySolidPassMap(mSolidPassesDecal); 
    333295                if (!(leavePassesInQueue & SOLID_PASSES_DIFFUSE_SPECULAR)) 
    334                         clearSolidPassMap(mSolidPassesDiffuseSpecular); 
     296                        destroySolidPassMap(mSolidPassesDiffuseSpecular); 
    335297                if (!(leavePassesInQueue & SOLID_PASSES_NOSHADOW)) 
    336                         clearSolidPassMap(mSolidPassesNoShadow); 
     298                        destroySolidPassMap(mSolidPassesNoShadow); 
    337299 
    338300        if (!(leavePassesInQueue & TRANSPARENT_PASSES)) 
    339301                        mTransparentPasses.clear(); 
    340302    } 
     303        //----------------------------------------------------------------------- 
     304    void RenderPriorityGroup::destroyPassMaps(const int leavePassesInQueue) 
     305    { 
     306                /*     
     307        const Pass::PassSet& graveyardList = Pass::getPassGraveyard(); 
     308        Pass::PassSet::const_iterator gi, giend; 
     309        giend = graveyardList.end(); 
     310        for (gi = graveyardList.begin(); gi != giend; ++gi) 
     311        { 
     312            removeSolidPassEntry(*gi); 
     313        } 
     314 
     315        const Pass::PassSet& dirtyList = Pass::getDirtyHashList(); 
     316        Pass::PassSet::const_iterator di, diend; 
     317        diend = dirtyList.end(); 
     318        for (di = dirtyList.begin(); di != diend; ++di) 
     319        { 
     320            removeSolidPassEntry(*di); 
     321                } 
     322                */ 
     323 
     324        // We do not clear the unchanged solid pass maps, only the contents of each list 
     325        // This is because we assume passes are reused a lot and it saves resorting 
     326                if (!(leavePassesInQueue & SOLID_PASSES)) 
     327                        destroySolidPassMap(mSolidPasses); 
     328                if (!(leavePassesInQueue & SOLID_PASSES_DECAL)) 
     329                        destroySolidPassMap(mSolidPassesDecal); 
     330                if (!(leavePassesInQueue & SOLID_PASSES_DIFFUSE_SPECULAR)) 
     331                        destroySolidPassMap(mSolidPassesDiffuseSpecular); 
     332                if (!(leavePassesInQueue & SOLID_PASSES_NOSHADOW)) 
     333                        destroySolidPassMap(mSolidPassesNoShadow); 
     334    } 
    341335#endif // GTP_VISIBILITY_MODIFIED_OGRE           
    342336//----------------------------------------------------------------------- 
  • trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneManager.cpp

    r316 r343  
    42264226                if (isRenderQueueToBeProcessed(qId)) 
    42274227                { 
    4228                         /*if (leaveTransparentsInQueue) 
    4229                         {       pGroup->clearSolids();  }       else 
    4230                         {       pGroup->clear(); }*/ 
    4231                         pGroup->clear(leavePassesInQueue); 
     4228                        pGroup->destroyPasses(leavePassesInQueue); 
    42324229                } 
    42334230        } 
  • trunk/VUT/work/ogre_changes/RenderSystems/GL/include/OgreGLHardwareOcclusionQuery.h

    r115 r343  
    111111#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    112112        bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH );  
     113 
     114        static bool sUseArbQueries; 
    113115#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    114116//---------------------------------------------------------------------- 
     
    122124        int                             mSkipCounter; 
    123125        int                             mSkipInterval; 
    124         bool                    mHasOcclusionSupport; 
     126        bool                    mHasOcclusionSupportNV; 
     127        bool                    mHasOcclusionSupportARB; 
    125128}; 
    126129 
  • 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.