diff options
author | RunitaiLinden <davep@lindenlab.com> | 2023-05-02 18:47:21 -0500 |
---|---|---|
committer | RunitaiLinden <davep@lindenlab.com> | 2023-05-02 18:47:21 -0500 |
commit | e09475713b7abe6fcb916f4a770081a1696b57ab (patch) | |
tree | 23ff7f10a9f710e237600df5bbc40b180ed71010 /indra/llrender/llglslshader.cpp | |
parent | 2994833e7cc53670bd3303cb88054d7acee875cf (diff) |
DRTVWR-559 Optimization pass, make it so profileAvatar can read back GPU timer without a frame stall.
Diffstat (limited to 'indra/llrender/llglslshader.cpp')
-rw-r--r-- | indra/llrender/llglslshader.cpp | 72 |
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; } |