fix(shader): keep NVIDIA mesh register-window writes coherent #15668

Merged
HenriksApsitis merged 3 commits from upstream-pr/15668 into main 2026-11-08 18:08:29 +00:00
HenriksApsitis commented 2026-11-04 01:48:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HenriksApsitis on 2026-11-04T01:48:26Z.


What

Mark the dedicated NVIDIA mesh vector-window storage buffer Coherent. On the RTX 5070, a relative write that changes a register followed by a relative read and later direct reads can otherwise return stale values. The existing fixture writes the original value back, so it does not catch this case.

Add agc_driver_mesh_vector_window_writes, which changes each relatively addressed value, rereads it, and checks the directly addressed window registers across all four wave64 waves. Preserve the original fixture as the default mode. This is a measured workaround limited to the existing NVIDIA mesh-buffer path, not a change to guest instruction semantics; the responsible driver transformation is not isolated.

This follows the mesh-buffer path introduced by #12233, but does not claim to fix or unblock a retail title. No proprietary inputs were used.

Tested

CachyOS Linux, kernel 7.3.1-1-cachyos, GCC 16.2.1, CMake 4.4.5, SPIRV-Tools enabled. Full-runtime Release configuration; the five relevant execution-test targets and their runtime dependencies built on both revisions.

Base: 1c8c0efc8c41314402e6966da5bef6ea3d639d10. Original renderer-qualified head: af4bd5cf7c9b0bdd53ba31cb4ea19e680dec0a39. The baseline is a separate main worktree with only the new test fixture/CTest registration overlaid, without the production decoration. Its source-built third-party dependencies point to the same checkouts as the candidate; all 26 submodule pins were verified against main.

Physical GPU / case Main Candidate
NVIDIA RTX 5070: five existing window/indexing controls 5/5 passed 15/15 passed, three runs each
NVIDIA RTX 5070: changed-value mesh relative-write regression 0/3 passed; same failure each run 3/3 passed
AMD Ryzen 5 9600X iGPU / RADV: new regression control 3/3 passed 3/3 passed

Every run selected the named physical device and loaded VK_LAYER_KHRONOS_validation, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1. No skipped tests, VUIDs, synchronization hazards, or validation errors were found in either side. NVIDIA driver disk caching was disabled and all caches/TMPDIR were task-owned. The longest observed CTest was 1.72 seconds; CI/lavapipe timing is not claimed.

The unchanged-main regression reports:

mesh vector window: thread 0 read 3 window registers wrong; wrong threads per wave: 64 64 64 64

The candidate reports:

mesh vector window relative write tests passed
100% tests passed, 0 tests failed out of 6

Focused command on each build, with the environment above:

ctest --test-dir <build> -R PATTERN -V --no-tests=error

PATTERN is ^agc_driver_(mesh_vector_window_(waves|writes)|relative_indexing|vector_window_(direct_access|liveness|narrowing))$. Main used --repeat until-pass:3, so the failing new case ran three times; candidate used --repeat until-fail:3. The AMD control selects only the new regression with --repeat until-fail:3.

python3 tools/check_conventions.py --base origin/main and git diff --check passed. A prior independent review approved the exact patch; its full-index patch SHA256 remains ff4c1abd6e37a593bb8036013048a30abfbc8f7a18aa46c6681cdf6e67525792 after rebasing.

The full tools/pr_overlap.py gate examined 1831 open PRs and exited 2 because 34 existing PR branches conflict with main in shared files. This is NOT a clean automatic-overlap result. Every reported branch was manually compared at its fetched head against its merge base: none changes the mesh-window buffer annotation, this regression fixture, or this debt entry. The helper-file changes concern integer fragment outputs, descriptor heaps, mesh-as-compute inputs, depth-bounds push data, parameter deduplication, and image modes; debt-file changes are unrelated entries or whitespace. No dependency was identified.

No retail title, Windows, other NVIDIA driver, performance improvement, or full CI-suite result is claimed. Full Linux/Windows PR builds still require a write-access collaborator to dispatch the upstream workflow.

Windows CI dependency update

The sole Windows failure on the original head was avplayer_http_patched_modules: its CMake wrapper was selected through a guest-client argument, but the host-only owner executable had not been built. This is the existing bug fixed by JJenkx's #15375, not a shader or native Windows compile failure.

Integration head: af7bcf8f98ade011d4cd025fe1a930fe5fd793e3. This head preserves #15375's original commits through a dependency merge. The NVIDIA shader, regression fixture and debt files are unchanged from the previously qualified renderer head. This PR now depends on #15375; no competing wrapper-owner implementation was added.

Verified on CachyOS under /home/hermes:

  • All three new ownership regressions fail against the original runner for the expected ownership/build assertions; all 25 guest-runner tests pass with the dependency.
  • Adjacent host-only target tests: 27 pass. Selector tests: 49 run, 3 existing skips, no failures.
  • A fresh real CMake File API/CTest fixture with Windows-shaped .exe wrapper arguments reproduces the missing-owner COPY_FILE failure with the original runner. With the dependency, the owner and its dependencies are built and all three CTests execute and pass. These fixture binaries are native Linux ELF files, not a claim of native Windows execution.
  • The actual avplayer_http_patched_modules executable builds and its HTTP closure test passes 3/3.
  • The six focused RTX 5070 tests pass again with required Vulkan, validation loaded and shader caches off.
  • Independent review of the exact two-file dependency integration passed. Conventions have zero errors and an existing long-debt-entry warning; whitespace checks pass.

Windows CI on integration head af7bcf8f98ade011d4cd025fe1a930fe5fd793e3 has now passed: Windows job. All latest checks that ran on this head passed; Linux, register-context, edge-watch and write-watch were skipped and are not claimed as executed. The original failed Windows run remains recorded separately.

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: #15375
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070, NVIDIA 615.78.08, CachyOS Linux; AMD Ryzen 5 9600X integrated GPU (RADV RAPHAEL_MENDOCINO), Mesa 26.2.5, CachyOS Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5147440775 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15668). Originally posted by [HenriksApsitis](https://github.com/HenriksApsitis) on 2026-11-04T01:48:26Z. --- ### What Mark the dedicated NVIDIA mesh vector-window storage buffer Coherent. On the RTX 5070, a relative write that changes a register followed by a relative read and later direct reads can otherwise return stale values. The existing fixture writes the original value back, so it does not catch this case. Add agc_driver_mesh_vector_window_writes, which changes each relatively addressed value, rereads it, and checks the directly addressed window registers across all four wave64 waves. Preserve the original fixture as the default mode. This is a measured workaround limited to the existing NVIDIA mesh-buffer path, not a change to guest instruction semantics; the responsible driver transformation is not isolated. This follows the mesh-buffer path introduced by #12233, but does not claim to fix or unblock a retail title. No proprietary inputs were used. ### 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. --> CachyOS Linux, kernel 7.3.1-1-cachyos, GCC 16.2.1, CMake 4.4.5, SPIRV-Tools enabled. Full-runtime Release configuration; the five relevant execution-test targets and their runtime dependencies built on both revisions. Base: `1c8c0efc8c41314402e6966da5bef6ea3d639d10`. Original renderer-qualified head: `af4bd5cf7c9b0bdd53ba31cb4ea19e680dec0a39`. The baseline is a separate main worktree with only the new test fixture/CTest registration overlaid, without the production decoration. Its source-built third-party dependencies point to the same checkouts as the candidate; all 26 submodule pins were verified against main. | Physical GPU / case | Main | Candidate | |---|---|---| | NVIDIA RTX 5070: five existing window/indexing controls | 5/5 passed | 15/15 passed, three runs each | | NVIDIA RTX 5070: changed-value mesh relative-write regression | 0/3 passed; same failure each run | 3/3 passed | | AMD Ryzen 5 9600X iGPU / RADV: new regression control | 3/3 passed | 3/3 passed | Every run selected the named physical device and loaded VK_LAYER_KHRONOS_validation, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1. No skipped tests, VUIDs, synchronization hazards, or validation errors were found in either side. NVIDIA driver disk caching was disabled and all caches/TMPDIR were task-owned. The longest observed CTest was 1.72 seconds; CI/lavapipe timing is not claimed. The unchanged-main regression reports: ```text mesh vector window: thread 0 read 3 window registers wrong; wrong threads per wave: 64 64 64 64 ``` The candidate reports: ```text mesh vector window relative write tests passed 100% tests passed, 0 tests failed out of 6 ``` Focused command on each build, with the environment above: ```sh ctest --test-dir <build> -R PATTERN -V --no-tests=error ``` PATTERN is `^agc_driver_(mesh_vector_window_(waves|writes)|relative_indexing|vector_window_(direct_access|liveness|narrowing))$`. Main used --repeat until-pass:3, so the failing new case ran three times; candidate used --repeat until-fail:3. The AMD control selects only the new regression with --repeat until-fail:3. python3 tools/check_conventions.py --base origin/main and git diff --check passed. A prior independent review approved the exact patch; its full-index patch SHA256 remains ff4c1abd6e37a593bb8036013048a30abfbc8f7a18aa46c6681cdf6e67525792 after rebasing. The full tools/pr_overlap.py gate examined 1831 open PRs and exited 2 because 34 existing PR branches conflict with main in shared files. This is NOT a clean automatic-overlap result. Every reported branch was manually compared at its fetched head against its merge base: none changes the mesh-window buffer annotation, this regression fixture, or this debt entry. The helper-file changes concern integer fragment outputs, descriptor heaps, mesh-as-compute inputs, depth-bounds push data, parameter deduplication, and image modes; debt-file changes are unrelated entries or whitespace. No dependency was identified. No retail title, Windows, other NVIDIA driver, performance improvement, or full CI-suite result is claimed. Full Linux/Windows PR builds still require a write-access collaborator to dispatch the upstream workflow. ### Windows CI dependency update The sole Windows failure on the original head was `avplayer_http_patched_modules`: its CMake wrapper was selected through a guest-client argument, but the host-only owner executable had not been built. This is the existing bug fixed by JJenkx's #15375, not a shader or native Windows compile failure. Integration head: `af7bcf8f98ade011d4cd025fe1a930fe5fd793e3`. This head preserves #15375's original commits through a dependency merge. The NVIDIA shader, regression fixture and debt files are unchanged from the previously qualified renderer head. This PR now depends on #15375; no competing wrapper-owner implementation was added. Verified on CachyOS under `/home/hermes`: - All three new ownership regressions fail against the original runner for the expected ownership/build assertions; all 25 guest-runner tests pass with the dependency. - Adjacent host-only target tests: 27 pass. Selector tests: 49 run, 3 existing skips, no failures. - A fresh real CMake File API/CTest fixture with Windows-shaped `.exe` wrapper arguments reproduces the missing-owner `COPY_FILE` failure with the original runner. With the dependency, the owner and its dependencies are built and all three CTests execute and pass. These fixture binaries are native Linux ELF files, not a claim of native Windows execution. - The actual `avplayer_http_patched_modules` executable builds and its HTTP closure test passes 3/3. - The six focused RTX 5070 tests pass again with required Vulkan, validation loaded and shader caches off. - Independent review of the exact two-file dependency integration passed. Conventions have zero errors and an existing long-debt-entry warning; whitespace checks pass. Windows CI on integration head `af7bcf8f98ade011d4cd025fe1a930fe5fd793e3` has now passed: [Windows job](https://github.com/boykopovar/AnyPS5/actions/runs/41800282657/job/126474162831). All latest checks that ran on this head passed; Linux, register-context, edge-watch and write-watch were skipped and are not claimed as executed. The original failed Windows run remains recorded separately. ### 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: <!-- #PR, or none --> #15375 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> NVIDIA GeForce RTX 5070, NVIDIA 615.78.08, CachyOS Linux; AMD Ryzen 5 9600X integrated GPU (RADV RAPHAEL_MENDOCINO), Mesa 26.2.5, CachyOS Linux - [x] AI-assisted: <!-- yes / no --> 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!15668
No description provided.