summaryrefslogtreecommitdiff
path: root/indra/llrender/llglslshader.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llglslshader.h')
-rw-r--r--indra/llrender/llglslshader.h98
1 files changed, 72 insertions, 26 deletions
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 43d095f73a..873ab0cff5 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 <boost/json.hpp>
#include <unordered_map>
class LLShaderFeatures
@@ -44,18 +45,21 @@ public:
bool hasTransport = false; // implies no lighting (it's possible to have neither though)
bool hasSkinning = false;
bool hasObjectSkinning = false;
+ bool mGLTF = false;
bool hasAtmospherics = false;
bool hasGamma = false;
bool hasShadows = false;
bool hasAmbientOcclusion = false;
bool hasSrgb = false;
- bool encodesNormal = false; // include: shaders\class1\environment\encodeNormF.glsl
bool isDeferred = false;
+ bool hasFullGBuffer = false;
bool hasScreenSpaceReflections = false;
- bool disableTextureIndex = false;
bool hasAlphaMask = false;
bool hasReflectionProbes = false;
bool attachNothing = false;
+ bool hasHeroProbes = false;
+ bool isPBRTerrain = false;
+ bool hasTonemap = false;
};
// ============= Structure for caching shader uniforms ===============
@@ -68,8 +72,8 @@ public:
template<typename T>
struct UniformSetting
{
- S32 mUniform;
- T mValue;
+ S32 mUniform{ 0 };
+ T mValue{};
};
typedef UniformSetting<S32> IntSetting;
@@ -144,6 +148,16 @@ public:
SG_COUNT
} eGroup;
+ enum UniformBlock : GLuint
+ {
+ UB_REFLECTION_PROBES, // "ReflectionProbes"
+ UB_GLTF_JOINTS, // "GLTFJoints"
+ UB_GLTF_NODES, // "GLTFNodes"
+ UB_GLTF_MATERIALS, // "GLTFMaterials"
+ NUM_UNIFORM_BLOCKS
+ };
+
+
static std::set<LLGLSLShader*> sInstances;
static bool sProfileEnabled;
@@ -154,15 +168,18 @@ public:
static LLGLSLShader* sCurBoundShaderPtr;
static S32 sIndexedTextureChannels;
+ static U32 sMaxGLTFMaterials;
+ static U32 sMaxGLTFNodes;
+
static void initProfile();
- static void finishProfile(bool emit_report = true);
+ static void finishProfile(boost::json::value& stats=sDefaultStats);
static void startProfile();
static void stopProfile();
void unload();
void clearStats();
- void dumpStats();
+ void dumpStats(boost::json::object& stats);
// 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
@@ -174,17 +191,14 @@ public:
// 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,
- U32 varying_count = 0,
- const char** varyings = NULL);
- BOOL attachFragmentObject(std::string object);
- BOOL attachVertexObject(std::string object);
+ bool createShader();
+ bool attachFragmentObject(std::string object);
+ bool attachVertexObject(std::string object);
void attachObject(GLuint object);
void attachObjects(GLuint* objects = NULL, S32 count = 0);
- BOOL mapAttributes(const std::vector<LLStaticHashedString>* attributes);
- BOOL mapUniforms(const std::vector<LLStaticHashedString>*);
- void mapUniform(GLint index, const std::vector<LLStaticHashedString>*);
+ bool mapAttributes();
+ bool mapUniforms();
+ void mapUniform(GLint index);
void uniform1i(U32 index, GLint i);
void uniform1f(U32 index, GLfloat v);
void fastUniform1f(U32 index, GLfloat v);
@@ -197,6 +211,7 @@ public:
void uniform2fv(U32 index, U32 count, const GLfloat* v);
void uniform3fv(U32 index, U32 count, const GLfloat* v);
void uniform4fv(U32 index, U32 count, const GLfloat* v);
+ void uniform4uiv(U32 index, U32 count, const GLuint* v);
void uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j);
void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v);
void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat* v);
@@ -208,10 +223,12 @@ public:
void uniform1f(const LLStaticHashedString& uniform, GLfloat v);
void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y);
void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z);
+ void uniform4f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
+ void uniform4uiv(const LLStaticHashedString& uniform, U32 count, const GLuint* v);
void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v);
void setMinimumAlpha(F32 minimum);
@@ -228,34 +245,38 @@ public:
void clearPermutations();
void addPermutation(std::string name, std::string value);
+ void addPermutations(const std::map<std::string, std::string>& defines)
+ {
+ mDefines.insert(defines.begin(), defines.end());
+ }
void removePermutation(std::string name);
void addConstant(const LLGLSLShader::eShaderConsts shader_const);
//enable/disable texture channel for specified uniform
- //if given texture uniform is active in the shader,
+ //if given texture uniform is active in the shader,
//the corresponding channel will be active upon return
//returns channel texture is enabled in from [0-MAX)
- S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
- S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
+ S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
+ S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
// get the texture channel of the given uniform, or -1 if uniform is not used as a texture
S32 getTextureChannel(S32 uniform) const;
// bindTexture returns the texture unit we've bound the texture to.
// You can reuse the return value to unbind a texture when required.
- S32 bindTexture(const std::string& uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
- S32 bindTexture(S32 uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
+ S32 bindTexture(const std::string& uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
+ S32 bindTexture(S32 uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 bindTexture(const std::string& uniform, LLRenderTarget* texture, bool depth = false, LLTexUnit::eTextureFilterOptions mode = LLTexUnit::TFO_BILINEAR);
S32 bindTexture(S32 uniform, LLRenderTarget* texture, bool depth = false, LLTexUnit::eTextureFilterOptions mode = LLTexUnit::TFO_BILINEAR, U32 index = 0);
S32 unbindTexture(const std::string& uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 unbindTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
- BOOL link(BOOL suppress_errors = FALSE);
+ bool link(bool suppress_errors = false);
void bind();
//helper to conditionally bind mRiggedVariant instead of this
void bind(bool rigged);
-
+
bool isComplete() const { return mProgramObject != 0; }
LLUUID hash();
@@ -289,7 +310,7 @@ public:
S32 mActiveTextureChannels;
S32 mShaderLevel;
S32 mShaderGroup; // see LLGLSLShader::eGroup
- BOOL mUniformsDirty;
+ bool mUniformsDirty;
LLShaderFeatures mFeatures;
std::vector< std::pair< std::string, GLenum > > mShaderFiles;
std::string mName;
@@ -317,6 +338,26 @@ public:
// this pointer should be set to whichever shader represents this shader's rigged variant
LLGLSLShader* mRiggedVariant = nullptr;
+ // variants for use by GLTF renderer
+ // bit 0 = alpha mode blend (1) or opaque (0)
+ // bit 1 = rigged (1) or static (0)
+ // bit 2 = unlit (1) or lit (0)
+ // bit 3 = single (0) or multi (1) uv coordinates
+ struct GLTFVariant
+ {
+ constexpr static U8 ALPHA_BLEND = 1;
+ constexpr static U8 RIGGED = 2;
+ constexpr static U8 UNLIT = 4;
+ constexpr static U8 MULTI_UV = 8;
+ };
+
+ constexpr static U8 NUM_GLTF_VARIANTS = 16;
+
+ std::vector<LLGLSLShader> mGLTFVariants;
+
+ //helper to bind GLTF variant
+ void bind(U8 variant);
+
// hacky flag used for optimization in LLDrawPoolAlpha
bool mCanBindFast = false;
@@ -326,14 +367,19 @@ public:
private:
void unloadInternal();
+ // This must be static because finishProfile() is called at least once
+ // within a __try block. If we default its stats parameter to a temporary
+ // json::value, that temporary must be destroyed when the stack is
+ // unwound, which __try forbids.
+ static boost::json::value sDefaultStats;
};
//UI shader (declared here so llui_libtest will link properly)
-extern LLGLSLShader gUIProgram;
+extern LLGLSLShader gUIProgram;
//output vec4(color.rgb,color.a*tex0[tc0].a)
-extern LLGLSLShader gSolidColorProgram;
+extern LLGLSLShader gSolidColorProgram;
//Alpha mask shader (declared here so llappearance can access properly)
-extern LLGLSLShader gAlphaMaskProgram;
+extern LLGLSLShader gAlphaMaskProgram;
#ifdef LL_PROFILER_ENABLE_RENDER_DOC
#define LL_SET_SHADER_LABEL(shader) shader.setLabel(#shader)