Skip to content

Commit c1dc4c0

Browse files
DolceTriadeillwieckz
authored andcommitted
glsl_restart: Stop segfaulting
Using git bisect, e497a08 introduces a window where globalUBOProxy can be null after glsl_restart. Therefore, also return early, if glboalUBOProxy is null. It will be instantiated later. Further, only initialize world shaders *AFTER* all shader storage has been initialized.
1 parent ef2ae9e commit c1dc4c0

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/engine/renderer/tr_backend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ static void RB_RenderPostProcess()
28302830

28312831
static void SetFrameUniforms() {
28322832
// This can happen with glsl_restart/vid_restart in R_SyncRenderThread()
2833-
if ( !stagingBuffer.Active() ) {
2833+
if ( !stagingBuffer.Active() || globalUBOProxy == nullptr ) {
28342834
return;
28352835
}
28362836

src/engine/renderer/tr_shade.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void EnableAvailableFeatures()
198198
glConfig.usingGeometryCache = glConfig.usingMaterialSystem && glConfig.geometryCacheAvailable;
199199
}
200200

201-
// For shaders that require map data for compile-time values
201+
// For shaders that require map data for compile-time values
202202
void GLSL_InitWorldShaders() {
203203
// make sure the render thread is stopped
204204
R_SyncRenderThread();
@@ -256,11 +256,6 @@ static void GLSL_InitGPUShadersOrError()
256256
gl_depthReductionShader->MarkProgramForBuilding();
257257
}
258258

259-
if ( tr.world ) // this only happens with /glsl_restart
260-
{
261-
GLSL_InitWorldShaders();
262-
}
263-
264259
if ( glConfig.realtimeLighting )
265260
{
266261
gl_shaderManager.LoadShader( gl_depthtile1Shader );
@@ -331,7 +326,7 @@ static void GLSL_InitGPUShadersOrError()
331326

332327
gl_contrastShader->MarkProgramForBuilding();
333328
}
334-
329+
335330
// portal process effect
336331
gl_shaderManager.LoadShader( gl_portalShader );
337332

@@ -384,6 +379,12 @@ static void GLSL_InitGPUShadersOrError()
384379
gl_shaderManager.PostProcessGlobalUniforms();
385380
gl_shaderManager.InitShaders();
386381

382+
// Init world shaders last so that everyhthing is already initialized.
383+
if ( tr.world ) // this only happens with /glsl_restart
384+
{
385+
GLSL_InitWorldShaders();
386+
}
387+
387388
if ( r_lazyShaders.Get() == 0 )
388389
{
389390
gl_shaderManager.BuildAll( false );
@@ -1447,7 +1448,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14471448

14481449
// bind u_NormalMap
14491450
gl_heatHazeShader->SetUniform_NormalMapBindless(
1450-
GL_BindToTMU( 0, pStage->bundle[TB_NORMALMAP].image[0] )
1451+
GL_BindToTMU( 0, pStage->bundle[TB_NORMALMAP].image[0] )
14511452
);
14521453

14531454
if ( pStage->enableNormalMapping )
@@ -1463,7 +1464,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14631464

14641465
// bind u_CurrentMap
14651466
gl_heatHazeShader->SetUniform_CurrentMapBindless(
1466-
GL_BindToTMU( 1, tr.currentRenderImage[backEnd.currentMainFBO] )
1467+
GL_BindToTMU( 1, tr.currentRenderImage[backEnd.currentMainFBO] )
14671468
);
14681469

14691470
gl_heatHazeShader->SetRequiredVertexPointers();
@@ -1473,7 +1474,7 @@ void Render_heatHaze( shaderStage_t *pStage )
14731474
// copy to foreground image
14741475
R_BindFBO( tr.mainFBO[ backEnd.currentMainFBO ] );
14751476
gl_heatHazeShader->SetUniform_CurrentMapBindless(
1476-
GL_BindToTMU( 1, tr.currentRenderImage[1 - backEnd.currentMainFBO] )
1477+
GL_BindToTMU( 1, tr.currentRenderImage[1 - backEnd.currentMainFBO] )
14771478
);
14781479
gl_heatHazeShader->SetUniform_DeformMagnitude( 0.0f );
14791480
Tess_DrawElements();

0 commit comments

Comments
 (0)