fix(agc): handle typed vertex descriptors that always fetch zeros #19065

Merged
JJenkx merged 1 commit from upstream-pr/19065 into main 2026-11-21 16:49:12 +00:00
JJenkx commented 2026-11-12 18:26:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-12T18:26:50Z.


What

Typed vertex descriptors that always read zeros could throw or fetch stored data, including a null base that needs no memory access. This implements the constant-zero range cases for strided OOB_SELECT 2 (NUM_RECORDS == 0) and 3 (fewer records than the typed fetch bytes), and allows a null or unaligned address only when the fetch is provably zero.

The host binding uses stride 0 and a four-component 32-bit format of the shader input's numeric class. That preserves zero W for narrow guest formats, instead of acquiring Vulkan's default W of 1. Component selectors still apply. Layout-cache comparisons and draw-recipe proofs account for transitions between live and constant-zero bindings; retained layouts are never mutated. The range helpers return the constant binding's size. Mixed in-range/out-of-range zero-stride select-1 fetches retain their documented limitation; gfx1013 remains unmeasured.

The range semantics follow the external RX 6700 XT (gfx1031) raw-ISA measurements in #8299 and the related #2241 investigation. This PR does not claim a new console/gfx1013 hardware measurement.

Tested

Fresh matched Linux validation, 2026-11-20: main 0af6acc89ea28aabf48733f41624c55ef8413d47 plus the exact five fixture files (private control a50678b6f5f29c101f6e9357b59a40f8a0ca594e) versus main plus the existing PR (private integration 80043105562261b3203ef35a2928469baa2aa69f). Public reviewed head b63c571b544d0d0a887f7493b2a14c7f98fca090 is unchanged. Both private source trees reconstruct exactly from public main and the attached patches/tree hashes; all 74 added/removed production lines match the reviewed public patch.

Both full SDK/relinker/fixture builds pass, with source/configuration/submodules restored. Same seven focused CTest cases: main plus fixtures: 3 passes / 4 expected failures; change: 7 passes. The two CPU failures reach the intended select-2/select-3 record-count refusals; the two GPU range modes fail at the corresponding unsupported fetches, rather than loader errors. This is a negative control, not a passing main suite.

Each of the four device-backed cases per arm independently selects the AMD Radeon RX 6650 XT / RADV and inserts Khronos validation 1.4.363 (compiled Vulkan-Headers version 335). Zero skips, missing layers or VUID- errors. Exact settings include ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer; direct fixtures use the frozen raw SDK first, and bank hashes remain unchanged.

Current-main build, verbose CPU/GPU results, source patches and manifests, 220,779 bytes, SHA-256 396561a100bf33205ea5b466ef17843f9cdd1ea6a4917ebc03cc6b895c45491e. Downloaded archive and all 50 payload hashes verified. No new game, FPS, Windows, macOS or console/gfx1013 result is claimed; earlier independent reports retain their original scope.

Current-main refresh, 2026-11-15: rebased without merge commits onto main 2d74858c14c4, new head b63c571b544d. The sole conflict was the already-coordinated #18287 fixture tail: retain main's ThreadVertexPlanScratch lifetime assertion alongside this PR's shared-pointer diagnostics call. All 74 added/removed production lines are identical to the former public patch; move the unchanged debt entry into the required fragment.

Fresh matched Linux qualification on RX 6650 XT / RADV Mesa 26.2.7, kernel 7.2.14-arch1-1, validation 1.4.363: main plus exact fixtures (8fb51eebe3ff) has 3 passes / 4 expected failures; this head has 7 passes. Same three CPU/mock cases and four physical-GPU cases, including both 109-positive/two-negative range modes and native multisample input. Each arm records four device selections and validation-layer insertions, zero skips and zero VUIDs, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer and ctest -V.

Both full SDK/relinker builds pass; both 836-file frozen banks remain unchanged after tests. Conventions pass. Clean merge-tree against later main e34613c7767c is compatibility evidence only; that later tree was not executed. No new Windows, console/gfx1013 or title/FPS claim.

Evidenced source refresh, full verbose tests, build logs and manifests, SHA-256 d1e1f1715a323bf4b947a0f8f181c22db8dc02e8816e31d6c5c1671f00ab5c2f; downloaded archive and all 33 members verified.

Independent NVIDIA report: @Doorriiaann's run on RTX 3070 (8 GB), driver 610.57.04, Debian 13, validation 1.4.335: this PR at f9d5e37898 passes all nine selected cases three times, including both 109-range vertex checks; the merge-base d4d6b64710 with matched fixtures reproduces the four expected failures three times. The report records no VUID or missing-layer lines. These are the contributor's measurements, not a local rerun.

Linux, GCC 16 Release, RX 6650 XT / RADV Mesa 26.2.6. Matched frozen qualification: upstream main d4d6b6471013c5b43d68102b79547f7b0a98d4f2 plus only the identical fixture sources (a757f20e9d9dbc629060275dcd2d22e299b29e41), against f9d5e3789876c5da6c328b5cf3bf88bacd6cdadd. Main: 3 pass / 4 expected failures (vertex fetch exceeds descriptor record count); change: 7 pass. Both: 0 skipped, 0 VUID errors. Each of the four physical Vulkan cases in each arm records insertion of validation 1.4.363; the other three are CPU/mock cases. Frozen provider banks and fixture binaries were unchanged after both runs. The full SDK libraries and relinker built in both arms. Conventions pass, and a merge-tree check is clean against newer main b2986bd1ced27f6b7eac3854a221f2406158be29. Windows runtime testing was not performed.

Same seven focused cases on main with matched fixtures and on this change, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, validation layer 1.4.363. New execution cases check the shader-written words for all four components: per-vertex and per-instance input; direct and indirect draws; float, narrow, RGB, unsigned and signed formats; null/unaligned zero addresses; selectors 0/1; large first indices; live→zero→live layout transitions; and refusal of in-range null addresses. Each range mode runs 109 positive checks and two negative-address checks. The plan-verification mode repeats them with APS5_VERIFY_DRAW_PLAN=1.

The existing 20 zero-stride cases, CPU graphics/input/validation cases and native multisample vertex-input case are included. The multisample positive fixture now supplies 48 records for its three 16-byte elements instead of a select-3 range shorter than one element. The argument block is aligned at runtime inside a larger 4 KiB-aligned static array for MinGW portability.

Overlap with #9915 is coordinated in that thread. Its nonzero strided fetches past the record count are a separate case; this PR works on main without it. The additional rejection assertions in #9915 need to become positive zero-value coverage when combined with this implementation. #9604 changes diagnostics. No new public export is introduced. The official scan covered 1,718 open PRs. I manually compared all 61 reported shared-file branches at verified heads; no duplicate zero-fetch implementation was found. #18287 has one fixture-tail conflict: retain its scratch-lifetime assertion alongside this fixture's shared-pointer device call and --ranges mode. Its scratch-backed zeroed vector and this early zero-binding path are compatible in scope; neither PR requires the other. #9875 changes nonzero copy windows; keep the zero path ahead of guest-copy planning when combining. The device-heap branches (#7642, #9508, #10193, #13928 and #13929) use DrawVertexAttributes(shader); their eventual composition must use that same live accessor for the new recipe proof. This is a static overlap review; these combinations have not all been built or GPU-tested.

Qualification logs, exact commands, source patch, frozen-bank manifests and full overlap review — SHA-256 774428191afe79a895bfae9dcc513a1f3c72dd0cd856913284eee2ded8c801c6. The downloaded artifact and all 38 members were verified against the upload. No game assets, executables or saves are included. No FPS or native title-unblock claim.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none; no native title-unblock claim
  • GPUs tested: AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.6-arch1.1, Linux 7.2.14-arch1-1
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5282961138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19065). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-12T18:26:50Z. --- ### What Typed vertex descriptors that always read zeros could throw or fetch stored data, including a null base that needs no memory access. This implements the constant-zero range cases for strided `OOB_SELECT` 2 (`NUM_RECORDS == 0`) and 3 (fewer records than the typed fetch bytes), and allows a null or unaligned address only when the fetch is provably zero. The host binding uses stride 0 and a four-component 32-bit format of the shader input's numeric class. That preserves zero W for narrow guest formats, instead of acquiring Vulkan's default W of 1. Component selectors still apply. Layout-cache comparisons and draw-recipe proofs account for transitions between live and constant-zero bindings; retained layouts are never mutated. The range helpers return the constant binding's size. Mixed in-range/out-of-range zero-stride select-1 fetches retain their documented limitation; gfx1013 remains unmeasured. The range semantics follow the external RX 6700 XT (gfx1031) raw-ISA measurements in [#8299](https://github.com/boykopovar/AnyPS5/issues/8299) and the related [#2241](https://github.com/boykopovar/AnyPS5/issues/2241) investigation. This PR does not claim a new console/gfx1013 hardware measurement. ### Tested <!-- codex-current-main-19065-20261120 --> **Fresh matched Linux validation, 2026-11-20:** main `0af6acc89ea28aabf48733f41624c55ef8413d47` plus the exact five fixture files (private control `a50678b6f5f29c101f6e9357b59a40f8a0ca594e`) versus main plus the existing PR (private integration `80043105562261b3203ef35a2928469baa2aa69f`). Public reviewed head `b63c571b544d0d0a887f7493b2a14c7f98fca090` is unchanged. Both private source trees reconstruct exactly from public main and the attached patches/tree hashes; all 74 added/removed production lines match the reviewed public patch. Both full SDK/relinker/fixture builds pass, with source/configuration/submodules restored. Same seven focused CTest cases: **main plus fixtures: 3 passes / 4 expected failures; change: 7 passes**. The two CPU failures reach the intended select-2/select-3 record-count refusals; the two GPU range modes fail at the corresponding unsupported fetches, rather than loader errors. This is a negative control, not a passing main suite. Each of the four device-backed cases per arm independently selects the AMD Radeon RX 6650 XT / RADV and inserts Khronos validation **1.4.363** (compiled Vulkan-Headers version **335**). Zero skips, missing layers or `VUID-` errors. Exact settings include `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer`; direct fixtures use the frozen raw SDK first, and bank hashes remain unchanged. [Current-main build, verbose CPU/GPU results, source patches and manifests](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr19065-main0af6acc8-linux-20261120.tar.gz), 220,779 bytes, SHA-256 `396561a100bf33205ea5b466ef17843f9cdd1ea6a4917ebc03cc6b895c45491e`. Downloaded archive and all 50 payload hashes verified. No new game, FPS, Windows, macOS or console/gfx1013 result is claimed; earlier independent reports retain their original scope. <!-- codex-current-main-19065-20261115 --> **Current-main refresh, 2026-11-15:** rebased without merge commits onto main `2d74858c14c4`, new head `b63c571b544d`. The sole conflict was the already-coordinated #18287 fixture tail: retain main's `ThreadVertexPlanScratch` lifetime assertion alongside this PR's shared-pointer diagnostics call. All 74 added/removed production lines are identical to the former public patch; move the unchanged debt entry into the required fragment. Fresh matched Linux qualification on RX 6650 XT / RADV Mesa 26.2.7, kernel 7.2.14-arch1-1, validation 1.4.363: main plus exact fixtures (`8fb51eebe3ff`) has **3 passes / 4 expected failures**; this head has **7 passes**. Same three CPU/mock cases and four physical-GPU cases, including both 109-positive/two-negative range modes and native multisample input. Each arm records four device selections and validation-layer insertions, zero skips and zero VUIDs, with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer` and `ctest -V`. Both full SDK/relinker builds pass; both 836-file frozen banks remain unchanged after tests. Conventions pass. Clean merge-tree against later main `e34613c7767c` is compatibility evidence only; that later tree was not executed. No new Windows, console/gfx1013 or title/FPS claim. [Evidenced source refresh, full verbose tests, build logs and manifests](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr19065-main2d748-linux-20261115.tar.gz), SHA-256 `d1e1f1715a323bf4b947a0f8f181c22db8dc02e8816e31d6c5c1671f00ab5c2f`; downloaded archive and all 33 members verified. <!-- independent-nvidia-19065-20261112 --> **Independent NVIDIA report:** [@Doorriiaann's run](https://github.com/boykopovar/AnyPS5/pull/19065#issuecomment-6835184670) on RTX 3070 (8 GB), driver 610.57.04, Debian 13, validation 1.4.335: this PR at `f9d5e37898` passes all nine selected cases three times, including both 109-range vertex checks; the merge-base `d4d6b64710` with matched fixtures reproduces the four expected failures three times. The report records no VUID or missing-layer lines. These are the contributor's measurements, not a local rerun. <!-- 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. --> Linux, GCC 16 Release, RX 6650 XT / RADV Mesa 26.2.6. Matched frozen qualification: upstream main `d4d6b6471013c5b43d68102b79547f7b0a98d4f2` plus only the identical fixture sources (`a757f20e9d9dbc629060275dcd2d22e299b29e41`), against `f9d5e3789876c5da6c328b5cf3bf88bacd6cdadd`. Main: **3 pass / 4 expected failures** (`vertex fetch exceeds descriptor record count`); change: **7 pass**. Both: **0 skipped, 0 VUID errors**. Each of the four physical Vulkan cases in each arm records insertion of validation 1.4.363; the other three are CPU/mock cases. Frozen provider banks and fixture binaries were unchanged after both runs. The full SDK libraries and relinker built in both arms. Conventions pass, and a merge-tree check is clean against newer main `b2986bd1ced27f6b7eac3854a221f2406158be29`. Windows runtime testing was not performed. Same seven focused cases on main with matched fixtures and on this change, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer`, validation layer 1.4.363. New execution cases check the shader-written words for all four components: per-vertex and per-instance input; direct and indirect draws; float, narrow, RGB, unsigned and signed formats; null/unaligned zero addresses; selectors 0/1; large first indices; live→zero→live layout transitions; and refusal of in-range null addresses. Each range mode runs 109 positive checks and two negative-address checks. The plan-verification mode repeats them with `APS5_VERIFY_DRAW_PLAN=1`. The existing 20 zero-stride cases, CPU graphics/input/validation cases and native multisample vertex-input case are included. The multisample positive fixture now supplies 48 records for its three 16-byte elements instead of a select-3 range shorter than one element. The argument block is aligned at runtime inside a larger 4 KiB-aligned static array for MinGW portability. Overlap with #9915 is coordinated in that thread. Its nonzero strided fetches past the record count are a separate case; this PR works on main without it. The additional rejection assertions in #9915 need to become positive zero-value coverage when combined with this implementation. #9604 changes diagnostics. No new public export is introduced. The official scan covered 1,718 open PRs. I manually compared all 61 reported shared-file branches at verified heads; no duplicate zero-fetch implementation was found. #18287 has one fixture-tail conflict: retain its scratch-lifetime assertion alongside this fixture's shared-pointer device call and `--ranges` mode. Its scratch-backed `zeroed` vector and this early zero-binding path are compatible in scope; neither PR requires the other. #9875 changes nonzero copy windows; keep the zero path ahead of guest-copy planning when combining. The device-heap branches (#7642, #9508, #10193, #13928 and #13929) use `DrawVertexAttributes(shader)`; their eventual composition must use that same live accessor for the new recipe proof. This is a static overlap review; these combinations have not all been built or GPU-tested. [Qualification logs, exact commands, source patch, frozen-bank manifests and full overlap review](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/agc-known-zero-vertex-f9d5e3789876-linux-20261112.tar.gz) — SHA-256 `774428191afe79a895bfae9dcc513a1f3c72dd0cd856913284eee2ded8c801c6`. The downloaded artifact and all 38 members were verified against the upload. No game assets, executables or saves are included. No FPS or native title-unblock claim. ### 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: none - [x] Fixes: none - [x] Unblocks: none; no native title-unblock claim - [x] GPUs tested: AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.6-arch1.1, Linux 7.2.14-arch1-1 - [x] AI-assisted: yes
MarcZX10 commented 2026-11-19 06:15:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T06:15:38Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head b63c571b544d0d0a887f7493b2a14c7f98fca090 using the pinned repo_read.py reader. No commands or tests were run locally. The qualification results in the PR description are author supplied.

Results

Check Result Note
Changed production logic not run Inspected targeted code and callers
Focused test changes not run Read changed hunks and included tests
Local build or tests not run No execution environment available

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full core/libs/prx/libSceAgcDriver/tests/Graphics.cpp was excluded as too large; only the changed hunk was read through the reader. No build, test, Windows, console, or gfx1013 run was performed here. The remaining changed files were read: VertexInput.hpp, Draw.cpp, tests/VertexInput.cpp, tests/cmake/agc_driver_zero_stride_vertex_fetch_tests.cmake, tests/execution/SampleMultisampleTarget.cpp, tests/execution/ZeroStrideVertexFetch.cpp, and the new debt entry. The PR description, commits, manifest, and prepared diff were also read. files.json was not available through the reader.

To get this to a good state

Nothing is required. Optional: run the focused tests and builds on the new head; the author reports existing Linux and NVIDIA qualification.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5970223783 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19065#pullrequestreview-5970223783). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T06:15:38Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `b63c571b544d0d0a887f7493b2a14c7f98fca090` using the pinned `repo_read.py` reader. No commands or tests were run locally. The qualification results in the PR description are author supplied. ## Results | Check | Result | Note | |---|---|---| | Changed production logic | not run | Inspected targeted code and callers | | Focused test changes | not run | Read changed hunks and included tests | | Local build or tests | not run | No execution environment available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` was excluded as too large; only the changed hunk was read through the reader. No build, test, Windows, console, or gfx1013 run was performed here. The remaining changed files were read: `VertexInput.hpp`, `Draw.cpp`, `tests/VertexInput.cpp`, `tests/cmake/agc_driver_zero_stride_vertex_fetch_tests.cmake`, `tests/execution/SampleMultisampleTarget.cpp`, `tests/execution/ZeroStrideVertexFetch.cpp`, and the new debt entry. The PR description, commits, manifest, and prepared diff were also read. `files.json` was not available through the reader. ## To get this to a good state Nothing is required. Optional: run the focused tests and builds on the new head; the author reports existing Linux and NVIDIA qualification.
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!19065
No description provided.