diff --git a/src/engine/renderer/Material.cpp b/src/engine/renderer/Material.cpp index 89f3c7a210..c0755de02a 100644 --- a/src/engine/renderer/Material.cpp +++ b/src/engine/renderer/Material.cpp @@ -828,12 +828,12 @@ void BindShaderLightMapping( Material* material ) { // bind u_LightGrid1 if ( material->enableGridLighting ) { - gl_lightMappingShaderMaterial->SetUniform_LightGrid1Bindless( GL_BindToTMU( BIND_LIGHTMAP, tr.lightGrid1Image ) ); + gl_lightMappingShaderMaterial->SetUniform_LightGrid1Bindless( GL_BindToTMU( BIND_LIGHTGRID1, tr.lightGrid1Image ) ); } // bind u_LightGrid2 if ( material->enableGridDeluxeMapping ) { - gl_lightMappingShaderMaterial->SetUniform_LightGrid2Bindless( GL_BindToTMU( BIND_DELUXEMAP, tr.lightGrid2Image ) ); + gl_lightMappingShaderMaterial->SetUniform_LightGrid2Bindless( GL_BindToTMU( BIND_LIGHTGRID2, tr.lightGrid2Image ) ); } if ( glConfig2.realtimeLighting ) { @@ -1729,17 +1729,7 @@ void MaterialSystem::Free() { texData.clear(); dynamicTexData.clear(); - R_SyncRenderThread(); - - surfaceCommandsSSBO.UnmapBuffer(); - culledCommandsBuffer.UnmapBuffer(); - atomicCommandCountersBuffer.UnmapBuffer(); - texDataBuffer.UnmapBuffer(); - lightMapDataUBO.UnmapBuffer(); - if ( totalPortals > 0 ) { - portalSurfacesSSBO.UnmapBuffer(); - for ( PortalView& portalView : portalStack ) { memset( portalView.views, 0, MAX_VIEWS * sizeof( uint32_t ) ); portalView.count = 0; diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index b8d3efca39..bbc09fb189 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -1514,22 +1514,75 @@ void GLShaderManager::SaveShaderBinary( ShaderProgramDescriptor* descriptor ) { cacheSaveCount++; } +std::string GLShaderManager::RemoveUniformsFromShaderText( const std::string& shaderText, const std::vector& uniforms ) { + std::istringstream shaderTextStream( shaderText ); + std::string shaderMain; + + std::string line; + /* Remove local uniform declarations, but avoid removing uniform / storage blocks; + * their values will be sourced from a buffer instead + * Global uniforms (like u_ViewOrigin) will still be set as regular uniforms */ + while ( std::getline( shaderTextStream, line, '\n' ) ) { + bool skip = false; + if ( line.find( "uniform" ) < line.find( "//" ) && line.find( ";" ) != std::string::npos ) { + for ( GLUniform* uniform : uniforms ) { + const size_t pos = line.find( uniform->_name ); + if ( pos != std::string::npos && !Str::cisalpha( line[pos + uniform->_name.size()] ) ) { + skip = true; + break; + } + } + } + + if ( skip ) { + continue; + } + + shaderMain += line + "\n"; + } + + return shaderMain; +} + +void GLShaderManager::GenerateUniformStructDefinesText( const std::vector& uniforms, const uint32_t padding, + const uint32_t paddingCount, const std::string& definesName, + std::string& uniformStruct, std::string& uniformDefines ) { + for ( GLUniform* uniform : uniforms ) { + uniformStruct += " " + ( uniform->_isTexture ? "uvec2" : uniform->_type ) + " " + uniform->_name; + + if ( uniform->_components ) { + uniformStruct += "[" + std::to_string( uniform->_components ) + "]"; + } + uniformStruct += ";\n"; + + uniformDefines += "#define "; + uniformDefines += uniform->_name; + + if ( uniform->_isTexture ) { + uniformDefines += "_initial"; + } + + uniformDefines += " " + definesName + "."; + uniformDefines += uniform->_name; + + uniformDefines += "\n"; + } + + // Array of structs is aligned to the largest member of the struct + for ( uint32_t i = 0; i < padding; i++ ) { + uniformStruct += " int uniform_padding" + std::to_string( i + paddingCount ); + uniformStruct += ";\n"; + } + + uniformDefines += "\n"; +} + // This will generate all the extra code for material system shaders std::string GLShaderManager::ShaderPostProcess( GLShader *shader, const std::string& shaderText, const uint32_t offset ) { if ( !shader->std430Size ) { return shaderText; } - std::string newShaderText; - std::string materialStruct = "\nstruct Material {\n"; - // 6 kb for materials - const uint32_t count = ( 4096 + 2048 ) / shader->GetSTD430Size(); - std::string materialBlock = "layout(std140, binding = " - + std::to_string( BufferBind::MATERIALS ) - + ") uniform materialsUBO {\n" - " Material materials[" + std::to_string( count ) + "]; \n" - "};\n\n"; - std::string texBuf = glConfig2.maxUniformBlockSize >= MIN_MATERIAL_UBO_SIZE ? "layout(std140, binding = " + std::to_string( BufferBind::TEX_DATA ) @@ -1569,7 +1622,6 @@ std::string GLShaderManager::ShaderPostProcess( GLShader *shader, const std::str "};\n\n" "#define u_LightMap_initial lightMapData[( baseInstance >> 24 ) & 0xFF].u_LightMap\n" "#define u_DeluxeMap_initial lightMapData[( baseInstance >> 24 ) & 0xFF].u_DeluxeMap\n\n"; - std::string materialDefines; /* Generate the struct and defines in the form of: * struct Material { @@ -1582,62 +1634,24 @@ std::string GLShaderManager::ShaderPostProcess( GLShader *shader, const std::str * #define uniformx materials[baseInstance].uniformx */ - for( GLUniform* uniform : shader->_materialSystemUniforms ) { - materialStruct += " " + uniform->_type + " " + uniform->_name; - - if ( uniform->_components ) { - materialStruct += "[" + std::to_string( uniform->_components ) + "]"; - } - materialStruct += ";\n"; - - materialDefines += "#define "; - materialDefines += uniform->_name; - - materialDefines += " materials[baseInstance & 0xFFF]."; - materialDefines += uniform->_name; - - materialDefines += "\n"; - } - - // Array of structs is aligned to the largest member of the struct - for ( uint i = 0; i < shader->padding; i++ ) { - materialStruct += " int material_padding" + std::to_string( i ); - materialStruct += ";\n"; - } + std::string materialStruct = "\nstruct Material {\n"; + std::string materialDefines; + GenerateUniformStructDefinesText( shader->_materialSystemUniforms, shader->padding, + 0, "materials[baseInstance & 0xFFF]", materialStruct, materialDefines ); materialStruct += "};\n\n"; - materialDefines += "\n"; - - std::istringstream shaderTextStream( shaderText ); - std::string shaderMain; - - std::string line; - - /* Remove local uniform declarations, but avoid removing uniform / storage blocks; - * their values will be sourced from a buffer instead - * Global uniforms (like u_ViewOrigin) will still be set as regular uniforms */ - while( std::getline( shaderTextStream, line, '\n' ) ) { - bool skip = false; - if ( line.find( "uniform" ) < line.find( "//" ) && line.find( ";" ) != std::string::npos ) { - for ( GLUniform* uniform : shader->_materialSystemUniforms ) { - const size_t pos = line.find( uniform->_name ); - if ( pos != std::string::npos && !Str::cisalpha( line[pos + strlen( uniform->_name.c_str() )] ) ) { - skip = true; - break; - } - } - } - - if ( skip ) { - continue; - } - shaderMain += line + "\n"; - } + // 6 kb for materials + const uint32_t count = ( 4096 + 2048 ) / shader->GetSTD430Size(); + std::string materialBlock = "layout(std140, binding = " + + std::to_string( BufferBind::MATERIALS ) + + ") uniform materialsUBO {\n" + " Material materials[" + std::to_string( count ) + "]; \n" + "};\n\n"; - materialDefines += "\n"; + std::string shaderMain = RemoveUniformsFromShaderText( shaderText, shader->_materialSystemUniforms ); - newShaderText = "#define USE_MATERIAL_SYSTEM\n" + materialStruct + materialBlock + texDataBlock + materialDefines; + std::string newShaderText = "#define USE_MATERIAL_SYSTEM\n" + materialStruct + materialBlock + texDataBlock + materialDefines; shaderMain.insert( offset, newShaderText ); return shaderMain; } @@ -2455,9 +2469,9 @@ void GLShader_lightMapping::SetShaderProgramUniforms( ShaderProgramDescriptor *s glUniform1i( glGetUniformLocation( shaderProgram->id, "u_HeightMap" ), BIND_HEIGHTMAP ); glUniform1i( glGetUniformLocation( shaderProgram->id, "u_MaterialMap" ), BIND_MATERIALMAP ); glUniform1i( glGetUniformLocation( shaderProgram->id, "u_LightMap" ), BIND_LIGHTMAP ); - glUniform1i( glGetUniformLocation( shaderProgram->id, "u_LightGrid1" ), BIND_LIGHTMAP ); + glUniform1i( glGetUniformLocation( shaderProgram->id, "u_LightGrid1" ), BIND_LIGHTGRID1 ); glUniform1i( glGetUniformLocation( shaderProgram->id, "u_DeluxeMap" ), BIND_DELUXEMAP ); - glUniform1i( glGetUniformLocation( shaderProgram->id, "u_LightGrid2" ), BIND_DELUXEMAP ); + glUniform1i( glGetUniformLocation( shaderProgram->id, "u_LightGrid2" ), BIND_LIGHTGRID2 ); glUniform1i( glGetUniformLocation( shaderProgram->id, "u_GlowMap" ), BIND_GLOWMAP ); glUniform1i( glGetUniformLocation( shaderProgram->id, "u_EnvironmentMap0" ), BIND_ENVIRONMENTMAP0 ); glUniform1i( glGetUniformLocation( shaderProgram->id, "u_EnvironmentMap1" ), BIND_ENVIRONMENTMAP1 ); @@ -2950,7 +2964,7 @@ void GLShader_depthtile1::SetShaderProgramUniforms( ShaderProgramDescriptor *sha GLShader_depthtile2::GLShader_depthtile2() : GLShader( "depthtile2", ATTR_POSITION, false, "screenSpace", "depthtile2" ), - u_DepthMap( this ) { + u_DepthTile1( this ) { } void GLShader_depthtile2::SetShaderProgramUniforms( ShaderProgramDescriptor *shaderProgram ) @@ -2961,7 +2975,7 @@ void GLShader_depthtile2::SetShaderProgramUniforms( ShaderProgramDescriptor *sha GLShader_lighttile::GLShader_lighttile() : GLShader( "lighttile", ATTR_POSITION | ATTR_TEXCOORD, false, "lighttile", "lighttile" ), - u_DepthMap( this ), + u_DepthTile2( this ), u_Lights( this ), u_numLights( this ), u_lightLayer( this ), @@ -2992,7 +3006,7 @@ void GLShader_fxaa::SetShaderProgramUniforms( ShaderProgramDescriptor *shaderPro GLShader_cull::GLShader_cull() : GLShader( "cull", - false, "cull" ), + false, "cull", true ), u_Frame( this ), u_ViewID( this ), u_SurfaceDescriptorsCount( this ), @@ -3015,11 +3029,12 @@ GLShader_depthReduction::GLShader_depthReduction() : false, "depthReduction" ), u_ViewWidth( this ), u_ViewHeight( this ), + u_DepthMap( this ), u_InitialDepthLevel( this ) { } void GLShader_depthReduction::SetShaderProgramUniforms( ShaderProgramDescriptor* shaderProgram ) { - glUniform1i( glGetUniformLocation( shaderProgram->id, "depthTextureInitial" ), 0 ); + glUniform1i( glGetUniformLocation( shaderProgram->id, "u_DepthMap" ), 0 ); } GLShader_clearSurfaces::GLShader_clearSurfaces() : diff --git a/src/engine/renderer/gl_shader.h b/src/engine/renderer/gl_shader.h index e13df92ff8..f5fea59e54 100644 --- a/src/engine/renderer/gl_shader.h +++ b/src/engine/renderer/gl_shader.h @@ -103,6 +103,8 @@ class GLShader { GLuint std430Size = 0; uint32_t padding = 0; + + const bool worldShader; protected: int _activeMacros = 0; ShaderProgramDescriptor* currentProgram; @@ -131,19 +133,21 @@ class GLShader { fragmentShaderName( newFragmentShaderName ), hasVertexShader( true ), hasFragmentShader( true ), - hasComputeShader( false ) { + hasComputeShader( false ), + worldShader( false ) { } GLShader( const std::string& name, const bool useMaterialSystem, - const std::string newComputeShaderName ) : + const std::string newComputeShaderName, const bool newWorldShader = false ) : _name( name ), _vertexAttribsRequired( 0 ), _useMaterialSystem( useMaterialSystem ), computeShaderName( newComputeShaderName ), hasVertexShader( false ), hasFragmentShader( false ), - hasComputeShader( true ) { + hasComputeShader( true ), + worldShader( newWorldShader ) { } public: @@ -318,6 +322,7 @@ class GLUniform { const bool _global; // This uniform won't go into the materials UBO if true const int _components; + const bool _isTexture; protected: GLShader* _shader; @@ -325,13 +330,15 @@ class GLUniform { size_t _locationIndex; GLUniform( GLShader* shader, const char* name, const char* type, const GLuint std430Size, const GLuint std430Alignment, - const bool global, const int components = 0 ) : + const bool global, const int components = 0, + const bool isTexture = false ) : _name( name ), _type( type ), _std430Size( std430Size ), _std430Alignment( std430Alignment ), _global( global ), _components( components ), + _isTexture( isTexture ), _shader( shader ) { _shader->RegisterUniform( this ); } @@ -387,19 +394,34 @@ class GLShaderManager { void GenerateWorldHeaders(); template - void LoadShader( T *& shader ) { - if( !deformShaderCount ) { + void LoadShader( T*& shader ) { + if ( !deformShaderCount ) { Q_UNUSED( GetDeformShaderIndex( nullptr, 0 ) ); initTime = 0; initCount = 0; } shader = new T(); - InitShader( shader ); _shaders.emplace_back( shader ); _shaderBuildQueue.push( shader ); } + void InitShaders() { + for ( const std::unique_ptr& shader : _shaders ) { + if ( !shader.get()->worldShader ) { + InitShader( shader.get() ); + } + } + } + + void InitWorldShaders() { + for ( const std::unique_ptr& shader : _shaders ) { + if ( shader.get()->worldShader ) { + InitShader( shader.get() ); + } + } + } + int GetDeformShaderIndex( deformStage_t *deforms, int numDeforms ); bool BuildPermutation( GLShader* shader, int macroIndex, int deformIndex, const bool buildOneShader ); @@ -439,14 +461,21 @@ class GLShaderManager { ShaderProgramDescriptor* out ); void SaveShaderBinary( ShaderProgramDescriptor* descriptor ); + void GenerateUniformStructDefinesText( const std::vector& uniforms, const uint32_t padding, + const uint32_t paddingCount, const std::string& definesName, + std::string& uniformStruct, std::string& uniformDefines ); + std::string RemoveUniformsFromShaderText( const std::string& shaderText, const std::vector& uniforms ); std::string ShaderPostProcess( GLShader *shader, const std::string& shaderText, const uint32_t offset ); std::string BuildDeformShaderText( const std::string& steps ); std::string ProcessInserts( const std::string& shaderText ) const; + void LinkProgram( GLuint program ) const; void BindAttribLocations( GLuint program ) const; void PrintShaderSource( Str::StringRef programName, GLuint object, std::vector& infoLogLines ) const; + std::vector ParseInfoLog( const std::string& infoLog ) const; std::string GetInfoLog( GLuint object ) const; + std::string BuildShaderText( const std::string& mainShaderText, const std::vector& headers, const std::string& macros ); ShaderDescriptor* FindShader( const std::string& name, const std::string& mainText, const GLenum type, const std::vector& headers, @@ -459,7 +488,7 @@ class GLUniformSampler : protected GLUniform { protected: GLUniformSampler( GLShader* shader, const char* name, const char* type ) : GLUniform( shader, name, type, glConfig2.bindlessTexturesAvailable ? 2 : 1, - glConfig2.bindlessTexturesAvailable ? 2 : 1, true ) { + glConfig2.bindlessTexturesAvailable ? 2 : 1, true, 0, true ) { } inline GLint GetLocation() { @@ -1821,6 +1850,30 @@ class u_FogMap : } }; +class u_DepthTile1 : + GLUniformSampler2D { + public: + u_DepthTile1( GLShader* shader ) : + GLUniformSampler2D( shader, "u_DepthTile1" ) { + } + + void SetUniform_DepthTile1Bindless( GLuint64 bindlessHandle ) { + this->SetValueBindless( bindlessHandle ); + } +}; + +class u_DepthTile2 : + GLUniformSampler2D { + public: + u_DepthTile2( GLShader* shader ) : + GLUniformSampler2D( shader, "u_DepthTile2" ) { + } + + void SetUniform_DepthTile2Bindless( GLuint64 bindlessHandle ) { + this->SetValueBindless( bindlessHandle ); + } +}; + class u_LightTiles : GLUniformSampler3D { public: @@ -3655,7 +3708,7 @@ class GLShader_depthtile1 : class GLShader_depthtile2 : public GLShader, - public u_DepthMap { + public u_DepthTile1 { public: GLShader_depthtile2(); void SetShaderProgramUniforms( ShaderProgramDescriptor *shaderProgram ) override; @@ -3663,7 +3716,7 @@ class GLShader_depthtile2 : class GLShader_lighttile : public GLShader, - public u_DepthMap, + public u_DepthTile2, public u_Lights, public u_numLights, public u_lightLayer, @@ -3708,6 +3761,7 @@ class GLShader_depthReduction : public GLShader, public u_ViewWidth, public u_ViewHeight, + public u_DepthMap, public u_InitialDepthLevel { public: GLShader_depthReduction(); diff --git a/src/engine/renderer/glsl_source/depthReduction_cp.glsl b/src/engine/renderer/glsl_source/depthReduction_cp.glsl index 10349dd1be..47dc8606b3 100644 --- a/src/engine/renderer/glsl_source/depthReduction_cp.glsl +++ b/src/engine/renderer/glsl_source/depthReduction_cp.glsl @@ -39,7 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Keep this to 8x8 because we don't want extra shared mem etc. to be allocated, and to minimize wasted lanes layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in; -layout(binding = 0) uniform sampler2D depthTextureInitial; +layout(binding = 0) uniform sampler2D u_DepthMap; layout(r32f, binding = 1) uniform readonly image2D depthImageIn; layout(r32f, binding = 2) uniform writeonly image2D depthImageOut; @@ -57,7 +57,7 @@ void main() { // Depth buffer uses a packed D24S8 format, so we have to copy it over to an r32f image first if( u_InitialDepthLevel ) { - vec4 depthOut = texelFetch( depthTextureInitial, position, 0 ); + vec4 depthOut = texelFetch( u_DepthMap, position, 0 ); imageStore( depthImageOut, position, depthOut ); } else { float depth[4]; diff --git a/src/engine/renderer/glsl_source/depthtile2_fp.glsl b/src/engine/renderer/glsl_source/depthtile2_fp.glsl index 7ede250cc6..92ae506a50 100644 --- a/src/engine/renderer/glsl_source/depthtile2_fp.glsl +++ b/src/engine/renderer/glsl_source/depthtile2_fp.glsl @@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* depthtile2_fp.glsl */ -uniform sampler2D u_DepthMap; +uniform sampler2D u_DepthTile1; #if __VERSION__ > 120 out vec4 outputColor; @@ -51,7 +51,7 @@ void main() for( x = -0.375; x < 0.5; x += 0.25 ) { for( y = -0.375; y < 0.5; y += 0.25 ) { - vec4 data = texture2D( u_DepthMap, st + vec2(x, y) * r_tileStep ); + vec4 data = texture2D( u_DepthTile1, st + vec2(x, y) * r_tileStep ); if( data.y < 99999.0 ) { accum.x = max( accum.x, data.x ); accum.y = min( accum.y, data.y ); diff --git a/src/engine/renderer/glsl_source/lighttile_fp.glsl b/src/engine/renderer/glsl_source/lighttile_fp.glsl index 559199a298..6c135a687a 100644 --- a/src/engine/renderer/glsl_source/lighttile_fp.glsl +++ b/src/engine/renderer/glsl_source/lighttile_fp.glsl @@ -59,7 +59,7 @@ Light GetLight( in uint idx ) { uniform int u_numLights; uniform mat4 u_ModelMatrix; -uniform sampler2D u_DepthMap; +uniform sampler2D u_DepthTile2; uniform int u_lightLayer; uniform vec3 u_zFar; @@ -96,7 +96,7 @@ vec3 ProjToView( vec2 inp ) { } void main() { - vec2 minmax = texture2D( u_DepthMap, 0.5 * vPosition + 0.5 ).xy; + vec2 minmax = texture2D( u_DepthTile2, 0.5 * vPosition + 0.5 ).xy; float minx = vPosition.x - r_tileStep.x; float maxx = vPosition.x + r_tileStep.x; diff --git a/src/engine/renderer/tr_backend.cpp b/src/engine/renderer/tr_backend.cpp index b0dbce22c9..e836607616 100644 --- a/src/engine/renderer/tr_backend.cpp +++ b/src/engine/renderer/tr_backend.cpp @@ -1160,7 +1160,7 @@ void RB_RenderPostDepthLightTile() GL_Scissor( 0, 0, w, h ); gl_depthtile2Shader->BindProgram( 0 ); - gl_depthtile2Shader->SetUniform_DepthMapBindless( + gl_depthtile2Shader->SetUniform_DepthTile1Bindless( GL_BindToTMU( 0, tr.depthtile1RenderImage ) ); @@ -1180,7 +1180,7 @@ void RB_RenderPostDepthLightTile() gl_lighttileShader->SetUniformBlock_Lights( tr.dlightUBO ); - gl_lighttileShader->SetUniform_DepthMapBindless( + gl_lighttileShader->SetUniform_DepthTile2Bindless( GL_BindToTMU( 1, tr.depthtile2RenderImage ) ); diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index 4f47fa0e44..9a6b29c4c1 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -448,6 +448,8 @@ enum class ssaoMode { BIND_LIGHTMAP, BIND_DELUXEMAP, BIND_GLOWMAP, + BIND_LIGHTGRID1, + BIND_LIGHTGRID2, BIND_ENVIRONMENTMAP0, BIND_ENVIRONMENTMAP1, BIND_LIGHTTILES, diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp index abb1a2a8d2..e44517a906 100644 --- a/src/engine/renderer/tr_shade.cpp +++ b/src/engine/renderer/tr_shade.cpp @@ -190,10 +190,10 @@ void GLSL_InitWorldShaders() { // Material system shaders that are always loaded if material system is available if ( glConfig2.usingMaterialSystem ) { - gl_shaderManager.LoadShader( gl_cullShader ); - gl_cullShader->MarkProgramForBuilding( 0 ); } + + gl_shaderManager.InitWorldShaders(); } static void GLSL_InitGPUShadersOrError() @@ -224,6 +224,9 @@ static void GLSL_InitGPUShadersOrError() gl_shaderManager.LoadShader( gl_lightMappingShaderMaterial ); gl_shaderManager.LoadShader( gl_clearSurfacesShader ); + /* Load gl_cullShader so we can post-process it correctly for push buffer, + it will only actually be built in GLSL_InitWorldShaders() */ + gl_shaderManager.LoadShader( gl_cullShader ); gl_shaderManager.LoadShader( gl_processSurfacesShader ); gl_shaderManager.LoadShader( gl_depthReductionShader ); @@ -320,7 +323,6 @@ static void GLSL_InitGPUShadersOrError() gl_contrastShader->MarkProgramForBuilding( 0 ); } - // portal process effect gl_shaderManager.LoadShader( gl_portalShader ); @@ -371,6 +373,8 @@ static void GLSL_InitGPUShadersOrError() gl_fxaaShader->MarkProgramForBuilding( 0 ); } + gl_shaderManager.InitShaders(); + if ( r_lazyShaders.Get() == 0 ) { gl_shaderManager.BuildAll( false ); @@ -1184,7 +1188,7 @@ void Render_lightMapping( shaderStage_t *pStage ) GL_BindToTMU( BIND_LIGHTMAP, lightmap ) ); } else { - gl_lightMappingShader->SetUniform_LightGrid1Bindless( GL_BindToTMU( BIND_LIGHTMAP, lightmap ) ); + gl_lightMappingShader->SetUniform_LightGrid1Bindless( GL_BindToTMU( BIND_LIGHTGRID1, lightmap ) ); } // bind u_DeluxeMap @@ -1193,7 +1197,7 @@ void Render_lightMapping( shaderStage_t *pStage ) GL_BindToTMU( BIND_DELUXEMAP, deluxemap ) ); } else { - gl_lightMappingShader->SetUniform_LightGrid2Bindless( GL_BindToTMU( BIND_DELUXEMAP, deluxemap ) ); + gl_lightMappingShader->SetUniform_LightGrid2Bindless( GL_BindToTMU( BIND_LIGHTGRID2, deluxemap ) ); } // bind u_GlowMap