Skip to content

Commit 2bc7f51

Browse files
committed
Bind the u_Lights UBO only once if GL_ARB_shading_language_420pack is available
1 parent 633b45a commit 2bc7f51

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/engine/renderer/Material.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,6 @@ void MaterialSystem::BindBuffers() {
730730
texDataBuffer.BindBufferBase( texDataBufferType, texDataBindingPoint );
731731
lightMapDataUBO.BindBufferBase();
732732

733-
if ( glConfig2.realtimeLighting ) {
734-
// UBOs are actually completely independent of shaders since we set the binding points explicitly here
735-
gl_lightMappingShaderMaterial->SetUniformBlock_Lights( tr.dlightUBO );
736-
}
737-
738733
culledCommandsBuffer.BindBuffer( GL_DRAW_INDIRECT_BUFFER );
739734
atomicCommandCountersBuffer.BindBuffer( GL_PARAMETER_BUFFER_ARB );
740735

src/engine/renderer/gl_shader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,10 @@ void GLShaderManager::BuildAll( const bool buildOnlyMarked ) {
11811181
cacheLoadCount, cacheLoadTime, cacheSaveCount, cacheSaveTime );
11821182
}
11831183

1184+
void GLShaderManager::BindBuffers() {
1185+
glBindBufferBase( GL_UNIFORM_BUFFER, BufferBind::LIGHTS, tr.dlightUBO );
1186+
}
1187+
11841188
std::string GLShaderManager::ProcessInserts( const std::string& shaderText ) const {
11851189
std::string out;
11861190
std::istringstream shaderTextStream( shaderText );

src/engine/renderer/gl_shader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ class GLShaderManager {
368368
bool BuildPermutation( GLShader* shader, int macroIndex, int deformIndex, const bool buildOneShader );
369369
void BuildAll( const bool buildOnlyMarked );
370370
void FreeAll();
371+
372+
void BindBuffers();
371373
private:
372374
struct InfoLogEntry {
373375
int line;
@@ -1261,7 +1263,6 @@ class GLUniformBlock
12611263

12621264
void SetBuffer( GLuint buffer ) {
12631265
if ( glConfig2.shadingLanguage420PackAvailable ) {
1264-
glBindBufferBase( GL_UNIFORM_BUFFER, _bindingPoint, buffer );
12651266
return;
12661267
}
12671268

src/engine/renderer/tr_init.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,10 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p
15401540
GLSL_FinishGPUShaders();
15411541
}
15421542

1543+
if ( glConfig2.shadingLanguage420PackAvailable ) {
1544+
gl_shaderManager.BindBuffers();
1545+
}
1546+
15431547
/* TODO: Move this into a loading step and don't render it to the screen
15441548
For now though do it here to avoid the ugly square rendering appearing on top of the loading screen */
15451549
if ( glConfig2.reflectionMappingAvailable ) {

0 commit comments

Comments
 (0)