[Fix] (Magma): lower pixel_center_integer gl_FragCoord so Vulkan validation stops refusing the program

This commit is contained in:
2026-10-12 15:06:42 -04:00
parent 171eed9ac0
commit da6b172d08
8 changed files with 391 additions and 0 deletions
@@ -3675,6 +3675,20 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
}
// Vulkan forbids the PixelCenterInteger execution mode that
// `layout(pixel_center_integer) in vec4 gl_FragCoord;` compiles to, so a module
// carrying it would fail validation and every draw of the program be refused. This
// runs before the FragCoordYFlip variant: the flip then rewrites the unshifted builtin
// read and the -0.5 lands on the flipped value, as GL defines it.
if (stages[i] == ShaderStage::Fragment) {
Vector<Uint> centeredSpirv;
if (MG_Util::ShaderTranspiler::ShaderCompiler::LowerPixelCenterIntegerForVulkan(
moduleSpirvs[i], centeredSpirv, enableSpirvValidation) &&
!centeredSpirv.empty()) {
moduleSpirvs[i] = Move(centeredSpirv);
}
}
if ((flags & ProgramFactory::CompileOptionBit::FragCoordYFlip) && stages[i] == ShaderStage::Fragment) {
Vector<Uint> fragCoordSpirv;
if (TransformSpirvForFragCoordYFlip(moduleSpirvs[i], fragCoordSpirv, m_defaultFramebufferHeight)) {