[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

This commit is contained in:
2026-08-10 13:00:11 -04:00
parent 0827d7a539
commit 94233ef928
@@ -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<int>(drawProgram.GetLinkStatus()),
static_cast<int>(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);