From 7ff9e4907f92fccf928c27c9ef8677a43ff6259a Mon Sep 17 00:00:00 2001 From: DeathWhispers <56944463+Death-Whispers-U@users.noreply.github.com> Date: Sat, 8 Aug 2026 02:21:18 -0400 Subject: [PATCH] Don't declare colorWriteEnable dynamic state on depth-only pipelines (#160) fix(gpu): drop colorWriteEnable dynamic state on depth-only pipelines Pipelines were created with VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT unconditionally on non-Apple platforms, but the draw path only calls vkCmdSetColorWriteEnableEXT when there is at least one color attachment. A depth-only draw therefore reached vkCmdDrawIndexed with the dynamic state declared and never set, which violates VUID-vkCmdDrawIndexed-None-07749. With validation enabled the error is fatal, so any title that issues a depth-only pass aborts. The launcher enables validation by default (vulkan_validation_enabled = true), so this is the default configuration: PAC-MAN WORLD Re-PAC crashes from the launcher while the same build runs normally with --vulkan-validation false. Gate the declaration on the same color_count the draw path uses. Both sides read state.color_count from the same draw, so the two conditions are now identical by construction. --- src/graphics/host_gpu/renderer/pipeline/shaders.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/graphics/host_gpu/renderer/pipeline/shaders.cpp b/src/graphics/host_gpu/renderer/pipeline/shaders.cpp index 7a9243d97..be304a547 100644 --- a/src/graphics/host_gpu/renderer/pipeline/shaders.cpp +++ b/src/graphics/host_gpu/renderer/pipeline/shaders.cpp @@ -953,11 +953,17 @@ void CreatePipelineInternal( vk::DynamicState::eStencilReference, vk::DynamicState::eStencilWriteMask, #if !defined(__APPLE__) + // Keep last so depth-only pipelines can omit this dynamic state. vk::DynamicState::eColorWriteEnableEXT, // unsupported by MoltenVK; static mask instead #endif }; - const auto dynamic_states_count = + auto dynamic_states_count = static_cast(sizeof(dynamic_states) / sizeof(dynamic_states[0])); +#if !defined(__APPLE__) + if (static_params.color_count == 0) { + dynamic_states_count--; + } +#endif vk::PipelineDynamicStateCreateInfo dynamic_state {}; dynamic_state.sType = vk::StructureType::ePipelineDynamicStateCreateInfo;