summaryrefslogtreecommitdiff
path: root/indra/newview/llvieweroctree.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-02-17 22:52:23 +0000
committerDave Parks <davep@lindenlab.com>2022-02-17 22:52:23 +0000
commit0d6aa3c0fe184ae00899304cb3f71315f5c73314 (patch)
tree88196dfd88c70728132cd05b5b7d5d4e630dd50a /indra/newview/llvieweroctree.cpp
parent892f7d98d5da2c329472a7075a88e010277b86b0 (diff)
SL-16815 Remove frame stalls from occlusion queries, bumpmap updates, and querying for available video memory.
Diffstat (limited to 'indra/newview/llvieweroctree.cpp')
-rw-r--r--indra/newview/llvieweroctree.cpp93
1 files changed, 65 insertions, 28 deletions
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 3cdef0ebff..65e9fa533d 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -787,42 +787,73 @@ void LLViewerOctreeGroup::checkStates()
//occulsion culling functions and classes
//-------------------------------------------------------------------------------------------
std::set<U32> LLOcclusionCullingGroup::sPendingQueries;
-class LLOcclusionQueryPool : public LLGLNamePool
+
+static std::queue<GLuint> sFreeQueries;
+
+U32 LLOcclusionCullingGroup::getNewOcclusionQueryObjectName()
{
-public:
- LLOcclusionQueryPool()
- {
- }
+ LL_PROFILE_ZONE_SCOPED;
+ // TODO: refactor this to a general purpose name pool
+ static GLuint occlusion_queries[2][1024];
+ static std::atomic<S32> query_count[2];
+ static S32 query_page = -1;
+
+ //reuse any query names that have been freed
+ if (!sFreeQueries.empty())
+ {
+ GLuint ret = sFreeQueries.front();
+ sFreeQueries.pop();
+ return ret;
+ }
-protected:
+ // first call, immediately fill entire name pool
+ if (query_page == -1)
+ {
+ glGenQueriesARB(1024, occlusion_queries[0]);
+ glGenQueriesARB(1024, occlusion_queries[1]);
+ query_page = 0;
+ query_count[0] = 1024;
+ query_count[1] = 1024;
+ }
- virtual GLuint allocateName()
- {
- GLuint ret = 0;
+ if (query_count[query_page] == 0) //this page is empty
+ {
+ //check the other page
+ query_page = (query_page + 1) % 2;
- glGenQueriesARB(1, &ret);
-
- return ret;
- }
+ if (query_count[query_page] == 0)
+ {
+ //the other page is also empty, generate immediately and return
+ GLuint ret;
+ glGenQueriesARB(1, &ret);
+ return ret;
+ }
+ }
- virtual void releaseName(GLuint name)
- {
-#if LL_TRACK_PENDING_OCCLUSION_QUERIES
- LLOcclusionCullingGroup::sPendingQueries.erase(name);
-#endif
- glDeleteQueriesARB(1, &name);
- }
-};
+ GLuint ret = occlusion_queries[query_page][--query_count[query_page]];
-static LLOcclusionQueryPool sQueryPool;
-U32 LLOcclusionCullingGroup::getNewOcclusionQueryObjectName()
-{
- return sQueryPool.allocate();
+ if (query_count[query_page] == 0)
+ { //exhausted this page, replenish on background thread
+ S32 page = query_page;
+ LL::WorkQueue::postMaybe(LL::WorkQueue::getInstance("LLImageGL"),
+ [=]()
+ {
+ LL_PROFILE_ZONE_NAMED("glGenQueries bg");
+ if (query_count[page] == 0) // <-- protect against redundant attempts to replenish
+ {
+ glGenQueriesARB(1024, occlusion_queries[page]);
+ query_count[page] = 1024;
+ glFlush();
+ }
+ });
+ }
+
+ return ret;
}
void LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(GLuint name)
{
- sQueryPool.release(name);
+ sFreeQueries.push(name);
}
//=====================================
@@ -1243,7 +1274,10 @@ 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");
+ glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]);
+ }
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
llassert(shader);
@@ -1282,7 +1316,10 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh
}
}
- glEndQueryARB(mode);
+ {
+ LL_PROFILE_ZONE_NAMED("glEndQuery");
+ glEndQueryARB(mode);
+ }
}
}