AGC: a raw 32-bit float export into a UINT color target fails pipeline creation on MoltenVK (Doom 3 BFG, ccleste) #9783

Closed
opened 2026-10-22 14:46:07 +00:00 by rooklz · 2 comments
rooklz commented 2026-10-22 14:46:07 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-22T14:46:07Z.


What stops

Two homebrew catalog titles stop at their first draw on macOS with MoltenVK, because a pixel shader that exports raw 32-bit values into a color target whose number type is UINT reaches Vulkan as a float4 output on an integer attachment, which Metal refuses to compile:

Title Target format the driver picks MoltenVK's error
PPSA99313 Doom 3 BFG (ps5-v1.0.0 catalog build) VK_FORMAT_R32G32B32A32_UINT (COLOR_32_32_32_32, number UINT) output of type float4 is not compatible with a MTLPixelFormatRGBA32Uint color attachment
PPSA59322 ccleste VK_FORMAT_R8_UINT (COLOR_8, number UINT) output of type float4 is not compatible with a MTLPixelFormatR8Uint color attachment

Both end as

[mvk-error] VK_ERROR_INITIALIZATION_FAILED: Render pipeline compile failed (Error code 3):
[gpu] driver failure: AGC graphics: vkCreateGraphicsPipelines: Vulkan result -3

(the second line of the Metal message is only printed with MVK_CONFIG_LOG_LEVEL=3). Doom 3 BFG's draw is a 3-index rect-list draw with one color target, vertex 0x200320000 and fragment 0x200320400, as APS5_TRACE_DRAW_PROGRAMS prints it; it also has blending enabled on that target, which MoltenVK warns about separately (Blending is enabled for attachment with format VK_FORMAT_R32G32B32A32_UINT, which does not support it) but which is not what fails the compile: I tried forcing blendEnable off for integer formats in State.cpp and the compile error stays.

On a Linux NVIDIA or AMD driver the same pipeline is accepted (the float output is written as its bits), so this only shows on Metal.

Where

  • Graphics/src/State.cpp chooses the attachment format from the target's number type: COLOR_32_32_32_32 with UINT becomes R32G32B32A32_UINT (case 14), COLOR_8 with UINT becomes R8_UINT.
  • Graphics/src/ShaderValidation.cpp (line 711 on main 8b3e39832a) expects the fragment output signature vertex:u32x4 only when color.uintExport is set, and State.cpp line 1386 sets that only for export format 7 (UINT16_ABGR). A raw 32-bit export (formats 1, 2, 3 and 9) into a UINT target keeps the float signature, so the SPIR-V output is float4 while the attachment is integer.

Vulkan leaves the result undefined when the output's numeric type differs from the attachment's; Metal rejects it at compile time. The Vulkan spec also says Blending is only defined for floating-point, UNORM, SNORM, and sRGB formats (framebuffer chapter), so the enabled blend on the UINT target is a second undefined case in the same draw.

What I think the fix is

Type the fragment output by the target, not only by the export format: for a UINT (or SINT) target reached through a raw 32-bit export, emit the export as u32x4 (a bitcast of the same bits) and expect that signature in ShaderValidation.cpp. For 32-bit channels that is the same stored bits the console's CB stores, since it does no conversion for 32-bit components; for 8- and 16-bit channels the console converts the raw export per the number type, which the integer attachment then does too. Blending on a UINT target should be dropped at the same time, since neither the console's CB nor Vulkan blends integer formats.

I have not measured this on a console; the CB conversion rules above are from the RDNA CB documentation as the driver already uses them. I can test a change on this M5 and on NVIDIA tomorrow, and I'm happy to do the PR if nobody is on it; I'm not touching the recompiler without saying so here first.

Environment

macOS 26.2, Apple M5, Apple clang 21, x86-64 under Rosetta 2, the ci/macos-series-2 integration tree at 53db0badb with #7524, the code of #7937 and the libSceSsl change of #7332, MoltenVK from MBridge (its VK_EXT_provoking_vertex, VK_KHR_fragment_shader_barycentric and mesh-shader features report false). Titles converted with main's relinker, --macos --to-rosetta.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5981606357 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9783). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-22T14:46:07Z. --- ### What stops Two homebrew catalog titles stop at their first draw on macOS with MoltenVK, because a pixel shader that exports raw 32-bit values into a color target whose number type is UINT reaches Vulkan as a `float4` output on an integer attachment, which Metal refuses to compile: | Title | Target format the driver picks | MoltenVK's error | | --- | --- | --- | | PPSA99313 Doom 3 BFG (`ps5-v1.0.0` catalog build) | `VK_FORMAT_R32G32B32A32_UINT` (`COLOR_32_32_32_32`, number UINT) | `output of type float4 is not compatible with a MTLPixelFormatRGBA32Uint color attachment` | | PPSA59322 ccleste | `VK_FORMAT_R8_UINT` (`COLOR_8`, number UINT) | `output of type float4 is not compatible with a MTLPixelFormatR8Uint color attachment` | Both end as ``` [mvk-error] VK_ERROR_INITIALIZATION_FAILED: Render pipeline compile failed (Error code 3): [gpu] driver failure: AGC graphics: vkCreateGraphicsPipelines: Vulkan result -3 ``` (the second line of the Metal message is only printed with `MVK_CONFIG_LOG_LEVEL=3`). Doom 3 BFG's draw is a 3-index rect-list draw with one color target, vertex `0x200320000` and fragment `0x200320400`, as `APS5_TRACE_DRAW_PROGRAMS` prints it; it also has blending enabled on that target, which MoltenVK warns about separately (`Blending is enabled for attachment with format VK_FORMAT_R32G32B32A32_UINT, which does not support it`) but which is not what fails the compile: I tried forcing `blendEnable` off for integer formats in `State.cpp` and the compile error stays. On a Linux NVIDIA or AMD driver the same pipeline is accepted (the float output is written as its bits), so this only shows on Metal. ### Where - `Graphics/src/State.cpp` chooses the attachment format from the target's number type: `COLOR_32_32_32_32` with UINT becomes `R32G32B32A32_UINT` (case 14), `COLOR_8` with UINT becomes `R8_UINT`. - `Graphics/src/ShaderValidation.cpp` (line 711 on `main` `8b3e39832a`) expects the fragment output signature `vertex:u32x4` only when `color.uintExport` is set, and `State.cpp` line 1386 sets that only for export format 7 (`UINT16_ABGR`). A raw 32-bit export (formats 1, 2, 3 and 9) into a UINT target keeps the float signature, so the SPIR-V output is `float4` while the attachment is integer. Vulkan leaves the result undefined when the output's numeric type differs from the attachment's; Metal rejects it at compile time. The Vulkan spec also says `Blending is only defined for floating-point, UNORM, SNORM, and sRGB formats` (framebuffer chapter), so the enabled blend on the UINT target is a second undefined case in the same draw. ### What I think the fix is Type the fragment output by the target, not only by the export format: for a UINT (or SINT) target reached through a raw 32-bit export, emit the export as `u32x4` (a bitcast of the same bits) and expect that signature in `ShaderValidation.cpp`. For 32-bit channels that is the same stored bits the console's CB stores, since it does no conversion for 32-bit components; for 8- and 16-bit channels the console converts the raw export per the number type, which the integer attachment then does too. Blending on a UINT target should be dropped at the same time, since neither the console's CB nor Vulkan blends integer formats. I have not measured this on a console; the CB conversion rules above are from the RDNA CB documentation as the driver already uses them. I can test a change on this M5 and on NVIDIA tomorrow, and I'm happy to do the PR if nobody is on it; I'm not touching the recompiler without saying so here first. ### Environment macOS 26.2, Apple M5, Apple clang 21, x86-64 under Rosetta 2, the `ci/macos-series-2` integration tree at `53db0badb` with #7524, the code of #7937 and the libSceSsl change of #7332, MoltenVK from MBridge (its `VK_EXT_provoking_vertex`, `VK_KHR_fragment_shader_barycentric` and mesh-shader features report false). Titles converted with `main`'s relinker, `--macos --to-rosetta`. AI-assisted: yes
rooklz commented 2026-10-22 14:48:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-22T14:48:26Z.


Starting on this now, so it's said here first: the change I'm trying is a fourth ColorExportPacking kind for UINT targets, which goes through the existing fragment-output specialization (the same retype-and-bitcast it already does for the 11_11_10 packings, no new SPIR-V shapes), the driver picking it for UINT number types reached by raw 32-bit exports and dropping the blend on those targets, plus a DecodeState check and an execution test. If someone is already on it, say so and I'll stop.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343662397 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9783#issuecomment-6343662397). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-22T14:48:26Z. --- Starting on this now, so it's said here first: the change I'm trying is a fourth `ColorExportPacking` kind for UINT targets, which goes through the existing fragment-output specialization (the same retype-and-bitcast it already does for the 11_11_10 packings, no new SPIR-V shapes), the driver picking it for UINT number types reached by raw 32-bit exports and dropping the blend on those targets, plus a DecodeState check and an execution test. If someone is already on it, say so and I'll stop.
rooklz commented 2026-10-22 15:05:30 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-22T15:05:30Z.


Pull request: #9789. On the M5 with MoltenVK it takes Doom 3 BFG past the pipeline compile to its own data check and ccleste to the barycentric gap; bring-up threads #9787 and #9788.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6344033861 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9783#issuecomment-6344033861). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-22T15:05:30Z. --- Pull request: #9789. On the M5 with MoltenVK it takes Doom 3 BFG past the pipeline compile to its own data check and ccleste to the barycentric gap; bring-up threads #9787 and #9788.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#9783
No description provided.