summaryrefslogtreecommitdiff
path: root/indra/llrender/llglslshader.cpp
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2023-05-11 21:21:01 -0700
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2023-05-11 21:21:01 -0700
commitad4118f6ceaf1c22b22d58825924aad5575319f9 (patch)
treea1227572853491f2e89fb0db128230c40248b47d /indra/llrender/llglslshader.cpp
parent339e02ef3311ad5c1197dfca2955a0c202b7c408 (diff)
parent06bdee663433bf5b12eddcbcfcb8785546354c28 (diff)
Merge branch 'DRTVWR-559' into DRTVWR-583
Diffstat (limited to 'indra/llrender/llglslshader.cpp')
-rw-r--r--indra/llrender/llglslshader.cpp72
1 files changed, 50 insertions, 22 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 04ac2476a7..b7f08aa9af 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -243,9 +243,9 @@ void LLGLSLShader::stopProfile()
}
}
-void LLGLSLShader::placeProfileQuery()
+void LLGLSLShader::placeProfileQuery(bool for_runtime)
{
- if (sProfileEnabled)
+ if (sProfileEnabled || for_runtime)
{
if (mTimerQuery == 0)
{
@@ -254,42 +254,70 @@ void LLGLSLShader::placeProfileQuery()
glGenQueries(1, &mPrimitivesQuery);
}
- glBeginQuery(GL_SAMPLES_PASSED, mSamplesQuery);
glBeginQuery(GL_TIME_ELAPSED, mTimerQuery);
- glBeginQuery(GL_PRIMITIVES_GENERATED, mPrimitivesQuery);
+
+ if (!for_runtime)
+ {
+ glBeginQuery(GL_SAMPLES_PASSED, mSamplesQuery);
+ glBeginQuery(GL_PRIMITIVES_GENERATED, mPrimitivesQuery);
+ }
}
}
-void LLGLSLShader::readProfileQuery()
+bool LLGLSLShader::readProfileQuery(bool for_runtime, bool force_read)
{
- if (sProfileEnabled)
+ if (sProfileEnabled || for_runtime)
{
- glEndQuery(GL_TIME_ELAPSED);
- glEndQuery(GL_SAMPLES_PASSED);
- glEndQuery(GL_PRIMITIVES_GENERATED);
+ if (!mProfilePending)
+ {
+ glEndQuery(GL_TIME_ELAPSED);
+ if (!for_runtime)
+ {
+ glEndQuery(GL_SAMPLES_PASSED);
+ glEndQuery(GL_PRIMITIVES_GENERATED);
+ }
+ mProfilePending = for_runtime;
+ }
+
+ if (mProfilePending && for_runtime && !force_read)
+ {
+ GLuint64 result = 0;
+ glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT_AVAILABLE, &result);
+
+ if (result != GL_TRUE)
+ {
+ return false;
+ }
+ }
GLuint64 time_elapsed = 0;
glGetQueryObjectui64v(mTimerQuery, GL_QUERY_RESULT, &time_elapsed);
+ mTimeElapsed += time_elapsed;
+ mProfilePending = false;
- GLuint64 samples_passed = 0;
- glGetQueryObjectui64v(mSamplesQuery, GL_QUERY_RESULT, &samples_passed);
+ if (!for_runtime)
+ {
+ GLuint64 samples_passed = 0;
+ glGetQueryObjectui64v(mSamplesQuery, GL_QUERY_RESULT, &samples_passed);
- U64 primitives_generated = 0;
- glGetQueryObjectui64v(mPrimitivesQuery, GL_QUERY_RESULT, &primitives_generated);
- sTotalTimeElapsed += time_elapsed;
- mTimeElapsed += time_elapsed;
+ U64 primitives_generated = 0;
+ glGetQueryObjectui64v(mPrimitivesQuery, GL_QUERY_RESULT, &primitives_generated);
+ sTotalTimeElapsed += time_elapsed;
- sTotalSamplesDrawn += samples_passed;
- mSamplesDrawn += samples_passed;
+ sTotalSamplesDrawn += samples_passed;
+ mSamplesDrawn += samples_passed;
- U32 tri_count = (U32)primitives_generated / 3;
+ U32 tri_count = (U32)primitives_generated / 3;
- mTrianglesDrawn += tri_count;
- sTotalTrianglesDrawn += tri_count;
+ mTrianglesDrawn += tri_count;
+ sTotalTrianglesDrawn += tri_count;
- sTotalBinds++;
- mBinds++;
+ sTotalBinds++;
+ mBinds++;
+ }
}
+
+ return true;
}