fix(shader): cull rect-list patches with NaN positions during PPSA38500 loading #28070

Open
lgqdaxia wants to merge 2 commits from upstream-pr/28070 into main
lgqdaxia commented 2026-11-28 11:21:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lgqdaxia on 2026-11-28T11:21:08Z.


What

During PPSA38500 scene loading on Windows, eleven rectangle-list draws in one GPU submission reported invalid positions. Their vertex programs can export NaN in a clip-space position. Reporting a fault for the draw also loses valid rectangles in a mixed draw.

The generated tessellation control shader now discards a source rectangle containing a NaN in X, Y, Z or W by setting its tessellation levels to zero. Other rectangles in the draw still render. The draw snapshots the guest NaN conversion and retention settings before deferred work starts. A guest override keeps the finite-position diagnostic, as do infinite inputs and overflow in the reconstructed corner. AMD vertex shader guidance · Vulkan patch discard

Tested

Windows 11, NVIDIA GeForce RTX 3080 Laptop GPU, driver 621.14. The focused Vulkan test sends one ordinary rectangle and four rectangles marked on different position components in the same draw. It checks each corner, pixel coverage and whether any marked rectangle wrote color. Separate draws exercise infinity and the guest override.

With the upstream production code at 9f028066, the mixed draw failed the finite-position check. At 45811190, the SPIR-V 1.3 and 1.4 cases each covered all 4096 expected pixels, and the four marked patches wrote no color. Infinity and a nondefault NaN mode retained their expected diagnostics. The Khronos validation layer was active in both runs and emitted no Vulkan validation or synchronization errors.

In an offline Windows integration run on the same GPU, all eleven previously failing vertex/fragment shader combinations ran again on the same HDR target with default NaN settings. None reported the rectangle fault. The run reached an outdoor frame with dark foreground geometry and later stopped in guest CPU code. Gameplay remains unverified.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: PPSA38500
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, driver 621.14, Windows 11
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Rectangles with NaN positions are now culled under standard clip controls, preventing them from appearing in rendered output.
    • NaN conversion overrides, infinite positions, and certain invalid corner calculations continue to report finite-position errors.
    • Rect-list draws now respect NaN-related clip-control settings, retaining the finite-position diagnostic when those settings require NaN values to be preserved.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5539587269 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28070). Originally posted by [lgqdaxia](https://github.com/lgqdaxia) on 2026-11-28T11:21:08Z. --- ### What During PPSA38500 scene loading on Windows, eleven rectangle-list draws in one GPU submission reported invalid positions. Their vertex programs can export NaN in a clip-space position. Reporting a fault for the draw also loses valid rectangles in a mixed draw. The generated tessellation control shader now discards a source rectangle containing a NaN in X, Y, Z or W by setting its tessellation levels to zero. Other rectangles in the draw still render. The draw snapshots the guest NaN conversion and retention settings before deferred work starts. A guest override keeps the finite-position diagnostic, as do infinite inputs and overflow in the reconstructed corner. [AMD vertex shader guidance](https://gpuopen.com/learn/rdna-performance-guide/#vertex-shaders) · [Vulkan patch discard](https://docs.vulkan.org/spec/latest/chapters/tessellation.html#tessellation-primitive-discard) ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, NVIDIA GeForce RTX 3080 Laptop GPU, driver 621.14. The focused Vulkan test sends one ordinary rectangle and four rectangles marked on different position components in the same draw. It checks each corner, pixel coverage and whether any marked rectangle wrote color. Separate draws exercise infinity and the guest override. With the upstream production code at `9f028066`, the mixed draw failed the finite-position check. At `45811190`, the SPIR-V 1.3 and 1.4 cases each covered all 4096 expected pixels, and the four marked patches wrote no color. Infinity and a nondefault NaN mode retained their expected diagnostics. The Khronos validation layer was active in both runs and emitted no Vulkan validation or synchronization errors. In an offline Windows integration run on the same GPU, all eleven previously failing vertex/fragment shader combinations ran again on the same HDR target with default NaN settings. None reported the rectangle fault. The run reached an outdoor frame with dark foreground geometry and later stopped in guest CPU code. Gameplay remains unverified. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: PPSA38500 - [x] GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, driver 621.14, Windows 11 - [x] AI-assisted: yes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Rectangles with NaN positions are now culled under standard clip controls, preventing them from appearing in rendered output. * NaN conversion overrides, infinite positions, and certain invalid corner calculations continue to report finite-position errors. * Rect-list draws now respect NaN-related clip-control settings, retaining the finite-position diagnostic when those settings require NaN values to be preserved. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-28 11:38:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T11:38:39Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this; the points below are optional.

What I ran

Reviewed head 458111908e6c537af99e04ba3360515d0d48d552 using the prepared review artifacts and pinned repo_read.py reader. No commands or tests were run; the Windows and Vulkan results in the description are author-reported.

Results

Check Result Note
Changed code review passed All five changed files read
Tests in this review not run Author-reported runs were not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported Windows 11 / RTX 3080 focused Vulkan test and integration run were not run during this review. All changed files listed in manifest.json were read: Draw.cpp, RectListCorner.cpp, PipelineSpecialization.hpp, RectListShaders.cpp, and rect-list-position-nan.md. No changed files were excluded by the manifest; files.json was not available in the review folder.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6097551078 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28070#pullrequestreview-6097551078). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-28T11:38:39Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this; the points below are optional. ## What I ran Reviewed head `458111908e6c537af99e04ba3360515d0d48d552` using the prepared review artifacts and pinned `repo_read.py` reader. No commands or tests were run; the Windows and Vulkan results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All five changed files read | | Tests in this review | not run | Author-reported runs were not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The reported Windows 11 / RTX 3080 focused Vulkan test and integration run were not run during this review. All changed files listed in `manifest.json` were read: `Draw.cpp`, `RectListCorner.cpp`, `PipelineSpecialization.hpp`, `RectListShaders.cpp`, and `rect-list-position-nan.md`. No changed files were excluded by the manifest; `files.json` was not available in the review folder. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-03 06:04:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T06:04:14Z.

Review: APPROVED


I read the diff at 458111908e. Windows 11, GCC 15.2, merged into main at cf556db18c3 together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • agc_driver_rect_list_corner: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (same tree and tests, the changed files of those PRs put back to main's): fails on both GPUs: "rect-list requires finite nondegenerate axis-aligned positions with equal positive W".

The macOS relinker job is red (2026-11-29). This PR doesn't touch the relinker and that job failed the same way on other such PRs around then, but I didn't read its log.

Not checked: PPSA38500 itself.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6164484659 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28070#pullrequestreview-6164484659). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T06:04:14Z. **Review:** APPROVED --- I read the diff at `458111908e`. Windows 11, GCC 15.2, merged into `main` at `cf556db18c3` together with other open PRs (so not an isolated build), with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1` and `VK_LAYER_KHRONOS_validation` on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2). - `agc_driver_rect_list_corner`: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a `VUID-` or `SYNC-HAZARD` line. - Control (same tree and tests, the changed files of those PRs put back to `main`'s): fails on both GPUs: "rect-list requires finite nondegenerate axis-aligned positions with equal positive W". The macOS relinker job is red (2026-11-29). This PR doesn't touch the relinker and that job failed the same way on other such PRs around then, but I didn't read its log. Not checked: PPSA38500 itself. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 20:37:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:37:57Z.

Review: COMMENTED


RectListCorner checks NaN culling and the disabled specialization by editing the generated shader directly. Could a case also go through the driver draw path and change the guest NaN control register between two draws with the same shaders? That would verify that the draw captures the register, uses the right specialization when recorded later, and preserves the fault on the override path.

Source review at 458111908e. The head trial-merges onto 700fae9438. Paired Vulkan execution is pending.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6178079704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28070#pullrequestreview-6178079704). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T20:37:57Z. **Review:** COMMENTED --- `RectListCorner` checks NaN culling and the disabled specialization by editing the generated shader directly. Could a case also go through the driver draw path and change the guest NaN control register between two draws with the same shaders? That would verify that the draw captures the register, uses the right specialization when recorded later, and preserves the fault on the override path. Source review at `458111908e`. The head trial-merges onto `700fae9438`. Paired Vulkan execution is pending. AI-assisted: yes.
ligmaSec commented 2026-12-03 21:50:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:50:51Z.

Review: COMMENTED


The new driver-level test covers the register-capture gap from my earlier review. Both draws reuse the same shader and change the NaN override in the same PM4 submission. The test checks a culled first draw, a finite second draw and the required fault for the reversed override. The current head merges cleanly with main 9896c0a605. The paired rect-list tests and new queued-draw case are scheduled on lavapipe.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6179224911 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28070#pullrequestreview-6179224911). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T21:50:51Z. **Review:** COMMENTED --- The new driver-level test covers the register-capture gap from my earlier review. Both draws reuse the same shader and change the NaN override in the same PM4 submission. The test checks a culled first draw, a finite second draw and the required fault for the reversed override. The current head merges cleanly with `main` `9896c0a605`. The paired rect-list tests and new queued-draw case are scheduled on lavapipe. AI-assisted: yes.
MarcZX10 commented 2026-12-03 22:18:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T22:18:08Z.

Review: APPROVED


Reviewed — looks good

The reviewed changes correctly cull NaN-position rect-list patches while retaining diagnostics for configured NaN handling and other invalid positions.

What I ran

Reviewed head f41bf93c0cfda257f04eb02614dac6b15a38898c using repo_read.py cat and repo_read.py search; no compiler or tests were run. The shader cull and fallback diagnostic are visible in RectListShaders.cpp and the draw-time register snapshot in Draw.cpp.

Results

Check Result Note
Changed-code review passed All seven changed files reviewed
Tests not run Test outcomes in the PR description are author-reported
Build not run No compilation performed

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not independently run the GPU tests or Windows integration scenario. files.json lists no excluded files.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6179585037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/28070#pullrequestreview-6179585037). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-12-03T22:18:08Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed changes correctly cull NaN-position rect-list patches while retaining diagnostics for configured NaN handling and other invalid positions. ## What I ran Reviewed head `f41bf93c0cfda257f04eb02614dac6b15a38898c` using `repo_read.py cat` and `repo_read.py search`; no compiler or tests were run. The shader cull and fallback diagnostic are visible in [RectListShaders.cpp](https://github.com/boykopovar/AnyPS5/blob/f41bf93c0cfda257f04eb02614dac6b15a38898c/core/shader/recompiler/SpirvBackend/src/RectListShaders.cpp#L83) and the draw-time register snapshot in [Draw.cpp](https://github.com/boykopovar/AnyPS5/blob/f41bf93c0cfda257f04eb02614dac6b15a38898c/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp#L770). ## Results | Check | Result | Note | |---|---|---| | Changed-code review | passed | All seven changed files reviewed | | Tests | not run | Test outcomes in the PR description are author-reported | | Build | not run | No compilation performed | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not independently run the GPU tests or Windows integration scenario. `files.json` lists no excluded files. ## To get this to a good state Nothing is required.
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/28070:upstream-pr/28070'
git switch 'upstream-pr/28070'

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