From 94233ef9280ddab75a3871e6fd0afc23b4d86023 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Mon, 10 Aug 2026 13:00:11 -0400 Subject: [PATCH] [Fix] (MG_Backend/DirectVulkan): drop draws and dispatches when a program has no optimized SPIR-V - a phase-B failure left raw glslang words in GetGeneratedSpirv --- .../DirectVulkan/Renderer/VulkanRenderer.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp index 7448f192..bbcecba6 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp @@ -5568,6 +5568,19 @@ void main() { MakeXfbWritesVisible(); VkTextureManager::DrawSyncScope drawSyncScope(*m_textureManager); m_textureManager->CollectGarbage(); + { + // Mirror DirectGLES's SyncToBackend gate: a program whose phase-B job failed or + // was cancelled has no usable optimized module - and on an in-place + // SanitizeAndOptimizeBinary failure GetGeneratedSpirv() still holds the RAW + // glslang words, which must never reach vkCreateShaderModule. Drop the draw. + const auto& drawProgram = *MG_State::pGLContext->GetProgramForDraw(); + if (!drawProgram.GetLinkStatus() || !drawProgram.GetSpirvStatus()) { + MGLOG_D("SetupDraw skipped: program=%u is linked=%d spirv=%d", + drawProgram.GetExternalIndex(), static_cast(drawProgram.GetLinkStatus()), + static_cast(drawProgram.GetSpirvStatus())); + return false; + } + } if (TrySetupDrawFastPath(frame, mode, aspects, drawParams, pIndexBufferView)) { return true; } @@ -6018,6 +6031,11 @@ void main() { m_textureManager->CollectGarbage(); auto& frame = m_frameContext.GetCurrent(); const auto& program = *MG_State::pGLContext->GetProgramForDraw(); + if (!program.GetLinkStatus() || !program.GetSpirvStatus()) { + MGLOG_E("DispatchCompute skipped: program=%u has no optimized SPIR-V", + program.GetExternalIndex()); + return; + } ProgramFactory::CompileOptionFlags transformFlags = 0; const auto& programObj = m_programFactory->GetOrCreateProgram(program, transformFlags); @@ -6058,6 +6076,11 @@ void main() { m_textureManager->CollectGarbage(); auto& frame = m_frameContext.GetCurrent(); const auto& program = *MG_State::pGLContext->GetProgramForDraw(); + if (!program.GetLinkStatus() || !program.GetSpirvStatus()) { + MGLOG_E("DispatchComputeIndirect skipped: program=%u has no optimized SPIR-V", + program.GetExternalIndex()); + return; + } ProgramFactory::CompileOptionFlags transformFlags = 0; const auto& programObj = m_programFactory->GetOrCreateProgram(program, transformFlags);