fix(shader): defer guarded fragment V# type faults #7689

Open
MarcZX10 wants to merge 1 commit from upstream-pr/7689 into main
MarcZX10 commented 2026-10-18 23:30:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T23:30:17Z.


What

  • Defer invalid buffer-descriptor TYPE faults for eligible, read-only fragment-stage buffer loads until the shader actually executes the load.
  • Preserve immediate rejection for unsupported writes, atomics, aliases, scalar loads, and ineligible descriptors.
  • Add active and inactive EXEC-branch regression cases for the Kena capture from #5879. The inactive mask is read from runtime user SGPRs so the load is not folded away.

This is a fragment-stage follow-up to #6412. Its author confirmed that #6412 remains compute-only and asked that the Kena case be handled separately.

Tested

Rebased onto current upstream main 1da991f9bb. Current PR head 75e1ccb8be (one commit on top of main; the previous head 3e63c0489a is replaced).

Windows 11, Ryzen 7 260 (AVX2, FMA and BMI2 present), GCC 15.2 UCRT, Release, with BUILD_TESTING=ON. No GPU or Vulkan validation-layer run on this host.

  • Build of agc_driver_draw_unsupported_buffer_type_tests, agc_driver_stencil_replay_tests, agc_shader_disk_cache_tests and agc_driver_image_table_reuse_tests: passed.
  • CTest, 24 entries across draw_unsupported_buffer_type (including _deferred_fault, _skip_refused, _draw_pipeline, _plan_verify), image_table_reuse (all 8 entries), stencil_replay (both entries) and agc_shader_disk_cache (all 5 entries): 24 of 24 passed.
  • python3 tools/check_conventions.py --base origin/main: passed. git diff --check origin/main...HEAD: clean.
  • Not verified: the Kena capture, the frame-time effect, and the shader output of valid draws on hardware. The cache format change is covered only by these tests.

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: #6412 (shared descriptor fault handling; rebase after it merges)
  • Fixes: none (the deferred TYPE fault of #5879; Kena's typed-buffer format 0 from the same V# is still open)
  • Unblocks: none
  • GPUs tested: n/a (no GPU run on this host; see Tested)
  • AI-Assisted: Yes

Cache format coordination

Current main uses shader cache format 96. This PR uses 97, which is above main. The FormatVersion - 1 round-trip checks in ShaderDiskCache tests are unchanged. Open #6924 and #6412 may propose other versions; recheck the next unused version if cache-format changes land before this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4913765267 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T23:30:17Z. --- ### What - Defer invalid buffer-descriptor TYPE faults for eligible, read-only fragment-stage buffer loads until the shader actually executes the load. - Preserve immediate rejection for unsupported writes, atomics, aliases, scalar loads, and ineligible descriptors. - Add active and inactive EXEC-branch regression cases for the Kena capture from #5879. The inactive mask is read from runtime user SGPRs so the load is not folded away. This is a fragment-stage follow-up to #6412. Its author confirmed that #6412 remains compute-only and asked that the Kena case be handled separately. ### Tested Rebased onto current upstream `main` `1da991f9bb`. Current PR head `75e1ccb8be` (one commit on top of `main`; the previous head `3e63c0489a` is replaced). Windows 11, Ryzen 7 260 (AVX2, FMA and BMI2 present), GCC 15.2 UCRT, Release, with `BUILD_TESTING=ON`. No GPU or Vulkan validation-layer run on this host. - Build of `agc_driver_draw_unsupported_buffer_type_tests`, `agc_driver_stencil_replay_tests`, `agc_shader_disk_cache_tests` and `agc_driver_image_table_reuse_tests`: passed. - CTest, 24 entries across `draw_unsupported_buffer_type` (including `_deferred_fault`, `_skip_refused`, `_draw_pipeline`, `_plan_verify`), `image_table_reuse` (all 8 entries), `stencil_replay` (both entries) and `agc_shader_disk_cache` (all 5 entries): 24 of 24 passed. - `python3 tools/check_conventions.py --base origin/main`: passed. `git diff --check origin/main...HEAD`: clean. - Not verified: the Kena capture, the frame-time effect, and the shader output of valid draws on hardware. The cache format change is covered only by these tests. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: #6412 (shared descriptor fault handling; rebase after it merges) - [x] Fixes: none (the deferred TYPE fault of #5879; Kena's typed-buffer format 0 from the same V# is still open) - [x] Unblocks: none - [x] GPUs tested: n/a (no GPU run on this host; see Tested) - [x] AI-Assisted: Yes ### Cache format coordination Current `main` uses shader cache format 96. This PR uses 97, which is above `main`. The `FormatVersion - 1` round-trip checks in `ShaderDiskCache` tests are unchanged. Open #6924 and #6412 may propose other versions; recheck the next unused version if cache-format changes land before this PR.
oneandonlydean commented 2026-10-19 00:21:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T00:21:46Z.


@MarcZX10 I ran agc_driver_draw_unsupported_buffer_type on an RTX 4090 (Linux, NVIDIA): it is the first run of this test anywhere, since your host can't build it. On b0507123c8 it fails before any assertion, with unsupported SOP1 opcode 0.

The first word of InactivePixelCode, 0xbe8c0080, decodes as SOP1 opcode 0 into s12. On GFX10, s_mov_b32 is SOP1 opcode 3, and opcode 0 doesn't exist, so the recompiler refuses the shader. Even with opcode 3, s_mov_b32 doesn't write SCC, so the s_cbranch_scc1 after it would branch on whatever SCC holds at entry rather than skip the load as intended.

Could you build the inactive case from instructions the translator accepts and that make the load's lanes inactive for certain? For example, clear EXEC first (s_mov_b32 exec_lo, 0, or s_mov_b64 exec, 0 for wave64) and either keep the load in the program or skip it with s_cbranch_execz. Then check the encodings against the GFX10 tables, the way PixelCode does. Keeping the load in the program with no active lanes is closer to the case in #5879, where the load is still in the shader. Once it runs, InactiveLaneDoesNotFault and NamesShaderAndDescriptor would cover both sides.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6257014089 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6257014089). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T00:21:46Z. --- @MarcZX10 I ran `agc_driver_draw_unsupported_buffer_type` on an RTX 4090 (Linux, NVIDIA): it is the first run of this test anywhere, since your host can't build it. On b0507123c8 it fails before any assertion, with `unsupported SOP1 opcode 0`. The first word of `InactivePixelCode`, `0xbe8c0080`, decodes as SOP1 opcode 0 into s12. On GFX10, `s_mov_b32` is SOP1 opcode 3, and opcode 0 doesn't exist, so the recompiler refuses the shader. Even with opcode 3, `s_mov_b32` doesn't write SCC, so the `s_cbranch_scc1` after it would branch on whatever SCC holds at entry rather than skip the load as intended. Could you build the inactive case from instructions the translator accepts and that make the load's lanes inactive for certain? For example, clear EXEC first (`s_mov_b32 exec_lo, 0`, or `s_mov_b64 exec, 0` for wave64) and either keep the load in the program or skip it with `s_cbranch_execz`. Then check the encodings against the GFX10 tables, the way `PixelCode` does. Keeping the load in the program with no active lanes is closer to the case in #5879, where the load is still in the shader. Once it runs, `InactiveLaneDoesNotFault` and `NamesShaderAndDescriptor` would cover both sides.
blawesom commented 2026-10-19 06:54:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T06:54:59Z.


Rebase handoff, with one serializer collision resolved and one open failure — main and this PR each added a DescriptorBinding field and an addGuestBuffer parameter (main's bufferExtent, your bufferDeferredTypeFault); the merged version carries both: both struct fields, both parameters, both encoder/decoder lines, with the disk-cache format bumped to v41 and the size assert pinned to the merged 696.

The open failure: agc_driver_draw_unsupported_buffer_type fails with unsupported SOP1 opcode 0 — it fails identically on your own unrebased head, so it is the PR's own state, not the merge: with the deferred type fault wired through, a path that previously threw at bind time now reaches the shader with an unencoded SOP1 instruction (opcode 0), which surfaces as a driver failure rather than the expected refusal. Beyond that and the three known main regressions (#5444 Mesa, #7584 BDA, #7766 image-table vouch), the suite is green and conventions pass.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7689
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is b0507123c.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6261518457 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6261518457). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-19T06:54:59Z. --- **Rebase handoff, with one serializer collision resolved and one open failure** — `main` and this PR each added a `DescriptorBinding` field and an `addGuestBuffer` parameter (main's `bufferExtent`, your `bufferDeferredTypeFault`); the merged version carries **both**: both struct fields, both parameters, both encoder/decoder lines, with the disk-cache format bumped to **v41** and the size assert pinned to the merged 696. **The open failure:** `agc_driver_draw_unsupported_buffer_type` fails with `unsupported SOP1 opcode 0` — **it fails identically on your own unrebased head**, so it is the PR's own state, not the merge: with the deferred type fault wired through, a path that previously threw at bind time now reaches the shader with an unencoded SOP1 instruction (opcode 0), which surfaces as a driver failure rather than the expected refusal. Beyond that and the three known `main` regressions (#5444 Mesa, #7584 BDA, #7766 image-table vouch), the suite is green and conventions pass. **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/7689 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `b0507123c`.
MarcZX10 commented 2026-10-19 16:09:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:09:28Z.


I checked the failing fixture and confirmed 0xbe8c0080 is unsupported SOP1 opcode 0. I replaced it locally with 0xbefe0480 (s_mov_b64 exec, 0), leaving the invalid V# load in the shader with all lanes inactive; this avoids relying on SCC state and matches the intended regression. git diff --check passes. I could not build the execution target in this worktree because it has no configured build tree, and rebasing the current PR onto today’s main stops on six conflicts in ShaderResources.hpp/.cpp, DescriptorBindingBuilder.cpp, Recompiler.hpp, and ShaderDiskCache.cpp/.hpp. The fix is ready as a small isolated patch, but I have not pushed it since the rebase would need those serializer and cache conflicts resolved.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271662029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6271662029). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T16:09:28Z. --- I checked the failing fixture and confirmed `0xbe8c0080` is unsupported SOP1 opcode 0. I replaced it locally with `0xbefe0480` (`s_mov_b64 exec, 0`), leaving the invalid V# load in the shader with all lanes inactive; this avoids relying on SCC state and matches the intended regression. `git diff --check` passes. I could not build the execution target in this worktree because it has no configured build tree, and rebasing the current PR onto today’s `main` stops on six conflicts in ShaderResources.hpp/.cpp, DescriptorBindingBuilder.cpp, Recompiler.hpp, and ShaderDiskCache.cpp/.hpp. The fix is ready as a small isolated patch, but I have not pushed it since the rebase would need those serializer and cache conflicts resolved.
MarcZX10 commented 2026-10-19 16:25:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:25:23Z.


Update: I resolved the current-main conflicts while preserving both bufferExtent and bufferDeferredTypeFault, encoded/decoded both fields, and bumped the shader disk-cache format to v41. The combined DescriptorBinding size assertion (696 bytes) and the full agc_driver_draw_unsupported_buffer_type_tests target compile and link successfully on Linux. The runtime test aborts before entering the test because this host lacks LZCNT, BMI1/BMI2, MOVBE, AVX2, and FMA. I replaced the malformed inactive fixture instruction with s_mov_b64 exec, 0, so the load remains in the program with no active lanes. Rebased head pushed: bde890a15e.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271957157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6271957157). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T16:25:23Z. --- Update: I resolved the current-main conflicts while preserving both `bufferExtent` and `bufferDeferredTypeFault`, encoded/decoded both fields, and bumped the shader disk-cache format to v41. The combined `DescriptorBinding` size assertion (696 bytes) and the full `agc_driver_draw_unsupported_buffer_type_tests` target compile and link successfully on Linux. The runtime test aborts before entering the test because this host lacks LZCNT, BMI1/BMI2, MOVBE, AVX2, and FMA. I replaced the malformed inactive fixture instruction with `s_mov_b64 exec, 0`, so the load remains in the program with no active lanes. Rebased head pushed: `bde890a15e`.
adriadam10 commented 2026-10-19 17:01:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T17:01:04Z.

Review: CHANGES_REQUESTED


Thanks for the follow-up. The deferral design looks consistent with #6412, and the s_mov_b64 exec, 0 fixture is correctly encoded. One thing to fix:

  • core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:5466 and :5470: CheckFaults() and WriteBackBuffers() now only call bda->CheckFault() when faultChecks is set. This is not specific to deferred fragment faults and changes every BDA user. The copied-writes path (Draw.cpp:1683) calls WriteBackBuffers() whether or not faultChecks is set, so a fault on a draw where prepareAddressBindings left faultChecks false (for example tableFaultsOnly without imageTableFaults/poisonedSrtReads) is no longer reported. Previously it threw. Please restore the unconditional if (bda) bda->CheckFault();. The new case already sets faultChecks through deferredBufferTypeFaults, so nothing else is needed. If you want the skip for a measured reason, scope it and add a test that shows the fault is still reported.

Also note that #6924 and #6683 both take shader disk-cache FormatVersion 41. Whichever lands second has to move to the next free number.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5574951532 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#pullrequestreview-5574951532). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T17:01:04Z. **Review:** CHANGES_REQUESTED --- Thanks for the follow-up. The deferral design looks consistent with #6412, and the `s_mov_b64 exec, 0` fixture is correctly encoded. One thing to fix: - `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:5466` and `:5470`: `CheckFaults()` and `WriteBackBuffers()` now only call `bda->CheckFault()` when `faultChecks` is set. This is not specific to deferred fragment faults and changes every BDA user. The copied-writes path (`Draw.cpp:1683`) calls `WriteBackBuffers()` whether or not `faultChecks` is set, so a fault on a draw where `prepareAddressBindings` left `faultChecks` false (for example `tableFaultsOnly` without `imageTableFaults`/`poisonedSrtReads`) is no longer reported. Previously it threw. Please restore the unconditional `if (bda) bda->CheckFault();`. The new case already sets `faultChecks` through `deferredBufferTypeFaults`, so nothing else is needed. If you want the skip for a measured reason, scope it and add a test that shows the fault is still reported. Also note that #6924 and #6683 both take shader disk-cache `FormatVersion` 41. Whichever lands second has to move to the next free number.
MarcZX10 commented 2026-10-19 17:12:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T17:12:43Z.


Thanks for identifying the regression. I rebased this branch onto current main and restored unconditional bda->CheckFault() calls in both CheckFaults() and WriteBackBuffers() in commit b5e75434b4. I also moved this branch's cache format to 42 in separate commit 487f12f9d6; current main uses 40, while the open #6412, #6488, #6924 and #7395 branches currently propose 41.

On current main 7a015c0946e2f421b7977129dc7fc255a133019b, conventions and the focused target builds pass, and shader_cache_file_read passes. The AGC test aborts before assertions because this host lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA, and I cannot run the required Vulkan validation-layer comparison here. Could you rerun the focused test on this head with validation enabled and compare it with current main?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272870746 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6272870746). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T17:12:43Z. --- Thanks for identifying the regression. I rebased this branch onto current `main` and restored unconditional `bda->CheckFault()` calls in both `CheckFaults()` and `WriteBackBuffers()` in commit `b5e75434b4`. I also moved this branch's cache format to 42 in separate commit `487f12f9d6`; current main uses 40, while the open #6412, #6488, #6924 and #7395 branches currently propose 41. On current main `7a015c0946e2f421b7977129dc7fc255a133019b`, conventions and the focused target builds pass, and `shader_cache_file_read` passes. The AGC test aborts before assertions because this host lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA, and I cannot run the required Vulkan validation-layer comparison here. Could you rerun the focused test on this head with validation enabled and compare it with current main?
ymatrix1 commented 2026-10-19 17:16:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ymatrix1 on 2026-10-19T17:16:46Z.


Ran Kena (PPSA01802) on Windows, RTX 4070 Super, to see whether this PR carries it past Continue.

  • #6412 alone (c050c1755, on 676d42396): reaches the menu; after Continue it stops with compute shader 0x2008b80000: buffer specialization has an unsupported format. That is a typed-buffer format 0 on the same stale V# from #5879, not a TYPE rejection, so a TYPE-only deferral will not get Kena past Continue by itself. Earlier traces on #5879 hit reserved bit, unaligned base and an unreadable range from the same slot.
  • This PR as rebased (b0507123c, on a6dd29b3d): Kena never shows a frame; it stops at startup with indirect register sentinel semantics are not implemented. The base commit a6dd29b3d without this PR stops the same way, so it is not caused by this PR, and I could not evaluate the PR on Kena at that base.
  • Stacking #6412 and this PR: the cherry-pick conflicts in ShaderResources.hpp/.cpp, ShaderAddressResources.cpp, ShaderInfo.hpp, DescriptorBindingBuilder.cpp, ResourceMaterializer.cpp, Recompiler.hpp and ShaderDiskCache.cpp/.hpp, so I did not run the combination.

Suggestion: for Kena the deferral would also have to cover the non-TYPE validations on that slot. I can re-run Kena once #6412 is merged and this PR is rebased on it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272949408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6272949408). Originally posted by [ymatrix1](https://github.com/ymatrix1) on 2026-10-19T17:16:46Z. --- Ran Kena (PPSA01802) on Windows, RTX 4070 Super, to see whether this PR carries it past Continue. - #6412 alone (`c050c1755`, on `676d42396`): reaches the menu; after Continue it stops with `compute shader 0x2008b80000: buffer specialization has an unsupported format`. That is a typed-buffer format 0 on the same stale V# from #5879, not a TYPE rejection, so a TYPE-only deferral will not get Kena past Continue by itself. Earlier traces on #5879 hit reserved bit, unaligned base and an unreadable range from the same slot. - This PR as rebased (`b0507123c`, on `a6dd29b3d`): Kena never shows a frame; it stops at startup with `indirect register sentinel semantics are not implemented`. The base commit `a6dd29b3d` without this PR stops the same way, so it is not caused by this PR, and I could not evaluate the PR on Kena at that base. - Stacking #6412 and this PR: the cherry-pick conflicts in `ShaderResources.hpp/.cpp`, `ShaderAddressResources.cpp`, `ShaderInfo.hpp`, `DescriptorBindingBuilder.cpp`, `ResourceMaterializer.cpp`, `Recompiler.hpp` and `ShaderDiskCache.cpp/.hpp`, so I did not run the combination. Suggestion: for Kena the deferral would also have to cover the non-TYPE validations on that slot. I can re-run Kena once #6412 is merged and this PR is rebased on it.
MarcZX10 commented 2026-10-19 20:27:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T20:27:03Z.


Thanks for the Kena comparison. It confirms the startup failure, “indirect register sentinel semantics are not implemented,” is identical on the PR and its tested base, so this run does not establish a regression or show Kena progressing with this change. I also note that #6412 alone reaches the menu but then stops on typed-buffer format 0, and the stacked combination was not tested because of conflicts. I’ll keep the PR’s claims limited to deferring the guarded TYPE fault and won’t present this as a Kena fix.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6276586545 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6276586545). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-19T20:27:03Z. --- Thanks for the Kena comparison. It confirms the startup failure, “indirect register sentinel semantics are not implemented,” is identical on the PR and its tested base, so this run does not establish a regression or show Kena progressing with this change. I also note that #6412 alone reaches the menu but then stops on typed-buffer format 0, and the stacked combination was not tested because of conflicts. I’ll keep the PR’s claims limited to deferring the guarded TYPE fault and won’t present this as a Kena fix.
MarcZX10 commented 2026-10-20 09:54:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T09:54:51Z.


I merged current main d14a186f46 into #7689 as e5cdc78345, resolving the cache changes by retaining main’s mesh-barycentric serialization and this PR’s deferred-type fields with format version 42. The exact merged tree builds agc_driver_draw_unsupported_buffer_type_tests and shader_cache_file_read_tests; shader_cache_file_read passes 1/1. The AGC runtime test still stops at this host’s CPU feature guard before assertions. Conventions and git diff --check pass on the merge. I updated the Tested section to keep the earlier Kena report explicitly tied to its old head/base; it does not establish a current-head Kena result.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6288299858 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6288299858). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T09:54:51Z. --- I merged current `main` `d14a186f46` into #7689 as `e5cdc78345`, resolving the cache changes by retaining main’s mesh-barycentric serialization and this PR’s deferred-type fields with format version 42. The exact merged tree builds `agc_driver_draw_unsupported_buffer_type_tests` and `shader_cache_file_read_tests`; `shader_cache_file_read` passes 1/1. The AGC runtime test still stops at this host’s CPU feature guard before assertions. Conventions and `git diff --check` pass on the merge. I updated the Tested section to keep the earlier Kena report explicitly tied to its old head/base; it does not establish a current-head Kena result.
oneandonlydean commented 2026-10-20 17:02:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T17:02:23Z.


Thanks for the EXEC fix: s_mov_b64 exec, 0 is a valid encoding now, and the test gets past the recompiler. I ran this head (e5cdc78345) on an RTX 4090 with the test enabled, and it shows two problems:

  1. NamesShaderAndDescriptor fails at recompile: ShaderRecompiler::Recompile: BDA fault function is missing for the active-lane pixel shader. For an eligible buffer the branch sets usesFaultBuffer and SpirvRuntimeBuffer.cpp calls faultIf(..., InvalidDescriptor), but RecordBdaFault / RecordBdaFaultReason in SpirvBdaFault.cpp also require usesDma, which a plain buffer load in a pixel shader doesn't set. So the deferred fault can't be emitted. Linux CI runs this test on lavapipe, so it will fail there too.
  2. InactiveLaneDoesNotFault passes even with the deferral disabled (I seeded deferInvalidBufferTypeFaults with false in ResourceMaterializer.cpp, and the case still passed). With a constant exec = 0, the load is probably folded away, so the buffer never reaches the resource checks. Could you take EXEC from a value the compiler can't fold (for example a user SGPR set to 0), so that the case fails without the deferral?

Separately, the branch conflicts with current main in ShaderResources.cpp (main's new classified / writeOnly lines next to your deferTypeFault argument) and in the ShaderDiskCache.cpp size asserts (IrValue is 128 on main now).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6296485147 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6296485147). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T17:02:23Z. --- Thanks for the EXEC fix: `s_mov_b64 exec, 0` is a valid encoding now, and the test gets past the recompiler. I ran this head (e5cdc78345) on an RTX 4090 with the test enabled, and it shows two problems: 1. **`NamesShaderAndDescriptor` fails at recompile:** `ShaderRecompiler::Recompile: BDA fault function is missing` for the active-lane pixel shader. For an eligible buffer the branch sets `usesFaultBuffer` and `SpirvRuntimeBuffer.cpp` calls `faultIf(..., InvalidDescriptor)`, but `RecordBdaFault` / `RecordBdaFaultReason` in `SpirvBdaFault.cpp` also require `usesDma`, which a plain buffer load in a pixel shader doesn't set. So the deferred fault can't be emitted. Linux CI runs this test on lavapipe, so it will fail there too. 2. **`InactiveLaneDoesNotFault` passes even with the deferral disabled** (I seeded `deferInvalidBufferTypeFaults` with `false` in `ResourceMaterializer.cpp`, and the case still passed). With a constant `exec = 0`, the load is probably folded away, so the buffer never reaches the resource checks. Could you take EXEC from a value the compiler can't fold (for example a user SGPR set to 0), so that the case fails without the deferral? Separately, the branch conflicts with current `main` in `ShaderResources.cpp` (main's new `classified` / `writeOnly` lines next to your `deferTypeFault` argument) and in the `ShaderDiskCache.cpp` size asserts (`IrValue` is 128 on main now).
MarcZX10 commented 2026-10-20 18:06:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T18:06:33Z.


I merged current main (892a4f1328) into this branch and addressed both findings from the exact-head review. Commit ebcc556b01 lets RecordBdaFault and RecordBdaFaultReason use the non-DMA fault-buffer ABI when a fault function exists, emitting the high address word as zero for these 32-bit guest-buffer addresses. Commit 4f855d1cad makes the inactive-lane case load EXEC from zero-valued runtime user SGPRs, so it is not folded away. The cache assertion now reflects the merged IrValue size of 128 bytes; the IrResourcePlan assertion remains 768 bytes.

The focused agc_driver_draw_unsupported_buffer_type_tests target builds successfully, and check_conventions.py --base upstream/main plus git diff --check pass. CTest cannot reach the assertions on this Xeon: the project CPU guard aborts because the host lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA. Could you rerun the focused test on a supported Vulkan host to confirm both the active fault path and inactive-lane behavior on this exact head?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297733061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6297733061). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T18:06:33Z. --- I merged current `main` (`892a4f1328`) into this branch and addressed both findings from the exact-head review. Commit `ebcc556b01` lets `RecordBdaFault` and `RecordBdaFaultReason` use the non-DMA fault-buffer ABI when a fault function exists, emitting the high address word as zero for these 32-bit guest-buffer addresses. Commit `4f855d1cad` makes the inactive-lane case load EXEC from zero-valued runtime user SGPRs, so it is not folded away. The cache assertion now reflects the merged `IrValue` size of 128 bytes; the `IrResourcePlan` assertion remains 768 bytes. The focused `agc_driver_draw_unsupported_buffer_type_tests` target builds successfully, and `check_conventions.py --base upstream/main` plus `git diff --check` pass. CTest cannot reach the assertions on this Xeon: the project CPU guard aborts because the host lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA. Could you rerun the focused test on a supported Vulkan host to confirm both the active fault path and inactive-lane behavior on this exact head?
MarcZX10 commented 2026-10-20 18:09:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T18:09:14Z.


Correction to my earlier note: after checking current main (FormatVersion = 41) and open #6924 (which proposes 42), I changed this branch to format 43 in commit a24ccea56b to avoid the collision. The PR description is updated accordingly. The current-main build of both focused targets passes, shader_cache_file_read passes 1/1, and the unsupported-buffer runtime test still cannot reach assertions on this CPU.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297784092 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6297784092). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T18:09:14Z. --- Correction to my earlier note: after checking current main (`FormatVersion = 41`) and open #6924 (which proposes 42), I changed this branch to format 43 in commit `a24ccea56b` to avoid the collision. The PR description is updated accordingly. The current-main build of both focused targets passes, `shader_cache_file_read` passes 1/1, and the unsupported-buffer runtime test still cannot reach assertions on this CPU.
MarcZX10 commented 2026-10-21 03:25:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T03:25:37Z.


I checked the current diff against this point. Commit b5e75434b49b restores unconditional bda->CheckFault() calls in both CheckFaults() and WriteBackBuffers(), while faultChecks is still used only to decide whether the deferred fragment fault path is armed. That preserves fault reporting for other BDA users. I also moved this branch to cache format 43 to avoid the #6924/#6683 collision. Thanks for identifying both issues.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307259391 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#issuecomment-6307259391). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T03:25:37Z. --- I checked the current diff against this point. Commit `b5e75434b49b` restores unconditional `bda->CheckFault()` calls in both `CheckFaults()` and `WriteBackBuffers()`, while `faultChecks` is still used only to decide whether the deferred fragment fault path is armed. That preserves fault reporting for other BDA users. I also moved this branch to cache format 43 to avoid the #6924/#6683 collision. Thanks for identifying both issues.
adriadam10 commented 2026-10-21 17:34:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T17:34:02Z.

Review: CHANGES_REQUESTED


The new commits address the earlier findings, but main moved and this no longer merges:

  • Conflicts in core/shader/recompiler/ShaderDiskCache.cpp (size asserts next to main's new userDataRegisterReads / remappedDepth1D / flatSlots fields) and in tests/execution/DrawUnsupportedBufferType.cpp.
  • ShaderDiskCache.hpp: main is at FormatVersion = 44 now, the branch sets 43. Needs to be above main's value (45), or the merge lowers it.
  • agc_driver_draw_unsupported_buffer_type_skip_refused (952ddb784, --skip-refused mode of the same test) submits this exact fragment shader and expects the draw to be refused and skipped. With this PR the type-2 V# is deferred to a draw-completion fault instead, so that test no longer exercises a refused draw. It needs a case that is still refused (for example a buffer the defer conditions exclude: written, atomic or formatted), or an updated expectation, while keeping InactiveLaneDoesNotFault and the fault check.

Please merge current main, bump the cache version, and rerun both ctest entries of that test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5603709884 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#pullrequestreview-5603709884). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T17:34:02Z. **Review:** CHANGES_REQUESTED --- The new commits address the earlier findings, but `main` moved and this no longer merges: - Conflicts in `core/shader/recompiler/ShaderDiskCache.cpp` (size asserts next to main's new `userDataRegisterReads` / `remappedDepth1D` / `flatSlots` fields) and in `tests/execution/DrawUnsupportedBufferType.cpp`. - `ShaderDiskCache.hpp`: main is at `FormatVersion = 44` now, the branch sets 43. Needs to be above main's value (45), or the merge lowers it. - `agc_driver_draw_unsupported_buffer_type_skip_refused` (952ddb784, `--skip-refused` mode of the same test) submits this exact fragment shader and expects the draw to be refused and skipped. With this PR the type-2 V# is deferred to a draw-completion fault instead, so that test no longer exercises a refused draw. It needs a case that is still refused (for example a buffer the defer conditions exclude: written, atomic or formatted), or an updated expectation, while keeping `InactiveLaneDoesNotFault` and the fault check. Please merge current `main`, bump the cache version, and rerun both ctest entries of that test.
MarcZX10 commented 2026-10-25 03:35:01 +00:00 (Migrated from github.com)

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

Review: COMMENTED


I rechecked this against current main and the latest review. The PR head remains based on the older cache schema: current main has ShaderDiskCache::FormatVersion = 44, while this branch sets 43. The current tree merge also conflicts in ShaderAddressResources.cpp, DrawUnsupportedBufferType.cpp, and ShaderDiskCache.cpp/.hpp. More importantly, the latest review points out agc_driver_draw_unsupported_buffer_type_skip_refused currently uses the same fragment TYPE 2 V# that this PR defers to draw-completion, so the test may stop verifying refusal; it requests a still-refused case (for example written, atomic, or formatted) and rerunning both CTest modes. I have not changed the branch because these are behavior and cache-compatibility questions that need a carefully reviewed fix, not mechanical conflict resolution. The local compatible-CPU runtime test is also unavailable here due the Xeon missing LZCNT/BMI1/BMI2/MOVBE/AVX2/FMA.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641361764 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#pullrequestreview-5641361764). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T03:35:01Z. **Review:** COMMENTED --- I rechecked this against current `main` and the latest review. The PR head remains based on the older cache schema: current main has `ShaderDiskCache::FormatVersion = 44`, while this branch sets 43. The current tree merge also conflicts in `ShaderAddressResources.cpp`, `DrawUnsupportedBufferType.cpp`, and `ShaderDiskCache.cpp/.hpp`. More importantly, the latest review points out `agc_driver_draw_unsupported_buffer_type_skip_refused` currently uses the same fragment TYPE 2 V# that this PR defers to draw-completion, so the test may stop verifying refusal; it requests a still-refused case (for example written, atomic, or formatted) and rerunning both CTest modes. I have not changed the branch because these are behavior and cache-compatibility questions that need a carefully reviewed fix, not mechanical conflict resolution. The local compatible-CPU runtime test is also unavailable here due the Xeon missing LZCNT/BMI1/BMI2/MOVBE/AVX2/FMA.
adriadam10 commented 2026-10-27 00:49:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T00:49:18Z.

Review: CHANGES_REQUESTED


Checked the current head merged onto main (full Agc/AgcDriver ctest on CI's lavapipe). Not mergeable yet:

  • ResourceMaterializer.cpp (ApplyStaticInterface, defer eligibility): every read-only pixel-stage buffer with plain LoadBufferU32* loads is marked deferred and sets usesFaultBuffer, even when its V# is valid. StencilReplay.cpp:851 rejects any shader with usesFaultBuffer and no guardedSrtSlots, so agc_driver_stencil_replay and agc_driver_stencil_replay_no_gpl fail with "stencil reference export emulation requires a replay-safe pixel shader with late tests"; both pass on main. The deferral has to apply only to a descriptor that is actually invalid (or the replay check has to accept it), without changing what valid draws do.
  • The same eligibility must also be computed in ExtractPlan: materializeTables checks the plan from there, and ApplyStaticInterface runs later, so the draw is still refused at capture. One shared helper for both.
  • materializeTables: the ADD_TID check must apply only to TYPE 0; the type-2 V# in the test has bit 23 set and is rejected as "ADD_TID is only valid for compute shaders" before the deferral is reached.
  • SpirvRuntimeBuffer.cpp/SpirvBdaFault.cpp: record the deferred fault with RecordBdaFaultWords (it handles both fault ABIs) and revert the non-DMA branch in RecordBdaFault/RecordBdaFaultReason: their other callers pass 64-bit addresses, which emits invalid SPIR-V in a shader without DMA where main throws.
  • DrawUnsupportedBufferType.cpp: the fault reports the IR stage (stage=2 for a pixel shader), not 5. ReportsDeferredTypeFault and NamesShaderAndDescriptor can't share a process: after the first failed draw the driver failure is latched and the next draw rethrows it. Run the deferred-fault case as its own ctest entry (e.g. --deferred-fault).

Happy to look again once the first point has a design.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5660983709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#pullrequestreview-5660983709). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-27T00:49:18Z. **Review:** CHANGES_REQUESTED --- Checked the current head merged onto `main` (full Agc/AgcDriver ctest on CI's lavapipe). Not mergeable yet: - `ResourceMaterializer.cpp` (`ApplyStaticInterface`, defer eligibility): every read-only pixel-stage buffer with plain `LoadBufferU32*` loads is marked deferred and sets `usesFaultBuffer`, even when its V# is valid. `StencilReplay.cpp:851` rejects any shader with `usesFaultBuffer` and no `guardedSrtSlots`, so `agc_driver_stencil_replay` and `agc_driver_stencil_replay_no_gpl` fail with "stencil reference export emulation requires a replay-safe pixel shader with late tests"; both pass on `main`. The deferral has to apply only to a descriptor that is actually invalid (or the replay check has to accept it), without changing what valid draws do. - The same eligibility must also be computed in `ExtractPlan`: `materializeTables` checks the plan from there, and `ApplyStaticInterface` runs later, so the draw is still refused at capture. One shared helper for both. - `materializeTables`: the ADD_TID check must apply only to TYPE 0; the type-2 V# in the test has bit 23 set and is rejected as "ADD_TID is only valid for compute shaders" before the deferral is reached. - `SpirvRuntimeBuffer.cpp`/`SpirvBdaFault.cpp`: record the deferred fault with `RecordBdaFaultWords` (it handles both fault ABIs) and revert the non-DMA branch in `RecordBdaFault`/`RecordBdaFaultReason`: their other callers pass 64-bit addresses, which emits invalid SPIR-V in a shader without DMA where `main` throws. - `DrawUnsupportedBufferType.cpp`: the fault reports the IR stage (`stage=2` for a pixel shader), not 5. `ReportsDeferredTypeFault` and `NamesShaderAndDescriptor` can't share a process: after the first failed draw the driver failure is latched and the next draw rethrows it. Run the deferred-fault case as its own ctest entry (e.g. `--deferred-fault`). Happy to look again once the first point has a design.
adriadam10 commented 2026-10-27 02:46:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T02:46:22Z.

Review: CHANGES_REQUESTED


Thanks for keeping it merged with main. e82d0abec6 only merges main, though, and every point of the previous review still applies to it:

  • ResourceMaterializer.cpp:2186-2209 (ApplyStaticInterface): every read-only pixel buffer with plain LoadBufferU32* loads is still marked deferred and sets usesFaultBuffer, even when its V# is valid. StencilReplaySafe (StencilReplay.cpp:852) then refuses the shader, so agc_driver_stencil_replay and agc_driver_stencil_replay_no_gpl fail ("stencil reference export emulation requires a replay-safe pixel shader with late tests"). Both pass on main. Valid draws must behave as they do on main. Either arm the deferral only for a descriptor that is actually invalid, or show that replaying a shader that records the deferred fault is safe and let the replay check accept that case.
  • ExtractPlan still doesn't compute the eligibility. materializeTables (:1520) reads it from the plan, which is extracted before ApplyStaticInterface runs, so the draw is still refused at capture. Use one helper for both.
  • materializeTables:1519: the ADD_TID check still runs before the TYPE check. The test's type-2 V# has bit 23 set, so it gets "ADD_TID is only valid for compute shaders" before the deferral is reached. Apply the check to TYPE 0 only.
  • SpirvBdaFault.cpp:79-93: the non-DMA branch in RecordBdaFault/RecordBdaFaultReason is still there. Their other callers pass 64-bit addresses, which would emit invalid SPIR-V in a shader without DMA, where main throws. Record the deferred fault in SpirvRuntimeBuffer.cpp:110 through RecordBdaFaultWords, which handles both fault ABIs.
  • DrawUnsupportedBufferType.cpp:108: the fault reports the IR stage (stage=2 for a pixel shader), not 5. :164-166: the three cases still share one process, and after the first failed draw the driver failure is latched and the next draw rethrows it. Give the deferred-fault case its own ctest entry (for example --deferred-fault).
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661652804 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7689#pullrequestreview-5661652804). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-27T02:46:22Z. **Review:** CHANGES_REQUESTED --- Thanks for keeping it merged with `main`. `e82d0abec6` only merges `main`, though, and every point of the previous review still applies to it: - `ResourceMaterializer.cpp:2186-2209` (`ApplyStaticInterface`): every read-only pixel buffer with plain `LoadBufferU32*` loads is still marked deferred and sets `usesFaultBuffer`, even when its V# is valid. `StencilReplaySafe` (`StencilReplay.cpp:852`) then refuses the shader, so `agc_driver_stencil_replay` and `agc_driver_stencil_replay_no_gpl` fail ("stencil reference export emulation requires a replay-safe pixel shader with late tests"). Both pass on `main`. Valid draws must behave as they do on `main`. Either arm the deferral only for a descriptor that is actually invalid, or show that replaying a shader that records the deferred fault is safe and let the replay check accept that case. - `ExtractPlan` still doesn't compute the eligibility. `materializeTables` (`:1520`) reads it from the plan, which is extracted before `ApplyStaticInterface` runs, so the draw is still refused at capture. Use one helper for both. - `materializeTables:1519`: the ADD_TID check still runs before the TYPE check. The test's type-2 V# has bit 23 set, so it gets "ADD_TID is only valid for compute shaders" before the deferral is reached. Apply the check to TYPE 0 only. - `SpirvBdaFault.cpp:79-93`: the non-DMA branch in `RecordBdaFault`/`RecordBdaFaultReason` is still there. Their other callers pass 64-bit addresses, which would emit invalid SPIR-V in a shader without DMA, where `main` throws. Record the deferred fault in `SpirvRuntimeBuffer.cpp:110` through `RecordBdaFaultWords`, which handles both fault ABIs. - `DrawUnsupportedBufferType.cpp:108`: the fault reports the IR stage (`stage=2` for a pixel shader), not 5. `:164-166`: the three cases still share one process, and after the first failed draw the driver failure is latched and the next draw rethrows it. Give the deferred-fault case its own ctest entry (for example `--deferred-fault`).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/7689:upstream-pr/7689'
git switch 'upstream-pr/7689'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/7689'
git switch 'upstream-pr/7689'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/7689'
git switch 'upstream-pr/7689'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/7689'
git switch 'main'
git merge --squash 'upstream-pr/7689'
git switch 'main'
git merge --ff-only 'upstream-pr/7689'
git switch 'main'
git merge 'upstream-pr/7689'
git push origin 'main'
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!7689
No description provided.