From d2dce17803a545378407d6b7c62fdcd3007a92bc Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 19 Oct 2021 02:26:41 +0000 Subject: SL-16197 Optimize LLEnvironment handling of shader uniforms. Instrument LLSD. Enable Fast Timers when Tracy is enabled to catch Fast Timer overhead. --- indra/llrender/llglslshader.h | 82 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 8 deletions(-) (limited to 'indra/llrender/llglslshader.h') diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 7cf6d3c941..3b23cf1b28 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -30,6 +30,7 @@ #include "llgl.h" #include "llrender.h" #include "llstaticstringtable.h" +#include class LLShaderFeatures { @@ -64,16 +65,79 @@ public: LLShaderFeatures(); }; +// ============= Structure for caching shader uniforms =============== +class LLGLSLShader; + +class LLShaderUniforms +{ +public: + + template + struct UniformSetting + { + S32 mUniform; + T mValue; + }; + + typedef UniformSetting IntSetting; + typedef UniformSetting FloatSetting; + typedef UniformSetting VectorSetting; + typedef UniformSetting Vector3Setting; + + void clear() + { + mIntegers.resize(0); + mFloats.resize(0); + mVectors.resize(0); + mVector3s.resize(0); + } + + void uniform1i(S32 index, S32 value) + { + mIntegers.push_back({ index, value }); + } + + void uniform1f(S32 index, F32 value) + { + mFloats.push_back({ index, value }); + } + + void uniform4fv(S32 index, const LLVector4& value) + { + mVectors.push_back({ index, value }); + } + + void uniform4fv(S32 index, const F32* value) + { + mVectors.push_back({ index, LLVector4(value) }); + } + + void uniform3fv(S32 index, const LLVector3& value) + { + mVector3s.push_back({ index, value }); + } + + void apply(LLGLSLShader* shader); + + + std::vector mIntegers; + std::vector mFloats; + std::vector mVectors; + std::vector mVector3s; +}; class LLGLSLShader { public: - enum + // enum primarily used to control application sky settings uniforms + typedef enum { - SG_DEFAULT = 0, - SG_SKY, - SG_WATER - }; + SG_DEFAULT = 0, // not sky or water specific + SG_SKY, // + SG_WATER, + SG_ANY, + SG_COUNT + } eGroup; static std::set sInstances; static bool sProfileEnabled; @@ -190,13 +254,15 @@ public: U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask()) std::vector mUniform; //lookup table of uniform enum to uniform location LLStaticStringTable mUniformMap; //lookup map of uniform name to uniform location - std::map mUniformNameMap; //lookup map of uniform location to uniform name - std::map mValue; //lookup map of uniform location to last known value + typedef std::unordered_map uniform_name_map_t; + typedef std::unordered_map uniform_value_map_t; + uniform_name_map_t mUniformNameMap; //lookup map of uniform location to uniform name + uniform_value_map_t mValue; //lookup map of uniform location to last known value std::vector mTexture; S32 mTotalUniformSize; S32 mActiveTextureChannels; S32 mShaderLevel; - S32 mShaderGroup; + S32 mShaderGroup; // see LLGLSLShader::eGroup BOOL mUniformsDirty; LLShaderFeatures mFeatures; std::vector< std::pair< std::string, GLenum > > mShaderFiles; -- cgit v1.2.3 From 28f9fb06a9f4cb9edccb2ff8132c7f6a9b27c060 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 20 Nov 2021 18:49:19 +0000 Subject: SL-16289 Rigged mesh rendering overhaul --- indra/llrender/llglslshader.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llglslshader.h') diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 3b23cf1b28..6fdb789087 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -230,6 +230,8 @@ public: BOOL link(BOOL suppress_errors = FALSE); void bind(); + //helper to conditionally bind mRiggedVariant instead of this + void bind(bool rigged); void unbind(); // Unbinds any previously bound shader by explicitly binding no shader. @@ -267,7 +269,8 @@ public: LLShaderFeatures mFeatures; std::vector< std::pair< std::string, GLenum > > mShaderFiles; std::string mName; - boost::unordered_map mDefines; + typedef std::unordered_map defines_map_t; + defines_map_t mDefines; //statistcis for profiling shader performance U32 mTimerQuery; @@ -285,6 +288,9 @@ public: std::vector mTextureMagFilter; std::vector mTextureMinFilter; + // this pointer should be set to whichever shader represents this shader's rigged variant + LLGLSLShader* mRiggedVariant = nullptr; + private: void unloadInternal(); }; -- cgit v1.2.3 From 68e09edad0d863d57ba06e2842b9399f3ff21618 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Mon, 29 Nov 2021 17:07:25 -0700 Subject: SL-16386 remove references to (const true) LLGLSLShader::sNoFixedFunction --- indra/llrender/llglslshader.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llrender/llglslshader.h') diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 6fdb789087..85e83dbcb9 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -148,7 +148,6 @@ public: static GLhandleARB sCurBoundShader; static LLGLSLShader* sCurBoundShaderPtr; static S32 sIndexedTextureChannels; - static bool sNoFixedFunction; static void initProfile(); static void finishProfile(bool emit_report = true); -- cgit v1.2.3