From 1ef97e517c6360fefc847bb565eaba697d12afb7 Mon Sep 17 00:00:00 2001 From: Dean Galvin Date: Thu, 15 Oct 2026 01:46:28 +1300 Subject: [PATCH] fix(shader): group compute derivatives by four consecutive lanes A compute shader with an LOD query was emitted with DerivativeGroupQuadsKHR, which needs both workgroup dimensions even. A guest workgroup of N x 1 lanes failed SPIR-V validation (VUID-StandaloneSpirv-DerivativeGroupQuadsKHR-10151), which agc_driver_waterfall_images hits on every device. GFX10 forms a compute quad from four consecutive lanes, which is DerivativeGroupLinearKHR. The wave64 path no longer reshapes its workgroup to 2 x N, which only made the 2D quads match consecutive lanes. --- .../SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp index f4c1da3f2b..b499d55a61 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cpp @@ -137,7 +137,7 @@ void DefineModule(SpirvEmitterState& state) { state.module.EmitCapability(spv::CapabilityGroupNonUniformShuffle); } if (state.requirements.computeDerivatives && StageOf(state) == IrShaderStage::Compute) { - state.module.EmitCapability(spv::CapabilityComputeDerivativeGroupQuadsKHR); + state.module.EmitCapability(spv::CapabilityComputeDerivativeGroupLinearKHR); state.module.EmitExtension("SPV_KHR_compute_shader_derivatives"); } const bool fragmentBarycentric = StageOf(state) == IrShaderStage::Pixel && std::any_of(state.inputs.begin(), state.inputs.end(), [](const SpirvInputBinding& input) { @@ -170,10 +170,6 @@ void DefineModule(SpirvEmitterState& state) { localX = ((localX * localY * localZ + 63u) / 64u) * 32u; localY = 1u; localZ = 1u; - if (state.requirements.computeDerivatives) { - localY = localX / 2u; - localX = 2u; - } } state.module.AddExecutionMode(state.mainFunc, spv::ExecutionModeLocalSize, localX, localY, localZ); } @@ -210,7 +206,7 @@ void DefineModule(SpirvEmitterState& state) { } } if (state.requirements.computeDerivatives && StageOf(state) == IrShaderStage::Compute) { - state.module.AddExecutionMode(state.mainFunc, spv::ExecutionModeDerivativeGroupQuadsKHR); + state.module.AddExecutionMode(state.mainFunc, spv::ExecutionModeDerivativeGroupLinearKHR); } state.module.AddName(state.mainFunc, "main"); if (state.requirements.functionLds) {