fix(shader): export valid-mask colors without branching on EXEC #14341

Merged
LeandroLP23 merged 8 commits from upstream-pr/14341 into main 2026-11-14 03:52:34 +00:00
LeandroLP23 commented 2026-11-01 10:06:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-01T10:06:19Z.


What

On Windows, agc_driver_quad_pixel_mask fails in the implicit-LOD case under a partial quad mask, on both AMD and NVIDIA (#14237). The pixel samples the wrong mip level: level 0 on an RTX 5060 Ti, levels 3 and 4 on a Radeon 860M, where level 2 is expected.

The cause is not the demoted helpers. A pixel export with vm set was stored inside if (exec) { ... }. The sampled value is only used inside that branch, so both Windows drivers move the OpImageSampleImplicitLod into it, out of uniform control flow, and the derivatives lose the neighbouring lanes. I checked this by editing the generated SPIR-V by hand on both GPUs:

Variant of the mask-2 module Radeon 860M RTX 5060 Ti
as generated levels 3 / 4 level 0
OpDemoteToHelperInvocation removed levels 3 / 4 -
demote and both OpKills removed levels 3 / 4 -
export branch condition replaced by true level 2 level 2

The fix keeps the EXEC semantics but drops the divergent control flow, only where it matters. A pixel program whose result depends on helper lanes either has neighbourLaneReads set (implicit-LOD samples, ImageQueryLod, DPP/swizzle/permute/readlane/ballot, WQM) or reads an offset barycentric (a GetBuiltin of a sample or centre barycentric kind), which goes through InterpolateAtOffset. In such a program, an MRT export without a color merge now stores select(exec, new, previous) unconditionally. previous is the last color the invocation stored to that output, kept in a Private shadow per output, zero-initialized with OpConstantNull, because the packed and reversed-order output specializations only accept whole stores to the Output variable. A lane with EXEC clear therefore keeps its earlier color, including when a later vm export makes it valid again, and the helper-lane reads stay in uniform control flow. Every other pixel export keeps its EXEC branch as on main, and so do targets with a color merge and the alpha-to-coverage store (in its own branch).

New checks:

  • agc_driver_quad_pixel_mask also runs the sequence from review: red to MRT 0 with EXEC set, then green to MRT 0 with vm and EXEC clear, then a NULL vm done export with EXEC set. It expects red. It passes on main, fails on this PR's first version (52fcd28bba, which stored green), and passes now.
  • agc_shader_quad_mask_no_demote checks that the color store of a pixel program with a live cross-lane read (ds_permute with EXEC left at the live lanes) is not nested in any selection or loop construct, with and without a quad mask. That check needs no GPU. It fails with main's emitter and passes here.
  • The same test checks a pixel program that exports its sample barycentrics with off-centre sample locations: the color store must not be nested either. It failed at 20acd940ce, whose check looked for the offset kinds in the program's input list, which records only the base barycentric.

Tested

  • Windows 11, NVIDIA RTX 5060 Ti: full ctest -j 6 with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, main 26fa1212b8 against 81b3d01f31.

    • main: 2 of 3,265 failed, agc_driver_quad_pixel_mask and agc_driver_vulkan_test_device_no_driver (the elevated-loader case of #14069).
    • This PR: only agc_driver_vulkan_test_device_no_driver failed.
    • The layer was loaded on both runs, and neither log has a VUID- line.
  • Windows 11, AMD Radeon 860M: ctest -R '^(agc_|shader)' (1,217 tests) on 81b3d01f31, same environment.

    • agc_driver_quad_pixel_mask and agc_shader_quad_mask_no_demote pass.
    • 5 fail: agc_driver_mesh, agc_driver_msaa_dcc_srgb_clear_2/4/8 and agc_driver_sample_order_grid_reference. They fail the same way with main's SpirvModuleEmitter.cpp.
    • No VUID- lines, and the layer was loaded.
  • Windows 11, NVIDIA RTX 5060 Ti (621.01), head d35348be5e on main b611e634f7: agc_driver_quad_pixel_mask and agc_shader_memory with the same environment. main: the quad mask test fails; this PR: both pass. The layer was loaded and there are no VUID- lines.

  • Independent runs:

    • DonRyuzaki, Windows, RX 7800 XT (AMD 26.10.1), d35348be5e with #9503 on main c3a5290c7d: agc_driver_sample_order_grid_reference passes 3 of 3 (0 color and 0 depth samples differ), where #9503 alone leaves 42 color samples. agc_driver_quad_pixel_mask passes on main and on this head there.
    • Superseabas, Windows 11, 81b3d01f31: the RTX 5070 Ti (621.01) fails on main and passes with this PR; the Ryzen 7 7700X iGPU (RDNA 2, AMD 24.30.18) passes on both. No VUID- lines.
    • TechLevelZero's NVIDIA bot, RTX 2000 Ada on Linux: 0 new failures and no new validation IDs.

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: Fixes #14237
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5060 Ti, driver 621.01 (32.0.16.2101), Windows 11; AMD Radeon 860M, driver 32.0.13058.8001, Windows 11 (also RTX 5070 Ti and Ryzen 7 7700X iGPU on Windows, and RTX 2000 Ada on Linux, from other contributors)
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5106349177 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14341). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-11-01T10:06:19Z. --- ### What On Windows, `agc_driver_quad_pixel_mask` fails in the implicit-LOD case under a partial quad mask, on both AMD and NVIDIA (#14237). The pixel samples the wrong mip level: level 0 on an RTX 5060 Ti, levels 3 and 4 on a Radeon 860M, where level 2 is expected. The cause is not the demoted helpers. A pixel export with `vm` set was stored inside `if (exec) { ... }`. The sampled value is only used inside that branch, so both Windows drivers move the `OpImageSampleImplicitLod` into it, out of uniform control flow, and the derivatives lose the neighbouring lanes. I checked this by editing the generated SPIR-V by hand on both GPUs: | Variant of the mask-2 module | Radeon 860M | RTX 5060 Ti | |---|---|---| | as generated | levels 3 / 4 | level 0 | | `OpDemoteToHelperInvocation` removed | levels 3 / 4 | - | | demote and both `OpKill`s removed | levels 3 / 4 | - | | export branch condition replaced by `true` | level 2 | level 2 | The fix keeps the EXEC semantics but drops the divergent control flow, only where it matters. A pixel program whose result depends on helper lanes either has `neighbourLaneReads` set (implicit-LOD samples, `ImageQueryLod`, DPP/swizzle/permute/readlane/ballot, WQM) or reads an offset barycentric (a `GetBuiltin` of a sample or centre barycentric kind), which goes through `InterpolateAtOffset`. In such a program, an MRT export without a color merge now stores `select(exec, new, previous)` unconditionally. `previous` is the last color the invocation stored to that output, kept in a `Private` shadow per output, zero-initialized with `OpConstantNull`, because the packed and reversed-order output specializations only accept whole stores to the `Output` variable. A lane with EXEC clear therefore keeps its earlier color, including when a later `vm` export makes it valid again, and the helper-lane reads stay in uniform control flow. Every other pixel export keeps its EXEC branch as on `main`, and so do targets with a color merge and the alpha-to-coverage store (in its own branch). New checks: - `agc_driver_quad_pixel_mask` also runs the sequence from review: red to MRT 0 with EXEC set, then green to MRT 0 with `vm` and EXEC clear, then a NULL `vm done` export with EXEC set. It expects red. It passes on `main`, fails on this PR's first version (`52fcd28bba`, which stored green), and passes now. - `agc_shader_quad_mask_no_demote` checks that the color store of a pixel program with a live cross-lane read (`ds_permute` with EXEC left at the live lanes) is not nested in any selection or loop construct, with and without a quad mask. That check needs no GPU. It fails with `main`'s emitter and passes here. - The same test checks a pixel program that exports its sample barycentrics with off-centre sample locations: the color store must not be nested either. It failed at `20acd940ce`, whose check looked for the offset kinds in the program's input list, which records only the base barycentric. ### Tested - **Windows 11, NVIDIA RTX 5060 Ti:** full `ctest -j 6` with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `main` `26fa1212b8` against `81b3d01f31`. - `main`: 2 of 3,265 failed, `agc_driver_quad_pixel_mask` and `agc_driver_vulkan_test_device_no_driver` (the elevated-loader case of #14069). - This PR: only `agc_driver_vulkan_test_device_no_driver` failed. - The layer was loaded on both runs, and neither log has a `VUID-` line. - **Windows 11, AMD Radeon 860M:** `ctest -R '^(agc_|shader)'` (1,217 tests) on `81b3d01f31`, same environment. - `agc_driver_quad_pixel_mask` and `agc_shader_quad_mask_no_demote` pass. - 5 fail: `agc_driver_mesh`, `agc_driver_msaa_dcc_srgb_clear_2/4/8` and `agc_driver_sample_order_grid_reference`. They fail the same way with `main`'s `SpirvModuleEmitter.cpp`. - No `VUID-` lines, and the layer was loaded. - **Windows 11, NVIDIA RTX 5060 Ti (621.01), head `d35348be5e` on `main` `b611e634f7`:** `agc_driver_quad_pixel_mask` and `agc_shader_memory` with the same environment. `main`: the quad mask test fails; this PR: both pass. The layer was loaded and there are no `VUID-` lines. - **Independent runs:** - DonRyuzaki, Windows, RX 7800 XT (AMD 26.10.1), `d35348be5e` with #9503 on `main` `c3a5290c7d`: `agc_driver_sample_order_grid_reference` passes 3 of 3 (0 color and 0 depth samples differ), where #9503 alone leaves 42 color samples. `agc_driver_quad_pixel_mask` passes on `main` and on this head there. - Superseabas, Windows 11, `81b3d01f31`: the RTX 5070 Ti (621.01) fails on `main` and passes with this PR; the Ryzen 7 7700X iGPU (RDNA 2, AMD 24.30.18) passes on both. No `VUID-` lines. - TechLevelZero's NVIDIA bot, RTX 2000 Ada on Linux: 0 new failures and no new validation IDs. ### 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: Fixes #14237 - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5060 Ti, driver 621.01 (32.0.16.2101), Windows 11; AMD Radeon 860M, driver 32.0.13058.8001, Windows 11 (also RTX 5070 Ti and Ryzen 7 7700X iGPU on Windows, and RTX 2000 Ada on Linux, from other contributors) - [x] AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-11-01 10:14:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T10:14:16Z.

Review: COMMENTED


Reviewed — no blocking findings

The unconditional store is sound on the paths I read: a lane with a clear valid mask is killed at every return unless it is a helper invocation, so its stored value is discarded. One non-blocking question remains about helper invocations.

What I ran

Reviewed head 25eb2a4c36d8d62f6567161fc0e7f0842c256824 against base 26fa1212b82f76dd49cf12d65e445d6ff3e0844c; the precheck merge preview is clean. Environment: Linux x86-64, Python 3.11. I read the full diff and the emitter paths listed under Sources at this head. No local build or shader test was run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14341
python3 -I tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 26fa1212b82f76dd49cf12d65e445d6ff3e0844c --head 25eb2a4c36d8d62f6567161fc0e7f0842c256824 --json
python3 -I tools/pr_test_quality.py --root <git archive of 25eb2a4c36: core/libs, core/shader, docs/dev/debt> --json core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp

The precheck's ABI and test-quality helpers were missing from the PR head tree, so I ran both by hand from the main checkout.

Results

Check Result
git diff --check, conventions and PR template (precheck) Passed
Live dependency and mergeability (precheck) Passed
ABI audit (by hand) Not applicable: no export declaration changed
Test quality (by hand) One possible-unregistered-cpp-test finding for core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp; false positive, the file is registered in core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake
Build and the AGC shader tests Not run (no-build protocol)
conventions_and_pr_template, unedited precheck output
All conventions checks passed.

Findings

Blocking

None found.

Non-blocking

  1. Helper invocations. EmitKillIfPixelValidMaskInactive keeps a helper invocation alive even when its valid mask is clear (SpirvFlowEmitter.cpp#L30-L45). Such a lane now executes the unconditional store, where the EXEC branch previously skipped it. Please state why a value written by a helper lane is not observable on the target, or cover that case in the GPU evidence. This is a question, not a request for a change.

Sources

Not verified

  • The GPU results in the PR (Radeon 860M and RTX 5060 Ti) are author-reported; I did not reproduce them.
  • The build, the AGC shader tests, and the hosted Windows, macOS and relinker jobs (queued or running at review time).
  • The helper-invocation question above.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5727559194 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14341#pullrequestreview-5727559194). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T10:14:16Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The unconditional store is sound on the paths I read: a lane with a clear valid mask is killed at every return unless it is a helper invocation, so its stored value is discarded. One non-blocking question remains about helper invocations. ## What I ran Reviewed head `25eb2a4c36d8d62f6567161fc0e7f0842c256824` against base `26fa1212b82f76dd49cf12d65e445d6ff3e0844c`; the precheck merge preview is clean. Environment: Linux x86-64, Python 3.11. I read the full diff and the emitter paths listed under Sources at this head. No local build or shader test was run. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14341 python3 -I tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 26fa1212b82f76dd49cf12d65e445d6ff3e0844c --head 25eb2a4c36d8d62f6567161fc0e7f0842c256824 --json python3 -I tools/pr_test_quality.py --root <git archive of 25eb2a4c36: core/libs, core/shader, docs/dev/debt> --json core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp ``` The precheck's ABI and test-quality helpers were missing from the PR head tree, so I ran both by hand from the main checkout. ## Results | Check | Result | |---|---| | `git diff --check`, conventions and PR template (precheck) | Passed | | Live dependency and mergeability (precheck) | Passed | | ABI audit (by hand) | Not applicable: no export declaration changed | | Test quality (by hand) | One `possible-unregistered-cpp-test` finding for `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`; false positive, the file is registered in `core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake` | | Build and the AGC shader tests | Not run (no-build protocol) | <details><summary>conventions_and_pr_template, unedited precheck output</summary> ```text All conventions checks passed. ``` </details> ## Findings ### Blocking None found. ### Non-blocking 1. **Helper invocations.** `EmitKillIfPixelValidMaskInactive` keeps a helper invocation alive even when its valid mask is clear ([SpirvFlowEmitter.cpp#L30-L45](https://github.com/boykopovar/AnyPS5/blob/25eb2a4c36d8d62f6567161fc0e7f0842c256824/core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp#L30-L45)). Such a lane now executes the unconditional store, where the EXEC branch previously skipped it. Please state why a value written by a helper lane is not observable on the target, or cover that case in the GPU evidence. This is a question, not a request for a change. ## Sources - Valid mask starts at 1 and is cleared to 0 for an inactive `vm` export: [SpirvModuleEmitter.cpp#L1840-L1841](https://github.com/boykopovar/AnyPS5/blob/25eb2a4c36d8d62f6567161fc0e7f0842c256824/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp#L1840-L1841), [#L2164-L2167](https://github.com/boykopovar/AnyPS5/blob/25eb2a4c36d8d62f6567161fc0e7f0842c256824/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp#L2164-L2167). - Kill of lanes with a clear mask at return, and the empty-block path: [SpirvFlowEmitter.cpp#L97](https://github.com/boykopovar/AnyPS5/blob/25eb2a4c36d8d62f6567161fc0e7f0842c256824/core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp#L97), [SpirvModuleEmitter.cpp#L1921-L1933](https://github.com/boykopovar/AnyPS5/blob/25eb2a4c36d8d62f6567161fc0e7f0842c256824/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp#L1921-L1933). - Scope of the unconditional store (pixel MRT, `vm`, no color merge): [SpirvModuleEmitter.cpp#L2271-L2273](https://github.com/boykopovar/AnyPS5/blob/25eb2a4c36d8d62f6567161fc0e7f0842c256824/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp#L2271-L2273). - Test registration: [agc_shader_memory_tests.cmake](https://github.com/boykopovar/AnyPS5/blob/25eb2a4c36d8d62f6567161fc0e7f0842c256824/core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake). ## Not verified - The GPU results in the PR (Radeon 860M and RTX 5060 Ti) are author-reported; I did not reproduce them. - The build, the AGC shader tests, and the hosted Windows, macOS and relinker jobs (queued or running at review time). - The helper-invocation question above.
CnRJay commented 2026-11-01 19:41:10 +00:00 (Migrated from github.com)

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

Review: COMMENTED


The diagnosis is clear: sinking the sample into the EXEC branch is what breaks the derivatives, and the table of hand-edited modules shows it. The fix is wider than the bug, though, and the PR carries no cost figure for that.

1. It applies to every pixel shader, not only to the shaders that hit the bug. preserveInactive is stage == Pixel && kind == Mrt && no merge for the target. Nothing in it looks at vm, a quad mask, or an implicit-LOD sample. So every ordinary pixel export in every title now gets a Private shadow variable, an OpLoad of it, a 4-wide OpCompositeConstruct of EXEC, an OpSelect, and two stores, where before it had one branch. In the common case (EXEC set for the whole shader, a single export) a driver compiler can usually fold the select away, but only if it can prove EXEC is uniform. The shader here reads EXEC as a runtime value, so on a shader that does s_mov exec or wave-mask work before the export the compiler keeps 4 v_cndmask per export per target and an extra live range. With 8 MRTs that is 32 selects per pixel. The new agc_shader_quad_mask_no_demote test counts nesting, not instructions, so it does not show either.

Please restrict preserveInactive to the cases that need it: a program with a quad mask or demote, an export with vm, or a program that samples with implicit LOD after an EXEC change. Everything else keeps the branch it has on main. If you want it unconditional, show the cost.

2. The SPIR-V and pipeline compile-time cost is not measured. The description tests correctness on four GPUs and runs the full suite, but gives no figure for SPIR-V size or pixel-stage compile time. A before/after of spirv-dis | wc -l and Driver.Draw.prepare ms per frame on one pixel-heavy scene would settle it. Pipeline compile time matters on a cold cache, where every pixel variant is compiled at the first draw.

3. Uninitialized shadow. The first export reads the Private shadow before any store. That is undefined, so a lane with EXEC clear on the first export gets an undefined color, where main's branch left the output undefined as well. Fine for correctness, but state that the previous value is only meaningful after a store, and consider an OpConstantNull initializer so drivers can fold the first select when EXEC is a known constant.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729892866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14341#pullrequestreview-5729892866). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:41:10Z. **Review:** COMMENTED --- The diagnosis is clear: sinking the sample into the EXEC branch is what breaks the derivatives, and the table of hand-edited modules shows it. The fix is wider than the bug, though, and the PR carries no cost figure for that. **1. It applies to every pixel shader, not only to the shaders that hit the bug.** `preserveInactive` is `stage == Pixel && kind == Mrt && no merge for the target`. Nothing in it looks at `vm`, a quad mask, or an implicit-LOD sample. So every ordinary pixel export in every title now gets a `Private` shadow variable, an `OpLoad` of it, a 4-wide `OpCompositeConstruct` of EXEC, an `OpSelect`, and two stores, where before it had one branch. In the common case (EXEC set for the whole shader, a single export) a driver compiler can usually fold the select away, but only if it can prove EXEC is uniform. The shader here reads EXEC as a runtime value, so on a shader that does `s_mov exec` or wave-mask work before the export the compiler keeps 4 `v_cndmask` per export per target and an extra live range. With 8 MRTs that is 32 selects per pixel. The new `agc_shader_quad_mask_no_demote` test counts nesting, not instructions, so it does not show either. Please restrict `preserveInactive` to the cases that need it: a program with a quad mask or demote, an export with `vm`, or a program that samples with implicit LOD after an EXEC change. Everything else keeps the branch it has on `main`. If you want it unconditional, show the cost. **2. The SPIR-V and pipeline compile-time cost is not measured.** The description tests correctness on four GPUs and runs the full suite, but gives no figure for SPIR-V size or pixel-stage compile time. A before/after of `spirv-dis | wc -l` and `Driver.Draw.prepare` ms per frame on one pixel-heavy scene would settle it. Pipeline compile time matters on a cold cache, where every pixel variant is compiled at the first draw. **3. Uninitialized shadow.** The first export reads the `Private` shadow before any store. That is undefined, so a lane with EXEC clear on the first export gets an undefined color, where `main`'s branch left the output undefined as well. Fine for correctness, but state that the `previous` value is only meaningful after a store, and consider an `OpConstantNull` initializer so drivers can fold the first select when EXEC is a known constant.
MarcZX10 commented 2026-11-02 07:49:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T07:49:40Z.

Review: COMMENTED


Reviewed — no blocking findings; the valid-mask export path has no hosted run of its execution test

This PR changes how the SPIR-V emitter writes pixel exports when the shader reads helper lanes. Inactive lanes now keep their previous value through a private shadow variable, instead of branching on EXEC. The Windows run passed three shader cases, but the execution test for this path, QuadPixelMask.cpp, is a stub on Windows and did not run. I read the production change in full.

What I ran

  • Head 20acd940ce94896ade451a0dc142e28c9244ecc3; base 5bae1a4bc2cffc66c13e37ce8e63ae48b1b5dd1e. 4 files, +68/-3: SpirvBackend/src/SpirvModuleEmitter.cpp (+35/-, the export path), SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp (+1), libSceAgcDriver/tests/ShaderMemory.cpp (+28), and libSceAgcDriver/tests/execution/QuadPixelMask.cpp (+7).
  • Read the SpirvModuleEmitter.cpp change in full. When a pixel MRT export is not merged and the shader reads neighbour lanes or non-barycentric inputs, the export writes through a private Select between the new value (active lanes) and the previous value (inactive lanes). The shadow variable is added to the interface list only for SPIR-V 1.4 and later. Otherwise the code keeps the original EXEC branch.
  • Read the ShaderMemory.cpp additions by their names only, and QuadPixelMask.cpp by its names only.
  • Hosted, Windows CTest: 21 of 21 passed. agc_shader_quad_mask_no_demote (Test #1909), agc_shader_result_memo_budget_masked (Test #1913), agc_shader_table_snapshot_reuse_unmasked (Test #1904) and agc_shader_memory (Test #1917) passed. The QuadPixelMask execution test does not appear in the run; on Windows it is a stub unless it is listed in ANYPS5_AGC_EXECUTION_TESTS, and it is not.
  • Read-only checks from the trusted main checkout: diff check and conventions passed. ABI audit not applicable. Stack check: clean, no declared dependencies, no errors.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed stack check: clean; no declared dependencies
ABI audit not applicable no export changed
Four shader cases (hosted, Windows) passed Test #1904, #1909, #1913, #1917
QuadPixelMask execution test (the changed path) not verified an execution stub on Windows; no case in the run
Export path in SpirvModuleEmitter.cpp (read) passed by reading the shadow-variable path is as described; no blocking defect found
Behaviour on hardware and the SPIR-V validator not verified not run here
Negative controls not run no local build
Read-only check output

Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: clean, no declared dependencies, no errors. Hosted: gh api repos/boykopovar/AnyPS5/commits/20acd940ce94896ade451a0dc142e28c9244ecc3/check-runs, and the Windows job log (21 of 21).

Negative control

Not run here. A negative control needs a local build and run of the execution test, and code from this head is not run here.

Findings

Blocking

None from the code read.

Non-blocking

  • The execution test that covers the new path (QuadPixelMask) did not run on Windows. The hosted shader cases that passed do not exercise the valid-mask export on a helper-lane shader. A run of QuadPixelMask on a host that builds the execution tests would close that gap.
  • The shadow variable is a private global that is written on every masked export. Its cost on large shaders was not measured.

Sources

Not verified

  • The QuadPixelMask execution test (stub on Windows).
  • The new path's behaviour on hardware and under the SPIR-V validator.
  • The bodies of the ShaderMemory.cpp additions.

To get this to a good state

  • Nothing blocking. Run QuadPixelMask at this head in hosted CI, or add it to the Windows execution list.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5733417619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14341#pullrequestreview-5733417619). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T07:49:40Z. **Review:** COMMENTED --- # Reviewed — no blocking findings; the valid-mask export path has no hosted run of its execution test This PR changes how the SPIR-V emitter writes pixel exports when the shader reads helper lanes. Inactive lanes now keep their previous value through a private shadow variable, instead of branching on `EXEC`. The Windows run passed three shader cases, but the execution test for this path, `QuadPixelMask.cpp`, is a stub on Windows and did not run. I read the production change in full. ## What I ran - Head `20acd940ce94896ade451a0dc142e28c9244ecc3`; base `5bae1a4bc2cffc66c13e37ce8e63ae48b1b5dd1e`. 4 files, +68/-3: `SpirvBackend/src/SpirvModuleEmitter.cpp` (+35/-, the export path), `SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp` (+1), `libSceAgcDriver/tests/ShaderMemory.cpp` (+28), and `libSceAgcDriver/tests/execution/QuadPixelMask.cpp` (+7). - Read the `SpirvModuleEmitter.cpp` change in full. When a pixel MRT export is not merged and the shader reads neighbour lanes or non-barycentric inputs, the export writes through a private `Select` between the new value (active lanes) and the previous value (inactive lanes). The shadow variable is added to the interface list only for SPIR-V 1.4 and later. Otherwise the code keeps the original `EXEC` branch. - Read the `ShaderMemory.cpp` additions by their names only, and `QuadPixelMask.cpp` by its names only. - Hosted, Windows CTest: 21 of 21 passed. `agc_shader_quad_mask_no_demote` (Test #1909), `agc_shader_result_memo_budget_masked` (Test #1913), `agc_shader_table_snapshot_reuse_unmasked` (Test #1904) and `agc_shader_memory` (Test #1917) passed. The `QuadPixelMask` execution test does not appear in the run; on Windows it is a stub unless it is listed in `ANYPS5_AGC_EXECUTION_TESTS`, and it is not. - Read-only checks from the trusted main checkout: diff check and conventions passed. ABI audit not applicable. Stack check: clean, no declared dependencies, no errors. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | stack check: clean; no declared dependencies | | ABI audit | not applicable | no export changed | | Four shader cases (hosted, Windows) | passed | Test #1904, #1909, #1913, #1917 | | `QuadPixelMask` execution test (the changed path) | not verified | an execution stub on Windows; no case in the run | | Export path in `SpirvModuleEmitter.cpp` (read) | passed by reading | the shadow-variable path is as described; no blocking defect found | | Behaviour on hardware and the SPIR-V validator | not verified | not run here | | Negative controls | not run | no local build | <details><summary>Read-only check output</summary> Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: clean, no declared dependencies, no errors. Hosted: `gh api repos/boykopovar/AnyPS5/commits/20acd940ce94896ade451a0dc142e28c9244ecc3/check-runs`, and the Windows job log (21 of 21). </details> ## Negative control Not run here. A negative control needs a local build and run of the execution test, and code from this head is not run here. ## Findings **Blocking** None from the code read. **Non-blocking** - The execution test that covers the new path (`QuadPixelMask`) did not run on Windows. The hosted shader cases that passed do not exercise the valid-mask export on a helper-lane shader. A run of `QuadPixelMask` on a host that builds the execution tests would close that gap. - The shadow variable is a private global that is written on every masked export. Its cost on large shaders was not measured. ## Sources - Export path: https://github.com/boykopovar/AnyPS5/blob/20acd940ce94896ade451a0dc142e28c9244ecc3/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp - Execution test: https://github.com/boykopovar/AnyPS5/blob/20acd940ce94896ade451a0dc142e28c9244ecc3/core/libs/prx/libSceAgcDriver/tests/execution/QuadPixelMask.cpp - Shader memory test: https://github.com/boykopovar/AnyPS5/blob/20acd940ce94896ade451a0dc142e28c9244ecc3/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp - Windows job log: check-run `windows` on 20acd940ce94896ade451a0dc142e28c9244ecc3 ## Not verified - The `QuadPixelMask` execution test (stub on Windows). - The new path's behaviour on hardware and under the SPIR-V validator. - The bodies of the `ShaderMemory.cpp` additions. ## To get this to a good state - Nothing blocking. Run `QuadPixelMask` at this head in hosted CI, or add it to the Windows execution list.
gabichuuuuu commented 2026-11-07 14:40:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T14:40:59Z.

Review: COMMENTED


A Windows NVIDIA run on a GPU where agc_driver_quad_pixel_mask already passes on main, to check that this change keeps it passing.

Setup: Windows 11 x64, NVIDIA laptop GPU (Turing), driver 610, WinLibs GCC 15.2.0 r7 UCRT, Release, every AGC execution test built. Head 608b3860c7 merged onto main 4e44ed59b2 (clean merge), with main 4e44ed59b2 from the same build directory as the control. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, Selected GPU was the NVIDIA GPU. No validation layer on this machine.

Tree agc_driver_quad_pixel_mask
main 4e44ed59b2 10 of 10
this PR 10 of 10

No pixel (1, 0) channel 0 is 32, expected 96 on either side. This driver is older than 617.42, which #14237 reports as passing, so it does not reproduce the 621.x failure. It does show that this change does not regress Turing.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5812898863 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14341#pullrequestreview-5812898863). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T14:40:59Z. **Review:** COMMENTED --- A Windows NVIDIA run on a GPU where `agc_driver_quad_pixel_mask` already passes on `main`, to check that this change keeps it passing. **Setup:** Windows 11 x64, NVIDIA laptop GPU (Turing), driver 610, WinLibs GCC 15.2.0 r7 UCRT, Release, every AGC execution test built. Head `608b3860c7` merged onto `main` `4e44ed59b2` (clean merge), with `main` `4e44ed59b2` from the same build directory as the control. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`, `Selected GPU` was the NVIDIA GPU. No validation layer on this machine. | Tree | `agc_driver_quad_pixel_mask` | |---|---| | `main` `4e44ed59b2` | 10 of 10 | | this PR | 10 of 10 | No `pixel (1, 0) channel 0 is 32, expected 96` on either side. This driver is older than 617.42, which #14237 reports as passing, so it does not reproduce the 621.x failure. It does show that this change does not regress Turing. AI-assisted: yes.
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!14341
No description provided.