fix(agc): a zero color export format is not a color export #10779

Merged
stuart-russell merged 3 commits from upstream-pr/10779 into main 2026-11-04 19:19:22 +00:00
stuart-russell commented 2026-10-25 00:04:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by stuart-russell on 2026-10-25T00:04:34Z.


What

SPI_SHADER_COL_FORMAT (0x1c5) entry 0 is SPI_SHADER_ZERO: the pixel shader exports nothing to that slot. The decode treated it as an unsupported export format and threw, so a draw whose CB_SHADER_MASK/CB_TARGET_MASK enabled a slot the shader does not write was rejected instead of drawing its other exports.

Skip format-0 slots when counting exports and when building attachments, and make an unwritten SPI_SHADER_COL_FORMAT read as no exports rather than as a missing register.

Split from #10420. Resubmitted after the open-pull-request limit closed the first copy. The remaining pieces follow one at a time as each lands.

References

An entry of 0 is SPI_SHADER_ZERO in the gfx10 export-format encoding; the existing DecodePixelStageInfo path already treats an unset register as no exports for every slot.

Tested

agc_driver_pm4 (18 tests) and agc_driver_graphics pass, and tools/check_conventions.py --base origin/main passes, on f26434afa.

Real-GPU runs from the thread, all with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation:

  • @wachi35676, Windows 11, 70 AGC entries on an NVIDIA RTX 5070 Ti (621.01) and an AMD RDNA2 iGPU: all pass on AMD, all pass on NVIDIA except agc_driver_stencil_ref_export (device lacks stencil export). With main's State.cpp only agc_driver_graphics fails, color export format 0 is unsupported; deleting just the attachment-loop skip fails the new hole test.
  • @brummilab, Windows 11, WinLibs GCC 15.2: agc_driver_pm4 and agc_driver_graphics pass on main and on this PR.
  • @TechLevelZero's NVIDIA CI, Ubuntu 26.04, RTX 2000 Ada (595.99.02): build passes, 2,259 tests pass with 0 new failures and no new validation IDs against main.

The branch's own runs on the Linux machine used for development have no Vulkan device, so they cover the decode path only.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA RTX 5070 Ti and AMD RDNA2 iGPU (@wachi35676), AMD RX 6600 XT (@brummilab), NVIDIA RTX 2000 Ada (@TechLevelZero CI); the branch's own Linux runs had no Vulkan device
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5000315038 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10779). Originally posted by [stuart-russell](https://github.com/stuart-russell) on 2026-10-25T00:04:34Z. --- ### What `SPI_SHADER_COL_FORMAT` (0x1c5) entry 0 is `SPI_SHADER_ZERO`: the pixel shader exports nothing to that slot. The decode treated it as an unsupported export format and threw, so a draw whose `CB_SHADER_MASK`/`CB_TARGET_MASK` enabled a slot the shader does not write was rejected instead of drawing its other exports. Skip format-0 slots when counting exports and when building attachments, and make an unwritten `SPI_SHADER_COL_FORMAT` read as no exports rather than as a missing register. Split from #10420. Resubmitted after the open-pull-request limit closed the first copy. The remaining pieces follow one at a time as each lands. ### References An entry of 0 is `SPI_SHADER_ZERO` in the gfx10 export-format encoding; the existing `DecodePixelStageInfo` path already treats an unset register as no exports for every slot. ### Tested `agc_driver_pm4` (18 tests) and `agc_driver_graphics` pass, and `tools/check_conventions.py --base origin/main` passes, on `f26434afa`. Real-GPU runs from the thread, all with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_LAYER_KHRONOS_validation`: - @wachi35676, Windows 11, 70 AGC entries on an NVIDIA RTX 5070 Ti (621.01) and an AMD RDNA2 iGPU: all pass on AMD, all pass on NVIDIA except `agc_driver_stencil_ref_export` (device lacks stencil export). With `main`'s `State.cpp` only `agc_driver_graphics` fails, `color export format 0 is unsupported`; deleting just the attachment-loop skip fails the new hole test. - @brummilab, Windows 11, WinLibs GCC 15.2: `agc_driver_pm4` and `agc_driver_graphics` pass on `main` and on this PR. - @TechLevelZero's NVIDIA CI, Ubuntu 26.04, RTX 2000 Ada (595.99.02): build passes, 2,259 tests pass with 0 new failures and no new validation IDs against `main`. The branch's own runs on the Linux machine used for development have no Vulkan device, so they cover the decode path only. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA RTX 5070 Ti and AMD RDNA2 iGPU (@wachi35676), AMD RX 6600 XT (@brummilab), NVIDIA RTX 2000 Ada (@TechLevelZero CI); the branch's own Linux runs had no Vulkan device - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 00:08:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T00:08:01Z.

Review: APPROVED


The change handles SPI_SHADER_ZERO consistently in both export counting and attachment creation. The new tests cover the single zero-format export and a zero-format slot between written exports, while preserving the later export index and blend mapping. I inspected the full diff and verified git diff --check; I could not run the graphics test locally because this checkout has no initialized build tree and its submodule setup is unavailable. Hosted checks are green for the current head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640708139 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10779#pullrequestreview-5640708139). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T00:08:01Z. **Review:** APPROVED --- The change handles `SPI_SHADER_ZERO` consistently in both export counting and attachment creation. The new tests cover the single zero-format export and a zero-format slot between written exports, while preserving the later export index and blend mapping. I inspected the full diff and verified `git diff --check`; I could not run the graphics test locally because this checkout has no initialized build tree and its submodule setup is unavailable. Hosted checks are green for the current head.
ahmadmuj commented 2026-10-25 11:13:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T11:13:34Z.

Review: COMMENTED


Checked head 3cf9b957ccbb, merged onto main 66e6772ca209 (clean merge). Linux, GCC 13. agc_driver_graphics is CPU-only, so no GPU needed.

What I ran:

  • ctest -R '^agc_driver_graphics$' --repeat until-fail:3 on the merge: pass 3/3.
  • Your two test edits with main's State.cpp: fails with color export format 0 is unsupported, as expected.
  • 0 = SPI_SHADER_ZERO checks out against Mesa's src/amd/registers/gfx10.json (SPI_SHADER_EX_FORMAT, used by the COLn_EXPORT_FORMAT fields of SPI_SHADER_COL_FORMAT).

The hole shape matches the existing COLOR_INVALID case: blends are sized by exportCount, attachments are placed by exportIndex, and DecodePixelStageInfo copies the format nibble per export index, so a 0 just writes a location with no attachment. Looks right to me.

Two things:

  1. The new if (slotExport == 0) continue; in the attachment loop isn't covered. Both edited tests put the 0 at the last export index, so the first loop already stops exportCount before it. I deleted that line and agc_driver_graphics still passed. A zero before a written export does hit it, e.g. in CompactedExportTests right after the 0x90009u case:
queue.context[0x1c5] = 0x40u;
state = AgcDriver::Graphics::DecodeState(queue);
Require(state.colors.size() == 1 && state.colors[0].slot == 4 && state.colors[0].exportIndex == 1 && state.blends.size() == 2 && state.blends[0].colorWriteMask == 0, "a zero export format shifted a later MRT export");

That passes on this PR and fails with the line removed.

  1. DrawRejection is now out of step with DecodeState (the comment above LayerExports says the precheck must reject exactly what DecodeState would). DecodeState passes hasColorTarget to colorControlSupported, and that is now false when every written export has format 0. DrawRejection still passes ColorWriteMask(cx) != 0. Example: makeState() with 0x1c5 = 0 and 0x202 = 0xcc0030 (mode resolve). DecodeState accepts it, DrawRejection returns the CB_COLOR_CONTROL message. With 0x1c5 = 9 both reject. It only refuses a draw, nothing renders wrong, but the precheck should probably apply the same zero-format rule.

Not checked: what real hardware does with a zero format between enabled CB_SHADER_MASK slots (no PS5 here). The PR keeps later export indices, same as the COLOR_INVALID model.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642878680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10779#pullrequestreview-5642878680). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T11:13:34Z. **Review:** COMMENTED --- Checked head `3cf9b957ccbb`, merged onto main `66e6772ca209` (clean merge). Linux, GCC 13. `agc_driver_graphics` is CPU-only, so no GPU needed. What I ran: - `ctest -R '^agc_driver_graphics$' --repeat until-fail:3` on the merge: pass 3/3. - Your two test edits with main's `State.cpp`: fails with `color export format 0 is unsupported`, as expected. - 0 = `SPI_SHADER_ZERO` checks out against Mesa's `src/amd/registers/gfx10.json` (`SPI_SHADER_EX_FORMAT`, used by the `COLn_EXPORT_FORMAT` fields of `SPI_SHADER_COL_FORMAT`). The hole shape matches the existing COLOR_INVALID case: blends are sized by `exportCount`, attachments are placed by `exportIndex`, and `DecodePixelStageInfo` copies the format nibble per export index, so a 0 just writes a location with no attachment. Looks right to me. Two things: 1. The new `if (slotExport == 0) continue;` in the attachment loop isn't covered. Both edited tests put the 0 at the last export index, so the first loop already stops `exportCount` before it. I deleted that line and `agc_driver_graphics` still passed. A zero before a written export does hit it, e.g. in `CompactedExportTests` right after the `0x90009u` case: ```cpp queue.context[0x1c5] = 0x40u; state = AgcDriver::Graphics::DecodeState(queue); Require(state.colors.size() == 1 && state.colors[0].slot == 4 && state.colors[0].exportIndex == 1 && state.blends.size() == 2 && state.blends[0].colorWriteMask == 0, "a zero export format shifted a later MRT export"); ``` That passes on this PR and fails with the line removed. 2. `DrawRejection` is now out of step with `DecodeState` (the comment above `LayerExports` says the precheck must reject exactly what DecodeState would). `DecodeState` passes `hasColorTarget` to `colorControlSupported`, and that is now false when every written export has format 0. `DrawRejection` still passes `ColorWriteMask(cx) != 0`. Example: `makeState()` with `0x1c5 = 0` and `0x202 = 0xcc0030` (mode resolve). `DecodeState` accepts it, `DrawRejection` returns the CB_COLOR_CONTROL message. With `0x1c5 = 9` both reject. It only refuses a draw, nothing renders wrong, but the precheck should probably apply the same zero-format rule. Not checked: what real hardware does with a zero format between enabled `CB_SHADER_MASK` slots (no PS5 here). The PR keeps later export indices, same as the COLOR_INVALID model.
MarcZX10 commented 2026-10-29 08:55:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:55:52Z.

Review: CHANGES_REQUESTED


Re-reviewed exact head 88aff2226ac84b672c98c2c646267fbb4018a6df. The topic patch is still the reviewed zero-export change, but this head remains DIRTY against current main and the merge preview conflicts in core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp. Main’s SignedNormalizedFormat/NormalizedChannelMask helpers and this PR’s ColorExportSlots/ColorExportCount additions need to coexist with the intended namespace boundaries. Please merge/rebase current main and rerun agc_driver_graphics/agc_driver_pm4, retaining the zero-format hole and resolve regressions. The earlier approval is stale for this integration state; I have not run local GPU tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695096329 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10779#pullrequestreview-5695096329). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T08:55:52Z. **Review:** CHANGES_REQUESTED --- Re-reviewed exact head `88aff2226ac84b672c98c2c646267fbb4018a6df`. The topic patch is still the reviewed zero-export change, but this head remains `DIRTY` against current `main` and the merge preview conflicts in `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`. Main’s `SignedNormalizedFormat`/`NormalizedChannelMask` helpers and this PR’s `ColorExportSlots`/`ColorExportCount` additions need to coexist with the intended namespace boundaries. Please merge/rebase current main and rerun `agc_driver_graphics`/`agc_driver_pm4`, retaining the zero-format hole and resolve regressions. The earlier approval is stale for this integration state; I have not run local GPU tests.
MarcZX10 commented 2026-10-29 09:43:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:43:58Z.

Review: APPROVED


Re-checked — approved

The updated head resolves the State.cpp integration conflict by preserving main's SignedNormalizedFormat and NormalizedChannelMask helpers before the zero-export helpers. The regression now treats format 0 as an unwritten color slot, preserves later MRT export indices, and accepts a resolve draw only when no color export is present.

The author reports the current-main head c3bc24355 building cleanly, agc_driver_pm4 and agc_driver_graphics passing 18/18, conventions passing, and the validation layer reporting zero VUIDs. Hosted conventions and labels are pending. I did not run a local C++/GPU test or independently inspect a title capture. No blocking issue remains in this diff; approval covers this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695684437 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10779#pullrequestreview-5695684437). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T09:43:58Z. **Review:** APPROVED --- # Re-checked — approved The updated head resolves the `State.cpp` integration conflict by preserving `main`'s `SignedNormalizedFormat` and `NormalizedChannelMask` helpers before the zero-export helpers. The regression now treats format 0 as an unwritten color slot, preserves later MRT export indices, and accepts a resolve draw only when no color export is present. The author reports the current-main head `c3bc24355` building cleanly, `agc_driver_pm4` and `agc_driver_graphics` passing 18/18, conventions passing, and the validation layer reporting zero VUIDs. Hosted conventions and labels are pending. I did not run a local C++/GPU test or independently inspect a title capture. No blocking issue remains in this diff; approval covers this head.
CnRJay commented 2026-11-01 19:47:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:47:42Z.

Review: COMMENTED


The Tested section reports the VK_LAYER_KHRONOS_validation run as clean, but GPUs tested says the AGC tests ran on Linux without a Vulkan device, so that run had nothing to validate. The runs on real GPUs later in the thread (brummilab on an RX 6600 XT, wachi35676 on NVIDIA and AMD) are the evidence for this; please move them, or your own run on a GPU against main, into Tested and drop the no-device line.

One question on ColorExportCount: a missing 0x1c5 now reads as 0, so a draw with a colour target mask and no SPI_SHADER_COL_FORMAT write exports nothing instead of failing. The description says DecodePixelStageInfo already does this; is that the only basis, or is there anything showing the console treats an unwritten register as zero here?

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729916559 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10779#pullrequestreview-5729916559). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:47:42Z. **Review:** COMMENTED --- The Tested section reports the `VK_LAYER_KHRONOS_validation` run as clean, but `GPUs tested` says the AGC tests ran on Linux without a Vulkan device, so that run had nothing to validate. The runs on real GPUs later in the thread (brummilab on an RX 6600 XT, wachi35676 on NVIDIA and AMD) are the evidence for this; please move them, or your own run on a GPU against `main`, into Tested and drop the no-device line. One question on `ColorExportCount`: a missing 0x1c5 now reads as 0, so a draw with a colour target mask and no `SPI_SHADER_COL_FORMAT` write exports nothing instead of failing. The description says `DecodePixelStageInfo` already does this; is that the only basis, or is there anything showing the console treats an unwritten register as zero here?
Sign in to join this conversation.
No reviewers
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!10779
No description provided.