Skip to content

Commit e33ad90

Browse files
committed
GLUniform._global -> _updateType
This will be required for `PushBuffer` to correctly sort uniforms. Also updates `GLShader.WriteUniformsToBuffer()` to use `mode` and `filter` arguments to select the correct uniforms.
1 parent 79d4de4 commit e33ad90

File tree

3 files changed

+241
-215
lines changed

3 files changed

+241
-215
lines changed

src/engine/renderer/Material.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage, boo
160160
gl_genericShaderMaterial->SetUniform_DepthScale( pStage->depthFadeValue );
161161
}
162162

163-
gl_genericShaderMaterial->WriteUniformsToBuffer( materials );
163+
gl_genericShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
164164
}
165165

166166
void UpdateSurfaceDataLightMapping( uint32_t* materials, shaderStage_t* pStage, bool, bool vertexLit, bool fullbright ) {
@@ -212,7 +212,7 @@ void UpdateSurfaceDataLightMapping( uint32_t* materials, shaderStage_t* pStage,
212212
gl_lightMappingShaderMaterial->SetUniform_SpecularExponent( specExpMin, specExpMax );
213213
}
214214

215-
gl_lightMappingShaderMaterial->WriteUniformsToBuffer( materials );
215+
gl_lightMappingShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
216216
}
217217

218218
void UpdateSurfaceDataReflection( uint32_t* materials, shaderStage_t* pStage, bool, bool, bool ) {
@@ -253,7 +253,7 @@ void UpdateSurfaceDataReflection( uint32_t* materials, shaderStage_t* pStage, bo
253253
gl_reflectionShaderMaterial->SetUniform_ReliefOffsetBias( shader->reliefOffsetBias );
254254
}
255255

256-
gl_reflectionShaderMaterial->WriteUniformsToBuffer( materials );
256+
gl_reflectionShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
257257
}
258258

259259
void UpdateSurfaceDataSkybox( uint32_t* materials, shaderStage_t* pStage, bool, bool, bool ) {
@@ -264,7 +264,7 @@ void UpdateSurfaceDataSkybox( uint32_t* materials, shaderStage_t* pStage, bool,
264264
// u_AlphaThreshold
265265
gl_skyboxShaderMaterial->SetUniform_AlphaTest( GLS_ATEST_NONE );
266266

267-
gl_skyboxShaderMaterial->WriteUniformsToBuffer( materials );
267+
gl_skyboxShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
268268
}
269269

270270
void UpdateSurfaceDataScreen( uint32_t* materials, shaderStage_t* pStage, bool, bool, bool ) {
@@ -277,7 +277,7 @@ void UpdateSurfaceDataScreen( uint32_t* materials, shaderStage_t* pStage, bool,
277277
this seems to be the only material system shader that might need it to not be global */
278278
gl_screenShaderMaterial->SetUniform_CurrentMapBindless( BindAnimatedImage( 0, &pStage->bundle[TB_COLORMAP] ) );
279279

280-
gl_screenShaderMaterial->WriteUniformsToBuffer( materials );
280+
gl_screenShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
281281
}
282282

283283
void UpdateSurfaceDataHeatHaze( uint32_t* materials, shaderStage_t* pStage, bool, bool, bool ) {
@@ -296,7 +296,7 @@ void UpdateSurfaceDataHeatHaze( uint32_t* materials, shaderStage_t* pStage, bool
296296
gl_heatHazeShaderMaterial->SetUniform_NormalScale( normalScale );
297297
}
298298

299-
gl_heatHazeShaderMaterial->WriteUniformsToBuffer( materials );
299+
gl_heatHazeShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
300300
}
301301

302302
void UpdateSurfaceDataLiquid( uint32_t* materials, shaderStage_t* pStage, bool, bool, bool ) {
@@ -348,15 +348,15 @@ void UpdateSurfaceDataLiquid( uint32_t* materials, shaderStage_t* pStage, bool,
348348
gl_liquidShaderMaterial->SetUniform_NormalScale( normalScale );
349349
}
350350

351-
gl_liquidShaderMaterial->WriteUniformsToBuffer( materials );
351+
gl_liquidShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
352352
}
353353

354354
void UpdateSurfaceDataFog( uint32_t* materials, shaderStage_t* pStage, bool, bool, bool ) {
355355
// shader_t* shader = pStage->shader;
356356

357357
materials += pStage->bufferOffset;
358358

359-
gl_fogQuake3ShaderMaterial->WriteUniformsToBuffer( materials );
359+
gl_fogQuake3ShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL );
360360
}
361361

362362
/*

src/engine/renderer/gl_shader.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2428,10 +2428,24 @@ void GLShader::SetRequiredVertexPointers()
24282428
GL_VertexAttribsState( attribs );
24292429
}
24302430

2431-
void GLShader::WriteUniformsToBuffer( uint32_t* buffer ) {
2431+
void GLShader::WriteUniformsToBuffer( uint32_t* buffer, const Mode mode, const int filter ) {
24322432
uint32_t* bufPtr = buffer;
2433-
for ( GLUniform* uniform : _materialSystemUniforms ) {
2434-
bufPtr = uniform->WriteToBuffer( bufPtr );
2433+
std::vector<GLUniform*>* uniforms;
2434+
switch ( mode ) {
2435+
case MATERIAL:
2436+
uniforms = &_materialSystemUniforms;
2437+
break;
2438+
case PUSH:
2439+
uniforms = &_pushUniforms;
2440+
break;
2441+
default:
2442+
ASSERT_UNREACHABLE();
2443+
}
2444+
2445+
for ( GLUniform* uniform : *uniforms ) {
2446+
if ( filter == -1 || uniform->_updateType == filter ) {
2447+
bufPtr = uniform->WriteToBuffer( bufPtr );
2448+
}
24352449
}
24362450
}
24372451

0 commit comments

Comments
 (0)