From 93a025966649e281ceff8d1471bc983cc036bc17 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 29 Apr 2022 13:51:11 +0000 Subject: SL-17282 prototype mixing of reflection map into legacy materials --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index c100c182dd..cd7ec478bb 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1155,6 +1155,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bumpMap"); mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); + mReservedUniforms.push_back("reflectionMap"); mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("cloud_noise_texture_next"); mReservedUniforms.push_back("fullbright"); -- cgit v1.2.3 From 3400e5fd302c0d9dea6386c4d5bf38876f2cc287 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 16 May 2022 17:21:08 +0000 Subject: SL-17284 Reflection probe tuning and optimization take 1 --- indra/llrender/llshadermgr.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index cd7ec478bb..8e8f44e99b 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -712,8 +712,15 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade { if (major_version >= 4) { - //set version to 400 - shader_code_text[shader_code_count++] = strdup("#version 400\n"); + //set version to 400 or 420 + if (minor_version >= 20) + { + shader_code_text[shader_code_count++] = strdup("#version 420\n"); + } + else + { + shader_code_text[shader_code_count++] = strdup("#version 400\n"); + } } else if (major_version == 3) { @@ -1155,7 +1162,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bumpMap"); mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); - mReservedUniforms.push_back("reflectionMap"); + mReservedUniforms.push_back("reflectionProbes"); mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("cloud_noise_texture_next"); mReservedUniforms.push_back("fullbright"); -- cgit v1.2.3 From 3564b24e2a90e0772c37185cc5dcedca29d62ab8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 19 May 2022 22:24:41 -0500 Subject: SL-17286 Reflection probe alpha/fullbright support. --- indra/llrender/llshadermgr.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 8e8f44e99b..bdc1f78201 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -218,6 +218,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } + if (features->hasReflectionProbes) + { + if (!shader->attachFragmentObject("deferred/reflectionProbeF.glsl")) + { + return FALSE; + } + } + if (features->hasAmbientOcclusion) { if (!shader->attachFragmentObject("deferred/aoUtil.glsl")) -- cgit v1.2.3 From 929abcd296199ab4ed7a0b08166e284502f7b8df Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 10 Jun 2022 16:36:38 -0500 Subject: SL-17523 Add reflection probe ambiance to windlight settings and integrate with UI and ReflectionMapManager --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index bdc1f78201..e2e1ff9714 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1342,6 +1342,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("halo_map"); mReservedUniforms.push_back("moon_brightness"); mReservedUniforms.push_back("cloud_variance"); + mReservedUniforms.push_back("reflection_probe_ambiance"); mReservedUniforms.push_back("sh_input_r"); mReservedUniforms.push_back("sh_input_g"); -- cgit v1.2.3 From 36d9fa90150d30a0a0851cc0da87531014c1d93d Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 21 Jun 2022 16:31:35 -0700 Subject: SL-17274: Add view_dir uniform --- indra/llrender/llshadermgr.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e2e1ff9714..4dd5bb591b 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1217,6 +1217,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("minimum_alpha"); mReservedUniforms.push_back("emissive_brightness"); + // Deferred mReservedUniforms.push_back("shadow_matrix"); mReservedUniforms.push_back("env_mat"); mReservedUniforms.push_back("shadow_clip"); @@ -1241,8 +1242,9 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("depth_cutoff"); mReservedUniforms.push_back("norm_cutoff"); mReservedUniforms.push_back("shadow_target_width"); + mReservedUniforms.push_back("view_dir"); // DEFERRED_VIEW_DIR - llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH+1); + llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_VIEW_DIR+1); mReservedUniforms.push_back("tc_scale"); mReservedUniforms.push_back("rcp_screen_res"); -- cgit v1.2.3 From 77b96114c30232c1d3f3b548bf982f89f11d09da Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 21 Jun 2022 22:00:12 -0700 Subject: SL-17274 Cleanup hard-coded gbuffer atmos flag for softenlight --- indra/llrender/llshadermgr.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e2e1ff9714..f1996b65e9 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -787,7 +787,12 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade extra_code_text[extra_code_count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n"); } } - + + // Use alpha float to store bit flags + // See: C++: addDeferredAttachment(), shader: frag_data[2] + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 1.0\n"); // atmo kill + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 0.0\n"); + if (defines) { for (std::unordered_map::iterator iter = defines->begin(); iter != defines->end(); ++iter) -- cgit v1.2.3 From 27ca7760cc4126c8c45a5c22edafee5d2984a742 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 21 Jun 2022 22:23:38 -0700 Subject: SL-17274: Remove hard-coded magic number checking if G-Buffer flag is set --- indra/llrender/llshadermgr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index f1996b65e9..4700d351f7 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -790,8 +790,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade // Use alpha float to store bit flags // See: C++: addDeferredAttachment(), shader: frag_data[2] - extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 1.0\n"); // atmo kill - extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 0.0\n"); + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 0.0\n"); // atmo kill + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 1.0\n"); + extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag) (norm.w>0.5)\n"); if (defines) { -- cgit v1.2.3 From d0d1b832d4983f35ab29947eb6fda54a8aa48f8a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Jun 2022 13:25:50 -0500 Subject: SL-17600 Proper irradiance probes. --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e2e1ff9714..10939db5e4 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1171,6 +1171,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); mReservedUniforms.push_back("reflectionProbes"); + mReservedUniforms.push_back("irradianceProbes"); mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("cloud_noise_texture_next"); mReservedUniforms.push_back("fullbright"); -- cgit v1.2.3 From 4d2b2f464be0c1b42462abf31b422e7248d49131 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 22 Jun 2022 11:32:10 -0700 Subject: SL-17274: Add GBuffer flag for PBR --- indra/llrender/llshadermgr.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 4700d351f7..fd1e85c68d 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -790,9 +790,10 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade // Use alpha float to store bit flags // See: C++: addDeferredAttachment(), shader: frag_data[2] - extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 0.0\n"); // atmo kill - extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 1.0\n"); - extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag) (norm.w>0.5)\n"); + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 0.0 \n"); // atmo kill + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 0.25\n"); // bit 0 + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_PBR 0.50\n"); // bit 1 + extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag) (mod(floor(norm.w/flag),2.0)>0.5)\n"); if (defines) { -- cgit v1.2.3 From 9439c721f4672d4ed3afdeb41f493c9968ecf28b Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 24 Jun 2022 12:15:34 -0500 Subject: SL-17274 Hook up emissive map and non-texture parameters to pbropaqueF.glsl --- indra/llrender/llshadermgr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 09d3f95736..896c4d2366 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1170,10 +1170,14 @@ void LLShaderMgr::initAttribsAndUniforms() llassert(mReservedUniforms.size() == LLShaderMgr::PROJECTOR_AMBIENT_LOD+1); mReservedUniforms.push_back("color"); - + mReservedUniforms.push_back("emissiveColor"); + mReservedUniforms.push_back("metallicFactor"); + mReservedUniforms.push_back("roughnessFactor"); + mReservedUniforms.push_back("diffuseMap"); mReservedUniforms.push_back("altDiffuseMap"); mReservedUniforms.push_back("specularMap"); + mReservedUniforms.push_back("emissiveMap"); mReservedUniforms.push_back("bumpMap"); mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); -- cgit v1.2.3 From 254bbc86e5d1d3ec094779f46619c109d027da18 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Jun 2022 15:39:04 -0500 Subject: Add emissiveRect to softenLightF.glsl --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 896c4d2366..05e0726798 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1286,6 +1286,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("positionMap"); mReservedUniforms.push_back("diffuseRect"); mReservedUniforms.push_back("specularRect"); + mReservedUniforms.push_back("emissiveRect"); mReservedUniforms.push_back("noiseMap"); mReservedUniforms.push_back("lightFunc"); mReservedUniforms.push_back("lightMap"); -- cgit v1.2.3 From 5cfc336ba2917116492b9d74ed02748bbbd725fd Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Jun 2022 18:46:48 -0500 Subject: Fix for 2-bit errors in writing to and reading from norm.w --- indra/llrender/llshadermgr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 05e0726798..686eaddc24 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -791,9 +791,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade // Use alpha float to store bit flags // See: C++: addDeferredAttachment(), shader: frag_data[2] extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 0.0 \n"); // atmo kill - extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 0.25\n"); // bit 0 - extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_PBR 0.50\n"); // bit 1 - extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag) (mod(floor(norm.w/flag),2.0)>0.5)\n"); + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_ATMOS 0.34\n"); // bit 0 + extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_HAS_PBR 0.67\n"); // bit 1 + extra_code_text[extra_code_count++] = strdup("#define GET_GBUFFER_FLAG(flag) (abs(norm.w-flag)< 0.1)\n"); if (defines) { -- cgit v1.2.3 From 664ba53e4ce8510345e490cedf4401f6655f38fc Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 15 Jun 2022 16:00:21 +0300 Subject: SL-17584 Make setShaders crashes more informative --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 686eaddc24..96fb764f75 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -673,7 +673,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (file == NULL) { - LL_SHADER_LOADING_WARNS() << "GLSL Shader file not found: " << open_file_name << LL_ENDL; + LL_WARNS("ShaderLoading") << "GLSL Shader file not found: " << open_file_name << LL_ENDL; return 0; } -- cgit v1.2.3 From 2082443220fe344bb027c3acbf50fea0a99159c3 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 1 Sep 2022 10:58:27 -0700 Subject: SL-17967 - Git rid of ARB that is in core --- indra/llrender/llshadermgr.cpp | 65 +++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 30 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 96fb764f75..43d59f7b43 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -558,18 +558,18 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) //============================================================================ // Load Shader -static std::string get_object_log(GLhandleARB ret) +static std::string get_object_log(GLuint ret) { std::string res; //get log length GLint length; - glGetObjectParameterivARB(ret, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); + glGetShaderiv(ret, GL_INFO_LOG_LENGTH, &length); if (length > 0) { //the log could be any size, so allocate appropriately - GLcharARB* log = new GLcharARB[length]; - glGetInfoLogARB(ret, length, &length, log); + GLchar* log = new GLchar[length]; + glGetProgramInfoLog(ret, length, &length, log); res = std::string((char *)log); delete[] log; } @@ -577,7 +577,7 @@ static std::string get_object_log(GLhandleARB ret) } //dump shader source for debugging -void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLcharARB** shader_code_text) +void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLchar** shader_code_text) { char num_str[16]; // U32 = max 10 digits @@ -592,7 +592,7 @@ void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLcharARB** shader_cod LL_CONT << LL_ENDL; } -void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns, const std::string& filename) +void LLShaderMgr::dumpObjectLog(GLuint ret, BOOL warns, const std::string& filename) { std::string log = get_object_log(ret); std::string fname = filename; @@ -608,7 +608,7 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns, const std::string& } } -GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::unordered_map* defines, S32 texture_index_channels) +GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::unordered_map* defines, S32 texture_index_channels) { // endsure work-around for missing GLSL funcs gets propogated to feature shader files (e.g. srgbF.glsl) @@ -679,9 +679,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //we can't have any lines longer than 1024 characters //or any shaders longer than 4096 lines... deal - DaveP - GLcharARB buff[1024]; - GLcharARB *extra_code_text[1024]; - GLcharARB *shader_code_text[4096 + LL_ARRAY_SIZE(extra_code_text)] = { NULL }; + GLchar buff[1024]; + GLchar *extra_code_text[1024]; + GLchar *shader_code_text[4096 + LL_ARRAY_SIZE(extra_code_text)] = { NULL }; GLuint extra_code_count = 0, shader_code_count = 0; BOOST_STATIC_ASSERT(LL_ARRAY_SIZE(extra_code_text) < LL_ARRAY_SIZE(shader_code_text)); @@ -763,7 +763,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade extra_code_text[extra_code_count++] = strdup("#define ATTRIBUTE in\n"); - if (type == GL_VERTEX_SHADER_ARB) + if (type == GL_VERTEX_SHADER) { //"varying" state is "out" in a vertex program, "in" in a fragment program // ("varying" is deprecated after version 1.20) extra_code_text[extra_code_count++] = strdup("#define VARYING out\n"); @@ -800,7 +800,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade for (std::unordered_map::iterator iter = defines->begin(); iter != defines->end(); ++iter) { std::string define = "#define " + iter->first + " " + iter->second + "\n"; - extra_code_text[extra_code_count++] = (GLcharARB *) strdup(define.c_str()); + extra_code_text[extra_code_count++] = (GLchar *) strdup(define.c_str()); } } @@ -809,7 +809,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade extra_code_text[extra_code_count++] = strdup( "#define IS_AMD_CARD 1\n" ); } - if (texture_index_channels > 0 && type == GL_FRAGMENT_SHADER_ARB) + if (texture_index_channels > 0 && type == GL_FRAGMENT_SHADER) { //use specified number of texture channels for indexed texture rendering @@ -949,7 +949,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } else { - shader_code_text[shader_code_count] = (GLcharARB *)strdup((char *)buff); + shader_code_text[shader_code_count] = (GLchar *)strdup((char *)buff); if(flag_write_to_out_of_extra_block_area & flags) { @@ -985,41 +985,46 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade fclose(file); + error = glGetError(); + if (error != GL_NO_ERROR) + { + LL_WARNS("HRS") << "WTF? Should be no error here: " << error << LL_ENDL; + } //create shader object - GLhandleARB ret = glCreateShaderObjectARB(type); + GLuint ret = glCreateShader(type); error = glGetError(); if (error != GL_NO_ERROR) { - LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShaderObjectARB: " << error << " for file: " << open_file_name << LL_ENDL; + LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShader: " << error << " for file: " << open_file_name << LL_ENDL; } //load source - glShaderSourceARB(ret, shader_code_count, (const GLcharARB**) shader_code_text, NULL); + glShaderSource(ret, shader_code_count, (const GLchar**) shader_code_text, NULL); error = glGetError(); if (error != GL_NO_ERROR) { - LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSourceARB: " << error << " for file: " << open_file_name << LL_ENDL; + LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSource: " << error << " for file: " << open_file_name << LL_ENDL; } //compile source - glCompileShaderARB(ret); + glCompileShader(ret); error = glGetError(); if (error != GL_NO_ERROR) { - LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShaderARB: " << error << " for file: " << open_file_name << LL_ENDL; + LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShader: " << error << " for file: " << open_file_name << LL_ENDL; } if (error == GL_NO_ERROR) { //check for errors GLint success = GL_TRUE; - glGetObjectParameterivARB(ret, GL_OBJECT_COMPILE_STATUS_ARB, &success); + glGetShaderiv(ret, GL_COMPILE_STATUS, &success); error = glGetError(); - if (error != GL_NO_ERROR || success == GL_FALSE) + if (error != GL_NO_ERROR || success == GL_FALSE) { //an error occured, print log LL_WARNS("ShaderLoading") << "GLSL Compilation Error:" << LL_ENDL; @@ -1044,10 +1049,10 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (ret) { // Add shader file to map - if (type == GL_VERTEX_SHADER_ARB) { + if (type == GL_VERTEX_SHADER) { mVertexShaderObjects[filename] = ret; } - else if (type == GL_FRAGMENT_SHADER_ARB) { + else if (type == GL_FRAGMENT_SHADER) { mFragmentShaderObjects[filename] = ret; } shader_level = try_gpu_class; @@ -1064,12 +1069,12 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade return ret; } -BOOL LLShaderMgr::linkProgramObject(GLhandleARB obj, BOOL suppress_errors) +BOOL LLShaderMgr::linkProgramObject(GLuint obj, BOOL suppress_errors) { //check for errors - glLinkProgramARB(obj); + glLinkProgram(obj); GLint success = GL_TRUE; - glGetObjectParameterivARB(obj, GL_OBJECT_LINK_STATUS_ARB, &success); + glGetProgramiv(obj, GL_LINK_STATUS, &success); if (!suppress_errors && success == GL_FALSE) { //an error occured, print log @@ -1087,12 +1092,12 @@ BOOL LLShaderMgr::linkProgramObject(GLhandleARB obj, BOOL suppress_errors) return success; } -BOOL LLShaderMgr::validateProgramObject(GLhandleARB obj) +BOOL LLShaderMgr::validateProgramObject(GLuint obj) { //check program validity against current GL - glValidateProgramARB(obj); + glValidateProgram(obj); GLint success = GL_TRUE; - glGetObjectParameterivARB(obj, GL_OBJECT_VALIDATE_STATUS_ARB, &success); + glGetProgramiv(obj, GL_LINK_STATUS, &success); if (success == GL_FALSE) { LL_SHADER_LOADING_WARNS() << "GLSL program not valid: " << LL_ENDL; -- cgit v1.2.3 From 013a7130011f72ab0c124dba87376b9862a95461 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Fri, 2 Sep 2022 15:44:19 -0700 Subject: SL-17967 - slightly more meaningful ogl error reporting --- indra/llrender/llshadermgr.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 43d59f7b43..96e83e6fbe 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -592,7 +592,7 @@ void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLchar** shader_code_t LL_CONT << LL_ENDL; } -void LLShaderMgr::dumpObjectLog(GLuint ret, BOOL warns, const std::string& filename) +void LLShaderMgr::dumpObjectLog(GLuint ret, BOOL warns, const std::string& filename) { std::string log = get_object_log(ret); std::string fname = filename; @@ -985,11 +985,6 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev fclose(file); - error = glGetError(); - if (error != GL_NO_ERROR) - { - LL_WARNS("HRS") << "WTF? Should be no error here: " << error << LL_ENDL; - } //create shader object GLuint ret = glCreateShader(type); @@ -1069,7 +1064,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev return ret; } -BOOL LLShaderMgr::linkProgramObject(GLuint obj, BOOL suppress_errors) +BOOL LLShaderMgr::linkProgramObject(GLuint obj, BOOL suppress_errors) { //check for errors glLinkProgram(obj); @@ -1079,6 +1074,8 @@ BOOL LLShaderMgr::linkProgramObject(GLuint obj, BOOL suppress_errors) { //an error occured, print log LL_SHADER_LOADING_WARNS() << "GLSL Linker Error:" << LL_ENDL; + dumpObjectLog(obj, TRUE, "linker"); + return success; } std::string log = get_object_log(obj); @@ -1178,7 +1175,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("emissiveColor"); mReservedUniforms.push_back("metallicFactor"); mReservedUniforms.push_back("roughnessFactor"); - + mReservedUniforms.push_back("diffuseMap"); mReservedUniforms.push_back("altDiffuseMap"); mReservedUniforms.push_back("specularMap"); -- cgit v1.2.3 From 60cc58fbfc23efe133dca3797188462d1b2ae5ab Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 2 Sep 2022 21:05:53 -0500 Subject: SL-17967 Fix for confounding program and shader objects when fetching logs and fix for gl errors on AMD windows --- indra/llrender/llshadermgr.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 96e83e6fbe..5293166ec3 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -558,7 +558,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) //============================================================================ // Load Shader -static std::string get_object_log(GLuint ret) +static std::string get_shader_log(GLuint ret) { std::string res; @@ -569,13 +569,46 @@ static std::string get_object_log(GLuint ret) { //the log could be any size, so allocate appropriately GLchar* log = new GLchar[length]; - glGetProgramInfoLog(ret, length, &length, log); + glGetShaderInfoLog(ret, length, &length, log); res = std::string((char *)log); delete[] log; } return res; } +static std::string get_program_log(GLuint ret) +{ + std::string res; + + //get log length + GLint length; + glGetProgramiv(ret, GL_INFO_LOG_LENGTH, &length); + if (length > 0) + { + //the log could be any size, so allocate appropriately + GLchar* log = new GLchar[length]; + glGetProgramInfoLog(ret, length, &length, log); + res = std::string((char*)log); + delete[] log; + } + return res; +} + +// get the info log for the given object, be it a shader or program object +// NOTE: ret MUST be a shader OR a program object +static std::string get_object_log(GLuint ret) +{ + if (glIsProgram(ret)) + { + return get_program_log(ret); + } + else + { + llassert(glIsShader(ret)); + return get_shader_log(ret); + } +} + //dump shader source for debugging void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLchar** shader_code_text) { @@ -594,7 +627,8 @@ void LLShaderMgr::dumpShaderSource(U32 shader_code_count, GLchar** shader_code_t void LLShaderMgr::dumpObjectLog(GLuint ret, BOOL warns, const std::string& filename) { - std::string log = get_object_log(ret); + std::string log; + log = get_object_log(ret); std::string fname = filename; if (filename.empty()) { @@ -1078,7 +1112,7 @@ BOOL LLShaderMgr::linkProgramObject(GLuint obj, BOOL suppress_errors) return success; } - std::string log = get_object_log(obj); + std::string log = get_program_log(obj); LLStringUtil::toLower(log); if (log.find("software") != std::string::npos) { -- cgit v1.2.3 From ff3a28422dc65afe4cf3131daf953d0567711b8a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 13 Sep 2022 17:07:30 -0500 Subject: SL-17701 WIP -- Parity for point lights between opaque and transparent PBR materials --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 5293166ec3..2ea1c0d698 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1180,6 +1180,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("light_position"); mReservedUniforms.push_back("light_direction"); mReservedUniforms.push_back("light_attenuation"); + mReservedUniforms.push_back("light_deferred_attenuation"); mReservedUniforms.push_back("light_diffuse"); mReservedUniforms.push_back("light_ambient"); mReservedUniforms.push_back("light_count"); -- cgit v1.2.3 From b2cf07f53ca9f0ab82d466063af8307631c50f31 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 17 Sep 2022 01:12:52 -0500 Subject: WIP - switch PBR implementations --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 2ea1c0d698..b609a74e32 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1324,6 +1324,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("diffuseRect"); mReservedUniforms.push_back("specularRect"); mReservedUniforms.push_back("emissiveRect"); + mReservedUniforms.push_back("brdfLut"); mReservedUniforms.push_back("noiseMap"); mReservedUniforms.push_back("lightFunc"); mReservedUniforms.push_back("lightMap"); -- cgit v1.2.3 From aaf7b17db047f0cb2630b479d5468062e6ca815e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 27 Sep 2022 23:32:02 -0500 Subject: SL-18190 WIP -- Take 2 on linear space windlight (more methodical approach -- make desired interface but brute force color conversions). Placeholder PBR water and move to deprecate forward rendering shaders. --- indra/llrender/llshadermgr.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index b609a74e32..c817a59189 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -145,6 +145,11 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) // NOTE order of shader object attaching is VERY IMPORTANT!!! if (features->calculatesAtmospherics) { + if (!shader->attachVertexObject("environment/srgbF.glsl")) // NOTE -- "F" suffix is superfluous here, there is nothing fragment specific in srgbF + { + return FALSE; + } + if (!shader->attachVertexObject("windlight/atmosphericsFuncs.glsl")) { return FALSE; } @@ -177,6 +182,13 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) /////////////////////////////////////// // NOTE order of shader object attaching is VERY IMPORTANT!!! + if (features->hasSrgb || features->hasAtmospherics || features->calculatesAtmospherics) + { + if (!shader->attachFragmentObject("environment/srgbF.glsl")) + { + return FALSE; + } + } if(features->calculatesAtmospherics) { @@ -250,14 +262,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasSrgb) - { - if (!shader->attachFragmentObject("environment/srgbF.glsl")) - { - return FALSE; - } - } - if (features->encodesNormal) { if (!shader->attachFragmentObject("environment/encodeNormF.glsl")) @@ -1405,6 +1409,9 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("water_edge"); mReservedUniforms.push_back("sun_up_factor"); mReservedUniforms.push_back("moonlight_color"); + mReservedUniforms.push_back("moonlight_linear"); + mReservedUniforms.push_back("sunlight_linear"); + mReservedUniforms.push_back("ambient_linear"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); -- cgit v1.2.3 From 2e499bcc40871b6a68700203cc83fe7d81c79c24 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 28 Sep 2022 19:14:00 -0500 Subject: SL-18190 Prune srgb_to_linear from atmosphericsFuncs.glsl --- indra/llrender/llshadermgr.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index c817a59189..8807433d80 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1231,9 +1231,12 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("sunlight_color"); mReservedUniforms.push_back("ambient_color"); mReservedUniforms.push_back("blue_horizon"); + mReservedUniforms.push_back("blue_horizon_linear"); mReservedUniforms.push_back("blue_density"); + mReservedUniforms.push_back("blue_density_linear"); mReservedUniforms.push_back("haze_horizon"); mReservedUniforms.push_back("haze_density"); + mReservedUniforms.push_back("haze_density_linear"); mReservedUniforms.push_back("cloud_shadow"); mReservedUniforms.push_back("density_multiplier"); mReservedUniforms.push_back("distance_multiplier"); -- cgit v1.2.3 From 1900df361558313f10e8b27ada03bcefd41241d9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 4 Oct 2022 12:20:19 -0500 Subject: SL-18293, SL-18190 -- Fix for debug displays not showing up (wireframe still busted). WIP on reflection probe/PBR driven water shader. --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 8807433d80..a363eac59e 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -214,7 +214,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } // we want this BEFORE shadows and AO because those facilities use pos/norm access - if (features->isDeferred) + if (features->isDeferred || features->hasReflectionProbes) { if (!shader->attachFragmentObject("deferred/deferredUtil.glsl")) { -- cgit v1.2.3 From 42ec639c860e172803753b9cb41ae9483305f2f8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 12 Oct 2022 14:46:51 -0500 Subject: SL-18190 Remove water reflection detail combo box and reimplement "Transparent Water" checkbox. --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index a363eac59e..7f7829c18e 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1357,6 +1357,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("specular"); mReservedUniforms.push_back("lightExp"); mReservedUniforms.push_back("waterFogColor"); + mReservedUniforms.push_back("waterFogColorLinear"); mReservedUniforms.push_back("waterFogDensity"); mReservedUniforms.push_back("waterFogKS"); mReservedUniforms.push_back("refScale"); -- cgit v1.2.3 From 9e7b725c15ea0bfea5246eb81dd7a100b7ac5b6b Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 31 Oct 2022 09:42:27 -0700 Subject: SL-18485: Render GLTF materials with extension KHR_texture_transform with approprate texture transforms --- indra/llrender/llshadermgr.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 7f7829c18e..e8cf7ec758 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1163,6 +1163,10 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedAttribs.push_back("weight4"); mReservedAttribs.push_back("clothing"); mReservedAttribs.push_back("texture_index"); + mReservedAttribs.push_back("basecolor_texcoord"); // GLTF + mReservedAttribs.push_back("normal_texcoord"); // GLTF + mReservedAttribs.push_back("metallic_roughness_texcoord"); // GLTF + mReservedAttribs.push_back("emissive_texcoord"); // GLTF //matrix state mReservedUniforms.push_back("modelview_matrix"); @@ -1177,7 +1181,11 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("texture_matrix3"); mReservedUniforms.push_back("object_plane_s"); mReservedUniforms.push_back("object_plane_t"); - llassert(mReservedUniforms.size() == LLShaderMgr::OBJECT_PLANE_T+1); + mReservedUniforms.push_back("texture_basecolor_matrix"); // GLTF + mReservedUniforms.push_back("texture_normal_matrix"); // GLTF + mReservedUniforms.push_back("texture_metallic_roughness_matrix"); // GLTF + mReservedUniforms.push_back("texture_emissive_matrix"); // GLTF + llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_EMISSIVE_MATRIX+1); mReservedUniforms.push_back("viewport"); -- cgit v1.2.3 From 843a5c287e34855fb7bd4882d8d0a106e987a9f7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 14 Nov 2022 11:40:18 -0600 Subject: SL-18485 Cleanup -- remove unused GLTF specific vertex attributes from LLVertexBuffer (blows past 16-attribute limit) --- indra/llrender/llshadermgr.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e8cf7ec758..ac4c610d72 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1163,10 +1163,6 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedAttribs.push_back("weight4"); mReservedAttribs.push_back("clothing"); mReservedAttribs.push_back("texture_index"); - mReservedAttribs.push_back("basecolor_texcoord"); // GLTF - mReservedAttribs.push_back("normal_texcoord"); // GLTF - mReservedAttribs.push_back("metallic_roughness_texcoord"); // GLTF - mReservedAttribs.push_back("emissive_texcoord"); // GLTF //matrix state mReservedUniforms.push_back("modelview_matrix"); -- cgit v1.2.3 From 97277e74a9d966ed441e51f844f9012f55cca3dc Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Mon, 14 Nov 2022 18:12:22 +0000 Subject: Merged in SL-18332 (pull request #1194) First pass of Screen Space Reflections Approved-by: Dave Parks --- indra/llrender/llshadermgr.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index ac4c610d72..b189e5452c 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -222,6 +222,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } + if (features->hasScreenSpaceReflections) + { + if (!shader->attachFragmentObject("deferred/screenSpaceReflUtil.glsl")) + { + return FALSE; + } + } + if (features->hasShadows) { if (!shader->attachFragmentObject("deferred/shadowUtil.glsl")) @@ -1170,6 +1178,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("inv_proj"); mReservedUniforms.push_back("modelview_projection_matrix"); mReservedUniforms.push_back("inv_modelview"); + mReservedUniforms.push_back("identity_matrix"); mReservedUniforms.push_back("normal_matrix"); mReservedUniforms.push_back("texture_matrix0"); mReservedUniforms.push_back("texture_matrix1"); -- cgit v1.2.3 From 7bd9d21e19b923096ba2b5ea3cbc8be3e13d7aa0 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 19 Jan 2023 09:13:45 -0600 Subject: Optimizations, decruft, and intel compatibility pass (#53) SL-18869, SL-18772 Overhaul VBO management, restore occlusion culling, intel compatibility pass, etc --- indra/llrender/llshadermgr.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index b189e5452c..ee8ac359c7 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -590,6 +590,7 @@ static std::string get_shader_log(GLuint ret) static std::string get_program_log(GLuint ret) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; std::string res; //get log length @@ -1113,16 +1114,24 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev BOOL LLShaderMgr::linkProgramObject(GLuint obj, BOOL suppress_errors) { //check for errors - glLinkProgram(obj); - GLint success = GL_TRUE; - glGetProgramiv(obj, GL_LINK_STATUS, &success); - if (!suppress_errors && success == GL_FALSE) - { - //an error occured, print log - LL_SHADER_LOADING_WARNS() << "GLSL Linker Error:" << LL_ENDL; - dumpObjectLog(obj, TRUE, "linker"); - return success; - } + { + LL_PROFILE_ZONE_NAMED_CATEGORY_SHADER("glLinkProgram"); + glLinkProgram(obj); + } + + GLint success = GL_TRUE; + + { + LL_PROFILE_ZONE_NAMED_CATEGORY_SHADER("glsl check link status"); + glGetProgramiv(obj, GL_LINK_STATUS, &success); + if (!suppress_errors && success == GL_FALSE) + { + //an error occured, print log + LL_SHADER_LOADING_WARNS() << "GLSL Linker Error:" << LL_ENDL; + dumpObjectLog(obj, TRUE, "linker"); + return success; + } + } std::string log = get_program_log(obj); LLStringUtil::toLower(log); -- cgit v1.2.3 From c83e66414848e468cce01d36c1054b2e9314baf9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 Jan 2023 13:00:40 -0600 Subject: SL-18869 GL 3 compatibility pass and minor decruft. --- indra/llrender/llshadermgr.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index ee8ac359c7..44b8ea164b 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1320,9 +1320,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("depth_cutoff"); mReservedUniforms.push_back("norm_cutoff"); mReservedUniforms.push_back("shadow_target_width"); - mReservedUniforms.push_back("view_dir"); // DEFERRED_VIEW_DIR - llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_VIEW_DIR+1); + llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH+1); mReservedUniforms.push_back("tc_scale"); mReservedUniforms.push_back("rcp_screen_res"); -- cgit v1.2.3 From 623bb4d58c197fccc8a795426c5864104301cebe Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 24 Jan 2023 14:17:36 -0600 Subject: SL-18772 Potential fix for failed shader load on Intel HD 3000 --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 44b8ea164b..6001b011ee 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -262,7 +262,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasGamma) + if (features->hasGamma || features->isDeferred) { if (!shader->attachFragmentObject("windlight/gammaF.glsl")) { -- cgit v1.2.3 From 3ef31cb9b28f7b026e109eab69d383dddc922850 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 27 Jan 2023 17:24:22 -0600 Subject: SL-19203 et al -- Integrate SSR with reflection probes, tweak probe blending. (#63) * SL-19203 WIP -- Integrate SSR with reflection probes. Decruft LLRenderTarget. * SL-19203 WIP -- Re-integrate SSR. Incidental decruft. * SL-19203 WIP -- SSR frame delta correction (still broken for Z) * SL-19203 WIP -- SSR frame delta Z fix * SL-19203 WIP -- Make SSR toggleable again and disable SSR in cube snapshots. * SL-19203 WIP -- Soften sphere probe transitions and fix reflections on void water (make fallback probe a simple terrain+water+sky probe). Remove parallax correction for automatic probes to reduce artifacts. * SL-19203 Tune probe blending. * SL-19203 Cleanup. --- indra/llrender/llshadermgr.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6001b011ee..27ac4053df 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -222,7 +222,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasScreenSpaceReflections) + if (features->hasScreenSpaceReflections || features->hasReflectionProbes) { if (!shader->attachFragmentObject("deferred/screenSpaceReflUtil.glsl")) { @@ -1244,6 +1244,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bumpMap"); mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); + mReservedUniforms.push_back("sceneMap"); + mReservedUniforms.push_back("sceneDepth"); mReservedUniforms.push_back("reflectionProbes"); mReservedUniforms.push_back("irradianceProbes"); mReservedUniforms.push_back("cloud_noise_texture"); @@ -1323,6 +1325,10 @@ void LLShaderMgr::initAttribsAndUniforms() llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH+1); + mReservedUniforms.push_back("modelview_delta"); + mReservedUniforms.push_back("inv_modelview_delta"); + mReservedUniforms.push_back("cube_snapshot"); + mReservedUniforms.push_back("tc_scale"); mReservedUniforms.push_back("rcp_screen_res"); mReservedUniforms.push_back("rcp_frame_opt"); -- cgit v1.2.3 From 10b8dcc497599042655dcc4037c9ae98d494bd6f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 30 Jan 2023 18:56:19 -0600 Subject: SL-19015 Bump probe resolution back to 256 by default (drop to 128 if vram < 2GB), remove irradiance map feedback loop (one bounce, but but more stable and allows for much brighter first bounce), make sky contribution to irradiance not tint the world blue. Make irradiance that appears in radiance maps match world irradiance. --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 27ac4053df..421b9ee2d6 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1431,6 +1431,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("moon_brightness"); mReservedUniforms.push_back("cloud_variance"); mReservedUniforms.push_back("reflection_probe_ambiance"); + mReservedUniforms.push_back("max_probe_lod"); mReservedUniforms.push_back("sh_input_r"); mReservedUniforms.push_back("sh_input_g"); -- cgit v1.2.3 From 4522864f0b12d252a953441bade7fa72a53554b9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 31 Jan 2023 17:05:58 -0600 Subject: SL-18772 Potential fix for failed shader load on Intel HD 3000 --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 421b9ee2d6..52509d3d29 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -278,7 +278,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasAtmospherics) + if (features->hasAtmospherics || features->isDeferred) { if (!shader->attachFragmentObject("windlight/atmosphericsFuncs.glsl")) { return FALSE; -- cgit v1.2.3 From c136c5ece4a6baf3b0a34c32211e00a3d0fc4b69 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 1 Feb 2023 16:23:44 -0600 Subject: SL-18772 Potential fix for failed shader load on Intel HD 3000 --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 52509d3d29..6e3d89eedc 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -190,7 +190,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if(features->calculatesAtmospherics) + if(features->calculatesAtmospherics || features->hasGamma || features->isDeferred) { if (features->hasWaterFog) { -- cgit v1.2.3 From 830cb6b66551025285120fb628f0b5ebf3841756 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Feb 2023 17:18:39 -0600 Subject: SL-19148 Decruft some forward shaders and drawpools. Fix HUDs being in wrong color space. --- indra/llrender/llshadermgr.cpp | 89 +----------------------------------------- 1 file changed, 1 insertion(+), 88 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6e3d89eedc..e9daf7cb75 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -296,9 +296,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { return FALSE; } - - // Test hasFullbright and hasShiny and attach fullbright and - // fullbright shiny atmos transport if we split them out. } // NOTE order of shader object attaching is VERY IMPORTANT!!! @@ -390,30 +387,11 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } } - // NOTE order of shader object attaching is VERY IMPORTANT!!! else if (features->isFullbright) { - if (features->isShiny && features->hasWaterFog) - { - if (features->disableTextureIndex) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightShinyWaterNonIndexedF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightShinyWaterF.glsl")) - { - return FALSE; - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - else if (features->hasWaterFog) + if (features->hasWaterFog) { if (features->disableTextureIndex) { @@ -445,26 +423,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); } } - - else if (features->isShiny) - { - if (features->disableTextureIndex) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightShinyNonIndexedF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightShinyF.glsl")) - { - return FALSE; - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - else { if (features->disableTextureIndex) @@ -505,50 +463,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } } - - // NOTE order of shader object attaching is VERY IMPORTANT!!! - else if (features->isShiny) - { - - if (features->hasWaterFog) - { - if (features->disableTextureIndex) - { - if (!shader->attachFragmentObject("lighting/lightShinyWaterNonIndexedF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightShinyWaterF.glsl")) - { - return FALSE; - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - - else - { - if (features->disableTextureIndex) - { - if (!shader->attachFragmentObject("lighting/lightShinyNonIndexedF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightShinyF.glsl")) - { - return FALSE; - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - } - if (features->mIndexedTextureChannels <= 1) { if (!shader->attachVertexObject("objects/nonindexedTextureV.glsl")) @@ -1422,7 +1336,6 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("single_mie_scattering_texture"); mReservedUniforms.push_back("irradiance_texture"); mReservedUniforms.push_back("blend_factor"); - mReservedUniforms.push_back("no_atmo"); mReservedUniforms.push_back("moisture_level"); mReservedUniforms.push_back("droplet_radius"); mReservedUniforms.push_back("ice_level"); -- cgit v1.2.3 From 1c2410b8af62254e96d60b2ae2e411d4756215e4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 3 Feb 2023 19:45:31 -0600 Subject: SL-19148 Decruft followthrough -- decruft shader tree and some remaining forward rendering code. --- indra/llrender/llshadermgr.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e9daf7cb75..646c9a821b 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -254,14 +254,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasIndirect) - { - if (!shader->attachFragmentObject("deferred/indirect.glsl")) - { - return FALSE; - } - } - if (features->hasGamma || features->isDeferred) { if (!shader->attachFragmentObject("windlight/gammaF.glsl")) @@ -624,7 +616,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev */ LL_DEBUGS("ShaderLoading") << "Looking in " << open_file_name << LL_ENDL; - file = LLFile::fopen(open_file_name, "r"); /* Flawfinder: ignore */ + file = LLFile::fopen(open_file_name, "r+"); /* Flawfinder: ignore */ if (file) { LL_DEBUGS("ShaderLoading") << "Loading file: " << open_file_name << " (Want class " << gpu_class << ")" << LL_ENDL; @@ -875,6 +867,13 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev GLuint out_of_extra_block_counter = 0, start_shader_code = shader_code_count, file_lines_count = 0; +#define TOUCH_SHADERS 0 + +#if TOUCH_SHADERS + const char* marker = "// touched"; + bool touched = false; +#endif + while(NULL != fgets((char *)buff, 1024, file) && shader_code_count < (LL_ARRAY_SIZE(shader_code_text) - LL_ARRAY_SIZE(extra_code_text))) { @@ -882,6 +881,13 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev bool extra_block_area_found = NULL != strstr((const char*)buff, "[EXTRA_CODE_HERE]"); +#if TOUCH_SHADERS + if (NULL != strstr((const char*)buff, marker)) + { + touched = true; + } +#endif + if(extra_block_area_found && !(flag_extra_block_marker_was_found & flags)) { if(!(flag_write_to_out_of_extra_block_area & flags)) @@ -944,6 +950,13 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev extra_code_count = 0; } +#if TOUCH_SHADERS + if (!touched) + { + fprintf(file, "\n%s\n", marker); + } +#endif + fclose(file); //create shader object -- cgit v1.2.3 From c8fb3ad4de0575a0538b9532e819319f655613d1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 6 Feb 2023 10:28:26 -0600 Subject: SL-19148 Decruft followthrough -- fix for crash when running from installer. Feed fresnel component into PBR alpha. Remove obsolete "shader_hierarchy.txt", remove redundant LL_PROFILE_ZONE_SCOPED, remove unused shader feature flag. --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 646c9a821b..16f2769411 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -616,7 +616,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev */ LL_DEBUGS("ShaderLoading") << "Looking in " << open_file_name << LL_ENDL; - file = LLFile::fopen(open_file_name, "r+"); /* Flawfinder: ignore */ + file = LLFile::fopen(open_file_name, "r"); /* Flawfinder: ignore */ if (file) { LL_DEBUGS("ShaderLoading") << "Loading file: " << open_file_name << " (Want class " << gpu_class << ")" << LL_ENDL; -- cgit v1.2.3 From b52699091da791a1349daf66d405f27ca2568ea9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Feb 2023 11:40:56 -0600 Subject: SL-19147 Water quality pass. Remove gl_FragDepth writes from sky rendering (optimization). Incidental decruft. --- indra/llrender/llshadermgr.cpp | 74 +++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 26 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 16f2769411..54dbb0d025 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -28,6 +28,7 @@ #include "llshadermgr.h" #include "llrender.h" #include "llfile.h" +#include "lldir.h" #if LL_DARWIN #include "OpenGL/OpenGL.h" @@ -593,36 +594,57 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev S32 gpu_class; std::string open_file_name; - //find the most relevant file - for (gpu_class = try_gpu_class; gpu_class > 0; gpu_class--) - { //search from the current gpu class down to class 1 to find the most relevant shader - std::stringstream fname; - fname << getShaderDirPrefix(); - fname << gpu_class << "/" << filename; - - open_file_name = fname.str(); - - /* - Would be awesome, if we didn't have shaders that re-use files - with different environments to say, add skinning, etc - can't depend on cached version to have evaluate ifdefs identically... - if we can define a deterministic hash for the shader based on - all the inputs, maybe we can save some time here. - if (mShaderObjects.count(filename) > 0) + +#if 0 // WIP -- try to come up with a way to fallback to an error shader without needing debug stubs all over the place in the shader tree + if (shader_level == -1) + { + // use "error" fallback + if (type == GL_VERTEX_SHADER) + { + open_file_name = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "shaders/errorV.glsl"); + } + else { - return mShaderObjects[filename]; + llassert(type == GL_FRAGMENT_SHADER); // type must be vertex or fragment shader + open_file_name = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "shaders/errorF.glsl"); } - */ + file = LLFile::fopen(open_file_name, "r"); + } + else +#endif + { + //find the most relevant file + for (gpu_class = try_gpu_class; gpu_class > 0; gpu_class--) + { //search from the current gpu class down to class 1 to find the most relevant shader + std::stringstream fname; + fname << getShaderDirPrefix(); + fname << gpu_class << "/" << filename; + + open_file_name = fname.str(); + + /* + Would be awesome, if we didn't have shaders that re-use files + with different environments to say, add skinning, etc + can't depend on cached version to have evaluate ifdefs identically... + if we can define a deterministic hash for the shader based on + all the inputs, maybe we can save some time here. + if (mShaderObjects.count(filename) > 0) + { + return mShaderObjects[filename]; + } + + */ - LL_DEBUGS("ShaderLoading") << "Looking in " << open_file_name << LL_ENDL; - file = LLFile::fopen(open_file_name, "r"); /* Flawfinder: ignore */ - if (file) - { - LL_DEBUGS("ShaderLoading") << "Loading file: " << open_file_name << " (Want class " << gpu_class << ")" << LL_ENDL; - break; // done - } - } + LL_DEBUGS("ShaderLoading") << "Looking in " << open_file_name << LL_ENDL; + file = LLFile::fopen(open_file_name, "r"); /* Flawfinder: ignore */ + if (file) + { + LL_DEBUGS("ShaderLoading") << "Loading file: " << open_file_name << " (Want class " << gpu_class << ")" << LL_ENDL; + break; // done + } + } + } if (file == NULL) { -- cgit v1.2.3 From a2647e953aeee26ef99e62e0146adcd37c8afca1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Feb 2023 18:25:22 -0600 Subject: SL-18229 Fix for PBR materials on HUDs misbehaving. Incidental decruft. --- indra/llrender/llshadermgr.cpp | 75 ------------------------------------------ 1 file changed, 75 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 54dbb0d025..7a7c5beb38 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -380,82 +380,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } } - // NOTE order of shader object attaching is VERY IMPORTANT!!! - else if (features->isFullbright) - { - if (features->hasWaterFog) - { - if (features->disableTextureIndex) - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl")) - { - return FALSE; - } - } - else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedF.glsl")) - { - return FALSE; - } - } - else - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightWaterAlphaMaskF.glsl")) - { - return FALSE; - } - } - else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterF.glsl")) - { - return FALSE; - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - else - { - if (features->disableTextureIndex) - { - - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedAlphaMaskF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedF.glsl")) - { - return FALSE; - } - } - } - else - { - if (features->hasAlphaMask) - { - if (!shader->attachFragmentObject("lighting/lightFullbrightAlphaMaskF.glsl")) - { - return FALSE; - } - } - else - { - if (!shader->attachFragmentObject("lighting/lightFullbrightF.glsl")) - { - return FALSE; - } - } - shader->mFeatures.mIndexedTextureChannels = llmax(LLGLSLShader::sIndexedTextureChannels-1, 1); - } - } - } if (features->mIndexedTextureChannels <= 1) { if (!shader->attachVertexObject("objects/nonindexedTextureV.glsl")) -- cgit v1.2.3 From 68c4ff7dce2bd519431238f6209238aba46dc0ba Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 14 Feb 2023 10:10:12 -0600 Subject: SL-18762 Fix for broken local lights on alpha when wearing a HUD attachment. Also fix stuck sun/moon and incidental decruft. --- indra/llrender/llshadermgr.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 7a7c5beb38..6cada320fa 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -679,7 +679,6 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev extra_code_text[extra_code_count++] = strdup("#define texture2D texture\n"); extra_code_text[extra_code_count++] = strdup("#define textureCube texture\n"); extra_code_text[extra_code_count++] = strdup("#define texture2DLod textureLod\n"); - extra_code_text[extra_code_count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n"); if (major_version > 1 || minor_version >= 40) { //GLSL 1.40 replaces texture2DRect et al with texture -- cgit v1.2.3 From 6494eed242b1cf64160e379c6d40df333deae23a Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 23 Feb 2023 10:58:39 -0800 Subject: SL-19228: Fix GLTF texture transform rotation and add UV debug (PBR only). See textureUtilV.glsl for UV coordinate comments --- indra/llrender/llshadermgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6cada320fa..13074032e0 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -177,6 +177,11 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) return FALSE; } } + + if (!shader->attachVertexObject("deferred/textureUtilV.glsl")) + { + return FALSE; + } /////////////////////////////////////// // Attach Fragment Shader Features Next -- cgit v1.2.3 From 33085b9d830ac1db280d678760b3972798aa1129 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 24 Feb 2023 13:53:55 -0800 Subject: SL-19265: Fix precision issue with texture transforms by moving transform matrix calculation into the shader --- indra/llrender/llshadermgr.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 13074032e0..c355115e8c 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1073,11 +1073,21 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("texture_matrix3"); mReservedUniforms.push_back("object_plane_s"); mReservedUniforms.push_back("object_plane_t"); - mReservedUniforms.push_back("texture_basecolor_matrix"); // GLTF - mReservedUniforms.push_back("texture_normal_matrix"); // GLTF - mReservedUniforms.push_back("texture_metallic_roughness_matrix"); // GLTF - mReservedUniforms.push_back("texture_emissive_matrix"); // GLTF - llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_EMISSIVE_MATRIX+1); + + mReservedUniforms.push_back("texture_base_color_scale"); // (GLTF) + mReservedUniforms.push_back("texture_base_color_rotation"); // (GLTF) + mReservedUniforms.push_back("texture_base_color_offset"); // (GLTF) + mReservedUniforms.push_back("texture_normal_scale"); // (GLTF) + mReservedUniforms.push_back("texture_normal_rotation"); // (GLTF) + mReservedUniforms.push_back("texture_normal_offset"); // (GLTF) + mReservedUniforms.push_back("texture_metallic_roughness_scale"); // (GLTF) + mReservedUniforms.push_back("texture_metallic_roughness_rotation"); // (GLTF) + mReservedUniforms.push_back("texture_metallic_roughness_offset"); // (GLTF) + mReservedUniforms.push_back("texture_emissive_scale"); // (GLTF) + mReservedUniforms.push_back("texture_emissive_rotation"); // (GLTF) + mReservedUniforms.push_back("texture_emissive_offset"); // (GLTF) + + llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_EMISSIVE_OFFSET+1); mReservedUniforms.push_back("viewport"); -- cgit v1.2.3 From b27c41578b4bb54ee87fbb8d05f29d9d9a9e2768 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 27 Feb 2023 15:57:45 -0800 Subject: SL-19279: LLGLSLShader::bindXXX is not free. Pack the uniforms --- indra/llrender/llshadermgr.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index c355115e8c..6fb319fd5b 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1074,20 +1074,12 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("object_plane_s"); mReservedUniforms.push_back("object_plane_t"); - mReservedUniforms.push_back("texture_base_color_scale"); // (GLTF) - mReservedUniforms.push_back("texture_base_color_rotation"); // (GLTF) - mReservedUniforms.push_back("texture_base_color_offset"); // (GLTF) - mReservedUniforms.push_back("texture_normal_scale"); // (GLTF) - mReservedUniforms.push_back("texture_normal_rotation"); // (GLTF) - mReservedUniforms.push_back("texture_normal_offset"); // (GLTF) - mReservedUniforms.push_back("texture_metallic_roughness_scale"); // (GLTF) - mReservedUniforms.push_back("texture_metallic_roughness_rotation"); // (GLTF) - mReservedUniforms.push_back("texture_metallic_roughness_offset"); // (GLTF) - mReservedUniforms.push_back("texture_emissive_scale"); // (GLTF) - mReservedUniforms.push_back("texture_emissive_rotation"); // (GLTF) - mReservedUniforms.push_back("texture_emissive_offset"); // (GLTF) - - llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_EMISSIVE_OFFSET+1); + mReservedUniforms.push_back("texture_base_color_transform"); // (GLTF) + mReservedUniforms.push_back("texture_normal_transform"); // (GLTF) + mReservedUniforms.push_back("texture_metallic_roughness_transform"); // (GLTF) + mReservedUniforms.push_back("texture_emissive_transform"); // (GLTF) + + llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_EMISSIVE_TRANSFORM+1); mReservedUniforms.push_back("viewport"); -- cgit v1.2.3 From 922746da752d30df1b292c0498f2a4543f93620f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Mar 2023 17:22:26 -0600 Subject: DRTVWR-559 Nudge Intel HD 3000 shader compilation failure --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6fb319fd5b..08a2e6779e 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -188,7 +188,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) /////////////////////////////////////// // NOTE order of shader object attaching is VERY IMPORTANT!!! - if (features->hasSrgb || features->hasAtmospherics || features->calculatesAtmospherics) + if (features->hasSrgb || features->hasAtmospherics || features->calculatesAtmospherics || features->isDeferred) { if (!shader->attachFragmentObject("environment/srgbF.glsl")) { -- cgit v1.2.3 From 10f66c05190585e9de2e85831712323c297d81c4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Mar 2023 14:30:59 -0500 Subject: DRTVWR-559 Dynamically adjust exposure. --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 08a2e6779e..016cbe6e75 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1238,6 +1238,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("diffuseRect"); mReservedUniforms.push_back("specularRect"); mReservedUniforms.push_back("emissiveRect"); + mReservedUniforms.push_back("exposureMap"); mReservedUniforms.push_back("brdfLut"); mReservedUniforms.push_back("noiseMap"); mReservedUniforms.push_back("lightFunc"); -- cgit v1.2.3 From 698966f8e7ddcc0b123a83d7c4e381778f8cd8ab Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 4 Apr 2023 12:29:12 -0500 Subject: =?UTF-8?q?SL-19538=20Remove=20hacky=20ambiance=20scale=20and=20ta?= =?UTF-8?q?ke=20the=20mittens=20off=20probe=20a=E2=80=A6=20(#151)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * SL-19538 Remove hacky ambiance scale and take the mittens off probe ambiance values. Fix for sky brightening being done in sRGB space. --- indra/llrender/llshadermgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 016cbe6e75..e1679c7f52 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -276,7 +276,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasAtmospherics || features->isDeferred) + if (features->hasAtmospherics || features->isDeferred || features->hasTransport) { if (!shader->attachFragmentObject("windlight/atmosphericsFuncs.glsl")) { return FALSE; -- cgit v1.2.3 From 339e02ef3311ad5c1197dfca2955a0c202b7c408 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Thu, 11 May 2023 21:19:58 -0700 Subject: Finally get glossy SSR up. DRTVWR-583 --- indra/llrender/llshadermgr.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e1679c7f52..614ddc0c62 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1203,7 +1203,14 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("norm_cutoff"); mReservedUniforms.push_back("shadow_target_width"); - llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH+1); + llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH + 1); + + mReservedUniforms.push_back("iterationCount"); + mReservedUniforms.push_back("rayStep"); + mReservedUniforms.push_back("distanceBias"); + mReservedUniforms.push_back("depthRejectBias"); + mReservedUniforms.push_back("glossySampleCount"); + mReservedUniforms.push_back("noiseSine"); mReservedUniforms.push_back("modelview_delta"); mReservedUniforms.push_back("inv_modelview_delta"); -- cgit v1.2.3 From cdc9852f052d804f8b25564ab7d90eb2b79cddd4 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 15 May 2023 11:01:24 -0500 Subject: SL-19709 Fix for fullbright shiny not factoring out exposure and flickering fullbright alpha. Incidental decruft. --- indra/llrender/llshadermgr.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e1679c7f52..e5211d9548 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -276,7 +276,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasAtmospherics || features->isDeferred || features->hasTransport) + if (features->hasAtmospherics || features->isDeferred) { if (!shader->attachFragmentObject("windlight/atmosphericsFuncs.glsl")) { return FALSE; @@ -288,14 +288,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasTransport) - { - if (!shader->attachFragmentObject("windlight/transportF.glsl")) - { - return FALSE; - } - } - // NOTE order of shader object attaching is VERY IMPORTANT!!! if (features->hasWaterFog) { -- cgit v1.2.3 From c827d32ebedeaa46ed75a91ae779f6547fc0d090 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 17 May 2023 18:09:36 -0500 Subject: SL-19655 Decruft legacy GLSL shaders and now unused build queues. --- indra/llrender/llshadermgr.cpp | 61 +++++------------------------------------- 1 file changed, 6 insertions(+), 55 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index e5211d9548..3a3a7679ce 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -588,30 +588,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev if (major_version == 1 && minor_version < 30) { - if (minor_version < 10) - { - //should NEVER get here -- if major version is 1 and minor version is less than 10, - // viewer should never attempt to use shaders, continuing will result in undefined behavior - LL_ERRS() << "Unsupported GLSL Version." << LL_ENDL; - } - - if (minor_version <= 19) - { - shader_code_text[shader_code_count++] = strdup("#version 110\n"); - extra_code_text[extra_code_count++] = strdup("#define ATTRIBUTE attribute\n"); - extra_code_text[extra_code_count++] = strdup("#define VARYING varying\n"); - extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT varying\n"); - } - else if (minor_version <= 29) - { - //set version to 1.20 - shader_code_text[shader_code_count++] = strdup("#version 120\n"); - extra_code_text[extra_code_count++] = strdup("#define FXAA_GLSL_120 1\n"); - extra_code_text[extra_code_count++] = strdup("#define FXAA_FAST_PIXEL_OFFSET 0\n"); - extra_code_text[extra_code_count++] = strdup("#define ATTRIBUTE attribute\n"); - extra_code_text[extra_code_count++] = strdup("#define VARYING varying\n"); - extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT varying\n"); - } + llassert(false); // GL 3.1 or later required } else { @@ -648,40 +625,14 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev } else { - //set version to 1.30 - shader_code_text[shader_code_count++] = strdup("#version 130\n"); + //set version to 1.40 + shader_code_text[shader_code_count++] = strdup("#version 140\n"); //some implementations of GLSL 1.30 require integer precision be explicitly declared extra_code_text[extra_code_count++] = strdup("precision mediump int;\n"); extra_code_text[extra_code_count++] = strdup("precision highp float;\n"); } - extra_code_text[extra_code_count++] = strdup("#define DEFINE_GL_FRAGCOLOR 1\n"); extra_code_text[extra_code_count++] = strdup("#define FXAA_GLSL_130 1\n"); - - extra_code_text[extra_code_count++] = strdup("#define ATTRIBUTE in\n"); - - if (type == GL_VERTEX_SHADER) - { //"varying" state is "out" in a vertex program, "in" in a fragment program - // ("varying" is deprecated after version 1.20) - extra_code_text[extra_code_count++] = strdup("#define VARYING out\n"); - extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT flat out\n"); - } - else - { - extra_code_text[extra_code_count++] = strdup("#define VARYING in\n"); - extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT flat in\n"); - } - - //backwards compatibility with legacy texture lookup syntax - extra_code_text[extra_code_count++] = strdup("#define texture2D texture\n"); - extra_code_text[extra_code_count++] = strdup("#define textureCube texture\n"); - extra_code_text[extra_code_count++] = strdup("#define texture2DLod textureLod\n"); - - if (major_version > 1 || minor_version >= 40) - { //GLSL 1.40 replaces texture2DRect et al with texture - extra_code_text[extra_code_count++] = strdup("#define texture2DRect texture\n"); - extra_code_text[extra_code_count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n"); - } } // Use alpha float to store bit flags @@ -719,13 +670,13 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev . uniform sampler2D texN; - VARYING_FLAT ivec4 vary_texture_index; + flat in int vary_texture_index; vec4 ret = vec4(1,0,1,1); vec4 diffuseLookup(vec2 texcoord) { - switch (vary_texture_index.r)) + switch (vary_texture_index) { case 0: ret = texture2D(tex0, texcoord); break; case 1: ret = texture2D(tex1, texcoord); break; @@ -751,7 +702,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev if (texture_index_channels > 1) { - extra_code_text[extra_code_count++] = strdup("VARYING_FLAT int vary_texture_index;\n"); + extra_code_text[extra_code_count++] = strdup("flat in int vary_texture_index;\n"); } extra_code_text[extra_code_count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n"); -- cgit v1.2.3 From 446d0cbf7f19e459b90a06f4153b3f7f9df6f09a Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 17 May 2023 18:28:01 -0500 Subject: SL-19655 Clean up some missed "texture2D" vs "texture" (thanks Rye) --- indra/llrender/llshadermgr.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 3a3a7679ce..d382fa7f71 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -678,13 +678,13 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev { switch (vary_texture_index) { - case 0: ret = texture2D(tex0, texcoord); break; - case 1: ret = texture2D(tex1, texcoord); break; - case 2: ret = texture2D(tex2, texcoord); break; + case 0: ret = texture(tex0, texcoord); break; + case 1: ret = texture(tex1, texcoord); break; + case 2: ret = texture(tex2, texcoord); break; . . . - case N: return texture2D(texN, texcoord); break; + case N: return texture(texN, texcoord); break; } return ret; @@ -711,7 +711,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev if (texture_index_channels == 1) { //don't use flow control, that's silly - extra_code_text[extra_code_count++] = strdup("return texture2D(tex0, texcoord);\n"); + extra_code_text[extra_code_count++] = strdup("return texture(tex0, texcoord);\n"); extra_code_text[extra_code_count++] = strdup("}\n"); } else if (major_version > 1 || minor_version >= 30) @@ -720,7 +720,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev { //switches are unreliable on some NVIDIA drivers for (U32 i = 0; i < texture_index_channels; ++i) { - std::string if_string = llformat("\t%sif (vary_texture_index == %d) { return texture2D(tex%d, texcoord); }\n", i > 0 ? "else " : "", i, i); + std::string if_string = llformat("\t%sif (vary_texture_index == %d) { return texture(tex%d, texcoord); }\n", i > 0 ? "else " : "", i, i); extra_code_text[extra_code_count++] = strdup(if_string.c_str()); } extra_code_text[extra_code_count++] = strdup("\treturn vec4(1,0,1,1);\n"); @@ -735,7 +735,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev //switch body for (S32 i = 0; i < texture_index_channels; ++i) { - std::string case_str = llformat("\t\tcase %d: return texture2D(tex%d, texcoord);\n", i, i); + std::string case_str = llformat("\t\tcase %d: return texture(tex%d, texcoord);\n", i, i); extra_code_text[extra_code_count++] = strdup(case_str.c_str()); } -- cgit v1.2.3 From 87bda552688bb38fe255cc7e6069c1be6ac20834 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Wed, 17 May 2023 19:30:27 -0400 Subject: Add a binary cache for compiled shaders using glProgramBinary (#216) * Add a binary cache for compiled shaders using glProgramBinary * Add additional sanity checking to shader binary save and load, hook up cache clear and menu option * Fix default init of shader cache data struct and clear gl errors before glGetError calls --------- Co-authored-by: RunitaiLinden --- indra/llrender/llshadermgr.cpp | 213 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 201 insertions(+), 12 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index d382fa7f71..7d0c99c9e3 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -29,6 +29,9 @@ #include "llrender.h" #include "llfile.h" #include "lldir.h" +#include "llsdutil.h" +#include "llsdserialize.h" +#include "hbxxh.h" #if LL_DARWIN #include "OpenGL/OpenGL.h" @@ -484,7 +487,7 @@ void LLShaderMgr::dumpObjectLog(GLuint ret, BOOL warns, const std::string& filen } } -GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::unordered_map* defines, S32 texture_index_channels) +GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::map* defines, S32 texture_index_channels) { // endsure work-around for missing GLSL funcs gets propogated to feature shader files (e.g. srgbF.glsl) @@ -644,7 +647,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev if (defines) { - for (std::unordered_map::iterator iter = defines->begin(); iter != defines->end(); ++iter) + for (auto iter = defines->begin(); iter != defines->end(); ++iter) { std::string define = "#define " + iter->first + " " + iter->second + "\n"; extra_code_text[extra_code_count++] = (GLchar *) strdup(define.c_str()); @@ -860,24 +863,39 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev if (error != GL_NO_ERROR) { LL_WARNS("ShaderLoading") << "GL ERROR in glCreateShader: " << error << " for file: " << open_file_name << LL_ENDL; + if (ret) + { + glDeleteShader(ret); //no longer need handle + ret = 0; + } } //load source - glShaderSource(ret, shader_code_count, (const GLchar**) shader_code_text, NULL); - - error = glGetError(); - if (error != GL_NO_ERROR) + if (ret) { - LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSource: " << error << " for file: " << open_file_name << LL_ENDL; + glShaderSource(ret, shader_code_count, (const GLchar**)shader_code_text, NULL); + + error = glGetError(); + if (error != GL_NO_ERROR) + { + LL_WARNS("ShaderLoading") << "GL ERROR in glShaderSource: " << error << " for file: " << open_file_name << LL_ENDL; + glDeleteShader(ret); //no longer need handle + ret = 0; + } } //compile source - glCompileShader(ret); - - error = glGetError(); - if (error != GL_NO_ERROR) + if (ret) { - LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShader: " << error << " for file: " << open_file_name << LL_ENDL; + glCompileShader(ret); + + error = glGetError(); + if (error != GL_NO_ERROR) + { + LL_WARNS("ShaderLoading") << "GL ERROR in glCompileShader: " << error << " for file: " << open_file_name << LL_ENDL; + glDeleteShader(ret); //no longer need handle + ret = 0; + } } if (error == GL_NO_ERROR) @@ -893,6 +911,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev LL_WARNS("ShaderLoading") << "GLSL Compilation Error:" << LL_ENDL; dumpObjectLog(ret, TRUE, open_file_name); dumpShaderSource(shader_code_count, shader_code_text); + glDeleteShader(ret); //no longer need handle ret = 0; } } @@ -984,6 +1003,176 @@ BOOL LLShaderMgr::validateProgramObject(GLuint obj) return success; } +void LLShaderMgr::initShaderCache(bool enabled, const LLUUID& old_cache_version, const LLUUID& current_cache_version) +{ + LL_INFOS() << "Initializing shader cache" << LL_ENDL; + + mShaderCacheEnabled = gGLManager.mGLVersion >= 4.09 && enabled; + + if(!mShaderCacheEnabled || mShaderCacheInitialized) + return; + + mShaderCacheInitialized = true; + + mShaderCacheDir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "shader_cache"); + LLFile::mkdir(mShaderCacheDir); + + { + std::string meta_out_path = gDirUtilp->add(mShaderCacheDir, "shaderdata.llsd"); + if (gDirUtilp->fileExists(meta_out_path)) + { + LL_INFOS() << "Loading shader cache metadata" << LL_ENDL; + + llifstream instream(meta_out_path); + LLSD in_data; + LLSDSerialize::fromNotation(in_data, instream, LLSDSerialize::SIZE_UNLIMITED); + instream.close(); + + if (old_cache_version == current_cache_version) + { + for (const auto& data_pair : llsd::inMap(in_data)) + { + ProgramBinaryData binary_info = ProgramBinaryData(); + binary_info.mBinaryFormat = data_pair.second["binary_format"].asInteger(); + binary_info.mBinaryLength = data_pair.second["binary_size"].asInteger(); + binary_info.mLastUsedTime = data_pair.second["last_used"].asReal(); + mShaderBinaryCache.insert_or_assign(LLUUID(data_pair.first), binary_info); + } + } + else + { + LL_INFOS() << "Shader cache version mismatch detected. Purging." << LL_ENDL; + clearShaderCache(); + } + } + } +} + +void LLShaderMgr::clearShaderCache() +{ + std::string shader_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "shader_cache"); + LL_INFOS() << "Removing shader cache at " << shader_cache << LL_ENDL; + const std::string mask = "*"; + gDirUtilp->deleteFilesInDir(shader_cache, mask); + mShaderBinaryCache.clear(); +} + +void LLShaderMgr::persistShaderCacheMetadata() +{ + if(!mShaderCacheEnabled) return; + + LL_INFOS() << "Persisting shader cache metadata to disk" << LL_ENDL; + + LLSD out = LLSD::emptyMap(); + + static const F32 LRU_TIME = (60.f * 60.f) * 24.f * 7.f; // 14 days + const F32 current_time = LLTimer::getTotalSeconds(); + for (auto it = mShaderBinaryCache.begin(); it != mShaderBinaryCache.end();) + { + const ProgramBinaryData& shader_metadata = it->second; + if ((shader_metadata.mLastUsedTime + LRU_TIME) < current_time) + { + std::string shader_path = gDirUtilp->add(mShaderCacheDir, it->first.asString() + ".shaderbin"); + LLFile::remove(shader_path); + it = mShaderBinaryCache.erase(it); + } + else + { + LLSD data = LLSD::emptyMap(); + data["binary_format"] = LLSD::Integer(shader_metadata.mBinaryFormat); + data["binary_size"] = LLSD::Integer(shader_metadata.mBinaryLength); + data["last_used"] = LLSD::Real(shader_metadata.mLastUsedTime); + out[it->first.asString()] = data; + ++it; + } + } + + std::string meta_out_path = gDirUtilp->add(mShaderCacheDir, "shaderdata.llsd"); + llofstream outstream(meta_out_path); + LLSDSerialize::toNotation(out, outstream); + outstream.close(); +} + +bool LLShaderMgr::loadCachedProgramBinary(LLGLSLShader* shader) +{ + if (!mShaderCacheEnabled) return false; + + glProgramParameteri(shader->mProgramObject, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE); + + auto binary_iter = mShaderBinaryCache.find(shader->mShaderHash); + if (binary_iter != mShaderBinaryCache.end()) + { + std::string in_path = gDirUtilp->add(mShaderCacheDir, shader->mShaderHash.asString() + ".shaderbin"); + auto& shader_info = binary_iter->second; + if (shader_info.mBinaryLength > 0) + { + std::vector in_data; + in_data.resize(shader_info.mBinaryLength); + + LLUniqueFile filep = LLFile::fopen(in_path, "rb"); + if (filep) + { + size_t result = fread(in_data.data(), sizeof(U8), in_data.size(), filep); + filep.close(); + + if (result == in_data.size()) + { + GLenum error = glGetError(); // Clear current error + glProgramBinary(shader->mProgramObject, shader_info.mBinaryFormat, in_data.data(), shader_info.mBinaryLength); + + error = glGetError(); + GLint success = GL_TRUE; + glGetProgramiv(shader->mProgramObject, GL_LINK_STATUS, &success); + if (error == GL_NO_ERROR && success == GL_TRUE) + { + binary_iter->second.mLastUsedTime = LLTimer::getTotalSeconds(); + LL_INFOS() << "Loaded cached binary for shader: " << shader->mName << LL_ENDL; + return true; + } + } + } + } + //an error occured, normally we would print log but in this case it means the shader needs recompiling. + LL_INFOS() << "Failed to load cached binary for shader: " << shader->mName << " falling back to compilation" << LL_ENDL; + LLFile::remove(in_path); + mShaderBinaryCache.erase(binary_iter); + } + return false; +} + +bool LLShaderMgr::saveCachedProgramBinary(LLGLSLShader* shader) +{ + if (!mShaderCacheEnabled) return true; + + ProgramBinaryData binary_info = ProgramBinaryData(); + glGetProgramiv(shader->mProgramObject, GL_PROGRAM_BINARY_LENGTH, &binary_info.mBinaryLength); + if (binary_info.mBinaryLength > 0) + { + std::vector program_binary; + program_binary.resize(binary_info.mBinaryLength); + + GLenum error = glGetError(); // Clear current error + glGetProgramBinary(shader->mProgramObject, program_binary.size() * sizeof(U8), nullptr, &binary_info.mBinaryFormat, program_binary.data()); + error = glGetError(); + if (error == GL_NO_ERROR) + { + std::string out_path = gDirUtilp->add(mShaderCacheDir, shader->mShaderHash.asString() + ".shaderbin"); + LLUniqueFile outfile = LLFile::fopen(out_path, "wb"); + if (outfile) + { + fwrite(program_binary.data(), sizeof(U8), program_binary.size(), outfile); + outfile.close(); + + binary_info.mLastUsedTime = LLTimer::getTotalSeconds(); + + mShaderBinaryCache.insert_or_assign(shader->mShaderHash, binary_info); + return true; + } + } + } + return false; +} + //virtual void LLShaderMgr::initAttribsAndUniforms() { -- cgit v1.2.3 From 47e311d6e8b9996de3e0a1ac75c13724ce7735aa Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Fri, 26 May 2023 16:56:33 -0700 Subject: Addressing some performance related feedback with SSR getting drastically slower. DRTVWR-559 DRTVWR-583 --- indra/llrender/llshadermgr.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 01bad3a684..1458b98bf5 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1343,6 +1343,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("depthRejectBias"); mReservedUniforms.push_back("glossySampleCount"); mReservedUniforms.push_back("noiseSine"); + mReservedUniforms.push_back("adaptiveStepMultiplier"); mReservedUniforms.push_back("modelview_delta"); mReservedUniforms.push_back("inv_modelview_delta"); -- cgit v1.2.3 From 50ec54831de88926ca13c9a72d89006ceda6c355 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 1 Jun 2023 19:49:23 -0500 Subject: DRTVWR-559 Revert skies to be very close to release and disable tone mapping when probe ambiance is zero. Hack for desaturating legacy materials has been removed for performance and quality reasons. Adds a new setting for auto adjusting legacy skies. This is the PBR "opt out" button. If disabled, legacy skies will disable tonemapping, automatic probe ambiance, and HDR/exposure. If enabled, legacy skies will behave as if probe ambiance and HDR scale are 1.0, and ambient will be cut in half. HDR scale will act as a sky brightener, but will automatically adjust dynamic exposure so the sky will be properly exposed. If you want relatively even exposure all the time, set HDR Scale to 1.0. If you want a high range of exposures between indoor/dark areas and outdoor/bright areas, increase HDR Scale. Also tuned up SSAO (thanks Rye!). Reviewed with Brad. --- indra/llrender/llshadermgr.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 01bad3a684..f398526b41 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1266,13 +1266,11 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("lightnorm"); mReservedUniforms.push_back("sunlight_color"); mReservedUniforms.push_back("ambient_color"); + mReservedUniforms.push_back("sky_hdr_scale"); mReservedUniforms.push_back("blue_horizon"); - mReservedUniforms.push_back("blue_horizon_linear"); - mReservedUniforms.push_back("blue_density"); - mReservedUniforms.push_back("blue_density_linear"); - mReservedUniforms.push_back("haze_horizon"); + mReservedUniforms.push_back("blue_density"); + mReservedUniforms.push_back("haze_horizon"); mReservedUniforms.push_back("haze_density"); - mReservedUniforms.push_back("haze_density_linear"); mReservedUniforms.push_back("cloud_shadow"); mReservedUniforms.push_back("density_multiplier"); mReservedUniforms.push_back("distance_multiplier"); @@ -1460,9 +1458,6 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("water_edge"); mReservedUniforms.push_back("sun_up_factor"); mReservedUniforms.push_back("moonlight_color"); - mReservedUniforms.push_back("moonlight_linear"); - mReservedUniforms.push_back("sunlight_linear"); - mReservedUniforms.push_back("ambient_linear"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); -- cgit v1.2.3 From 66283201301b0e55336f4b20407fed811acdc739 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 11 Jul 2023 09:51:14 -0700 Subject: SL-19567: Add option RenderGlowNoise for low precision glow dithering, enabled by default --- indra/llrender/llshadermgr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 75d6ef6c46..22940dc703 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1300,8 +1300,9 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("warmthAmount"); mReservedUniforms.push_back("glowStrength"); mReservedUniforms.push_back("glowDelta"); + mReservedUniforms.push_back("glowNoiseMap"); - llassert(mReservedUniforms.size() == LLShaderMgr::GLOW_DELTA+1); + llassert(mReservedUniforms.size() == LLShaderMgr::GLOW_NOISE_MAP+1); mReservedUniforms.push_back("minimum_alpha"); -- cgit v1.2.3 From 894c9e0417e7b29aaf31c673ca040dff93eb36ef Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Tue, 22 Aug 2023 13:17:58 -0500 Subject: SL-19842 WIP -- Move sky auto adjustment magic numbers to debug settings. --- indra/llrender/llshadermgr.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llrender/llshadermgr.cpp') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 22940dc703..0e7f9e1331 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1267,6 +1267,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("sunlight_color"); mReservedUniforms.push_back("ambient_color"); mReservedUniforms.push_back("sky_hdr_scale"); + mReservedUniforms.push_back("sky_sunlight_scale"); + mReservedUniforms.push_back("sky_ambient_scale"); mReservedUniforms.push_back("blue_horizon"); mReservedUniforms.push_back("blue_density"); mReservedUniforms.push_back("haze_horizon"); -- cgit v1.2.3