From ca57f7b46c4e20922c38e04fa6dcfa7615befa3d Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Mon, 28 Oct 2024 15:22:00 +0100 Subject: [PATCH] sokol: Fix crash when no render target was initialized --- Source/Render/sokol/SokolRenderState.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Render/sokol/SokolRenderState.cpp b/Source/Render/sokol/SokolRenderState.cpp index a8862cf6..8a30e7cd 100644 --- a/Source/Render/sokol/SokolRenderState.cpp +++ b/Source/Render/sokol/SokolRenderState.cpp @@ -715,11 +715,12 @@ void cSokolRender::CreateCommand(VertexBuffer* vb, size_t vertices, IndexBuffer* SokolPipelineContext pipeline_context; pipeline_context.pipeline_type = pipelineType; - pipeline_context.pipeline_target = SOKOL_PIPELINE_TARGET_SWAPCHAIN; pipeline_context.pipeline_mode = activePipelineMode; pipeline_context.primitive_type = activeDrawBuffer->primitive; pipeline_context.vertex_fmt = vb->fmt; - if (activeRenderTarget == shadowMapRenderTarget) { + if (activeRenderTarget == nullptr) { + pipeline_context.pipeline_target = SOKOL_PIPELINE_TARGET_SWAPCHAIN; + } else if (activeRenderTarget == shadowMapRenderTarget) { pipeline_context.pipeline_target = SOKOL_PIPELINE_TARGET_SHADOWMAP; // render back-faces in shadow pass to prevent shadow acne on front-faces pipeline_context.pipeline_mode.cull = CULL_CCW;