Skip to content

Commit e6a66e6

Browse files
committed
Fix crash in GenerateWorldMaterials()
If the cgame sends some 2D rendering commands in the first frame before calling RenderScene as described in Unvanquished/Unvanquished#3305, it could cause a crash. Fix this by not setting generatingWorldCommandBuffer prematurely while those commands are executing.
1 parent 96bd021 commit e6a66e6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/engine/renderer/Material.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,8 @@ void MaterialSystem::ProcessStage( drawSurf_t* drawSurf, shaderStage_t* pStage,
14861486
* A material represents a distinct global OpenGL state (e. g. blend function, depth test, depth write etc.)
14871487
* Materials can have a dependency on other materials to make sure that consecutive stages are rendered in the proper order */
14881488
void MaterialSystem::GenerateWorldMaterials() {
1489+
R_SyncRenderThread();
1490+
14891491
const int current_r_nocull = r_nocull->integer;
14901492
const int current_r_drawworld = r_drawworld->integer;
14911493
r_nocull->integer = 1;
@@ -1494,8 +1496,6 @@ void MaterialSystem::GenerateWorldMaterials() {
14941496

14951497
Log::Debug( "Generating world materials" );
14961498

1497-
R_SyncRenderThread();
1498-
14991499
++tr.viewCountNoReset;
15001500
R_AddWorldSurfaces();
15011501

0 commit comments

Comments
 (0)