diff options
author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2022-03-02 19:46:48 +0200 |
---|---|---|
committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2022-03-02 19:46:48 +0200 |
commit | f90d17905899d01db76b82b6d647bbecf1c47f23 (patch) | |
tree | dba8f9a514a02a9d86fe25c5d0ffccf30a6b754f /indra/newview/llvieweroctree.cpp | |
parent | 064f28b290026be0e77cd38de78b06477a9c0876 (diff) | |
parent | 97a103255e433629f13e2156aa307ca329cdcfc6 (diff) |
Merge branch 'DRTVWR-546' into DRTVWR-539
# Conflicts:
# indra/llcommon/tests/llprocess_test.cpp
# indra/llui/llcombobox.cpp
# indra/llui/llcombobox.h
# indra/newview/VIEWER_VERSION.txt
# indra/newview/llviewertexturelist.cpp
# indra/newview/llvovolume.cpp
Diffstat (limited to 'indra/newview/llvieweroctree.cpp')
-rw-r--r-- | indra/newview/llvieweroctree.cpp | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 3cdef0ebff..5eda75753e 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -787,42 +787,39 @@ void LLViewerOctreeGroup::checkStates() //occulsion culling functions and classes //------------------------------------------------------------------------------------------- std::set<U32> LLOcclusionCullingGroup::sPendingQueries; -class LLOcclusionQueryPool : public LLGLNamePool -{ -public: - LLOcclusionQueryPool() - { - } - -protected: - virtual GLuint allocateName() - { - GLuint ret = 0; +static std::queue<GLuint> sFreeQueries; - glGenQueriesARB(1, &ret); - - return ret; - } +#define QUERY_POOL_SIZE 1024 - virtual void releaseName(GLuint name) - { -#if LL_TRACK_PENDING_OCCLUSION_QUERIES - LLOcclusionCullingGroup::sPendingQueries.erase(name); -#endif - glDeleteQueriesARB(1, &name); - } -}; - -static LLOcclusionQueryPool sQueryPool; U32 LLOcclusionCullingGroup::getNewOcclusionQueryObjectName() { - return sQueryPool.allocate(); + LL_PROFILE_ZONE_SCOPED; + + if (sFreeQueries.empty()) + { + //seed 1024 query names into the free query pool + GLuint queries[1024]; + glGenQueriesARB(1024, queries); + for (int i = 0; i < 1024; ++i) + { + sFreeQueries.push(queries[i]); + } + } + + // pull from pool + GLuint ret = sFreeQueries.front(); + sFreeQueries.pop(); + return ret; } void LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(GLuint name) { - sQueryPool.release(name); + if (name != 0) + { + LL_PROFILE_ZONE_SCOPED; + sFreeQueries.push(name); + } } //===================================== @@ -1243,7 +1240,14 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh //store which frame this query was issued on mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount; - glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]); + { + LL_PROFILE_ZONE_NAMED("glBeginQuery"); + + //get an occlusion query that hasn't been used in awhile + releaseOcclusionQueryObjectName(mOcclusionQuery[LLViewerCamera::sCurCameraID]); + mOcclusionQuery[LLViewerCamera::sCurCameraID] = getNewOcclusionQueryObjectName(); + glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]); + } LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; llassert(shader); @@ -1282,7 +1286,10 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh } } - glEndQueryARB(mode); + { + LL_PROFILE_ZONE_NAMED("glEndQuery"); + glEndQueryARB(mode); + } } } |