Skip to content

Commit 4e15435

Browse files
committed
Merge branch 'master' into for-0.56.0/sync
2 parents 65a3c09 + 91374f8 commit 4e15435

File tree

4 files changed

+130
-401
lines changed

4 files changed

+130
-401
lines changed

src/engine/renderer/gl_shader.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ GLShaderManager::~GLShaderManager()
218218
= default;
219219

220220
void GLShaderManager::FreeAll() {
221+
for ( const std::unique_ptr<GLShader>& shader : _shaders ) {
222+
if ( shader.get()->uniformStorage ) {
223+
Z_Free( shader.get()->uniformStorage );
224+
}
225+
}
226+
221227
_shaders.clear();
222228

223229
deformShaderCount = 0;
@@ -236,8 +242,8 @@ void GLShaderManager::FreeAll() {
236242
Z_Free( program.uniformBlockIndexes );
237243
}
238244

239-
if ( program.uniformFirewall ) {
240-
Z_Free( program.uniformFirewall );
245+
if ( program.uniformStorage ) {
246+
Z_Free( program.uniformStorage );
241247
}
242248
}
243249

@@ -266,7 +272,7 @@ void GLShaderManager::UpdateShaderProgramUniformLocations( GLShader* shader, Sha
266272
shaderProgram->uniformLocations = ( GLint* ) Z_Malloc( sizeof( GLint ) * numUniforms );
267273

268274
// create buffer for uniform firewall
269-
shaderProgram->uniformFirewall = ( byte* ) Z_Malloc( uniformSize );
275+
shaderProgram->uniformStorage = ( uint32_t* ) Z_Malloc( uniformSize );
270276

271277
// update uniforms
272278
for (GLUniform *uniform : shader->_uniforms)
@@ -1273,10 +1279,15 @@ void GLShaderManager::InitShader( GLShader* shader ) {
12731279
for ( std::size_t i = 0; i < shader->_uniforms.size(); i++ ) {
12741280
GLUniform* uniform = shader->_uniforms[i];
12751281
uniform->SetLocationIndex( i );
1276-
uniform->SetFirewallIndex( shader->_uniformStorageSize );
1277-
shader->_uniformStorageSize += uniform->GetSize();
1282+
uniform->SetUniformStorageOffset( shader->_uniformStorageSize );
1283+
1284+
shader->_uniformStorageSize += uniform->_bufferSize;
12781285
}
12791286

1287+
shader->_uniformStorageSize *= sizeof( uint32_t );
1288+
1289+
shader->uniformStorage = ( uint32_t* ) Z_Malloc( shader->_uniformStorageSize );
1290+
12801291
for ( std::size_t i = 0; i < shader->_uniformBlocks.size(); i++ ) {
12811292
GLUniformBlock* uniformBlock = shader->_uniformBlocks[i];
12821293
uniformBlock->SetLocationIndex( i );
@@ -2136,10 +2147,6 @@ bool GLCompileMacro_USE_BSP_SURFACE::HasConflictingMacros(size_t permutation, co
21362147
return false;
21372148
}
21382149

2139-
uint32_t* GLUniform::WriteToBuffer( uint32_t * ) {
2140-
Sys::Error( "WriteToBuffer not implemented for GLUniform '%s'", _name );
2141-
}
2142-
21432150
void GLShader::RegisterUniform( GLUniform* uniform ) {
21442151
_uniforms.push_back( uniform );
21452152
}
@@ -2425,6 +2432,8 @@ void GLShader::WriteUniformsToBuffer( uint32_t* buffer, const Mode mode, const i
24252432
bufPtr = uniform->WriteToBuffer( bufPtr );
24262433
}
24272434
}
2435+
2436+
uniformsUpdated = false;
24282437
}
24292438

24302439
GLShader_generic::GLShader_generic() :

0 commit comments

Comments
 (0)