summaryrefslogtreecommitdiff
path: root/indra/llrender
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
parent339e02ef3311ad5c1197dfca2955a0c202b7c408 (diff)
parent06bdee663433bf5b12eddcbcfcb8785546354c28 (diff)
Merge branch 'DRTVWR-559' into DRTVWR-583
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llglslshader.cpp72
-rw-r--r--indra/llrender/llglslshader.h16
-rw-r--r--indra/llrender/llimagegl.h2
-rw-r--r--indra/llrender/llrender.h9
-rw-r--r--indra/llrender/llrendertarget.cpp12
5 files changed, 73 insertions, 38 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;
}
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 9d187c972c..3e7dae6669 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -168,8 +168,16 @@ public:
void unload();
void clearStats();
void dumpStats();
- void placeProfileQuery();
- void readProfileQuery();
+
+ // place query objects for profiling if profiling is enabled
+ // if for_runtime is true, will place timer query only whether or not profiling is enabled
+ void placeProfileQuery(bool for_runtime = false);
+
+ // Readback query objects if profiling is enabled
+ // If for_runtime is true, will readback timer query iff query is available
+ // Will return false if a query is pending (try again later)
+ // If force_read is true, will force an immediate readback (severe performance penalty)
+ bool readProfileQuery(bool for_runtime = false, bool force_read = false);
BOOL createShader(std::vector<LLStaticHashedString>* attributes,
std::vector<LLStaticHashedString>* uniforms,
@@ -292,6 +300,7 @@ public:
defines_map_t mDefines;
//statistics for profiling shader performance
+ bool mProfilePending = false;
U32 mTimerQuery;
U32 mSamplesQuery;
U32 mPrimitivesQuery;
@@ -308,6 +317,9 @@ public:
// this pointer should be set to whichever shader represents this shader's rigged variant
LLGLSLShader* mRiggedVariant = nullptr;
+ // hacky flag used for optimization in LLDrawPoolAlpha
+ bool mCanBindFast = false;
+
#ifdef LL_PROFILER_ENABLE_RENDER_DOC
void setLabel(const char* label);
#endif
diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h
index 87fb9e363e..243aeaea25 100644
--- a/indra/llrender/llimagegl.h
+++ b/indra/llrender/llimagegl.h
@@ -340,7 +340,7 @@ public:
template <typename CALLABLE>
bool post(CALLABLE&& func)
{
- return getQueue().postIfOpen(std::forward<CALLABLE>(func));
+ return getQueue().post(std::forward<CALLABLE>(func));
}
void run() override;
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 909a1de2b3..98141d71f5 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -545,12 +545,7 @@ glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up);
-#if LL_RELEASE_FOR_DOWNLOAD
- #define LL_SHADER_LOADING_WARNS(...) LL_WARNS_ONCE("ShaderLoading")
- #define LL_SHADER_UNIFORM_ERRS(...) LL_WARNS_ONCE("Shader")
-#else
- #define LL_SHADER_LOADING_WARNS(...) LL_WARNS()
- #define LL_SHADER_UNIFORM_ERRS(...) LL_ERRS("Shader")
-#endif
+#define LL_SHADER_LOADING_WARNS(...) LL_WARNS()
+#define LL_SHADER_UNIFORM_ERRS(...) LL_ERRS("Shader")
#endif
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 629664b76d..88c48e5166 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -388,14 +388,14 @@ void LLRenderTarget::release()
glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO);
}
- if (mFBO == sCurFBO)
- {
- sCurFBO = 0;
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- }
-
if (mFBO)
{
+ if (mFBO == sCurFBO)
+ {
+ sCurFBO = 0;
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ }
+
glDeleteFramebuffers(1, (GLuint *) &mFBO);
mFBO = 0;
}