fix(agc): size a moved read-only buffer at the render target as its build does #9050

Merged
EagleBearerYS merged 1 commit from upstream-pr/9050 into main 2026-10-27 05:19:07 +00:00
EagleBearerYS commented 2026-10-21 10:54:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T10:54:27Z.


What

A follow-up to #8224. Since #8224, a read-only strided buffer that starts below the render target and runs less than one stride into it is bound only up to the target. addGuestBuffer and CheckBufferAliases apply that cut. ShaderResources::MovedReadOnlyBuffers, the check a cached build makes before it serves a draw, does not:

  • It compares the size the build bound (cut at the target) with the descriptor's whole size, so it takes such a buffer as moved on every hit, even with the same words and target.
  • It then either rebinds all of the buffer, over the render target, or, when its overlap checks see pending writes there, leaves the cached build unused, so the draw builds again.

So, from the code, a cached hit of the Boggle (CUSA03312) draw that #8224 fixed takes its vertex buffer as moved. This wasn't run in the title.

The change:

  • MovedReadOnlyBuffers takes the draw's target and cuts a read-only buffer as the build does.
  • The cut moves into ShaderResources::BytesUpToTarget, which addGuestBuffer, CheckBufferAliases and MovedReadOnlyBuffers all call, each with the target only for a read-only buffer, as #8224's second commit does.
  • A buffer that runs a whole stride or more into the target is not cut, and still fails the alias checks.

Tested

  • agc_driver_graphics, after #8224's alias cases: one cached build whose read-only stride-60, 4-record buffer runs 8 bytes into the render target.
    • The same words list nothing moved.
    • A buffer moved to run 4 bytes in is listed at the target minus 236, with 236 bytes.
    • One moved to run a whole stride (60) in is listed with all 240 bytes.
  • GitHub's runners (run; it tests this commit's tree against a base that differs only in that size line):
    • Red: with only MovedReadOnlyBuffers' size line put back to descriptor.GetSize(), it fails in 3 of 3 runs on Linux and Windows: "a cached build whose strided buffer runs 8 bytes into the render target took it as moved for the same words and target (1 moved, the first 240 bytes)".
    • With the change, agc_driver_graphics passes 10 runs in a row on Linux and Windows.
    • The libc and libkernel suites pass, apart from libc's precise_wait timing test on Linux, which fails with main's code too.
  • Linux on a cloud worker (CI's configuration, lavapipe), the same change on #8224's first head:
    • red in 20 of 20 runs: "a cached build whose strided buffer runs 8 bytes into the render target took it as moved for the same words and target (1 moved, the first 240 bytes)";
    • green in 20 of 20;
    • ^agc: 815 tests, 0 failed.
  • Windows with an NVIDIA GPU, by @gdols (comment): GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, main 80565c594 (with #8310 to build) and this PR at f65fda5c3, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1.
    • agc_driver_graphics passes 3 of 3. With only MovedReadOnlyBuffers' size line put back to descriptor.GetSize(), it fails 3 of 3 with the red line above.
    • As they note, the case runs on mock Vulkan, so the GPU doesn't change it. On the device, ^agc_ gave 870 passed, 3 skipped and 3 failed, the same as on main. They name the three as agc_driver_sample_order*, which they say #9056 fixes.
  • python3 tools/check_conventions.py --base origin/main: passed.

Checklist

  • Based on main 27c88a8d75, and merges cleanly with current main (2abfb1beb4); 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 (none added)
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none (related: #8224)
  • Unblocks: none
  • GPUs tested: lavapipe (Mesa, Linux: GitHub's runner and a cloud worker); the test is a mock-Vulkan resource test, so the Windows runner runs it without a GPU
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4950403291 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9050). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T10:54:27Z. --- ### What A follow-up to #8224. Since #8224, a read-only strided buffer that starts below the render target and runs less than one stride into it is bound only up to the target. `addGuestBuffer` and `CheckBufferAliases` apply that cut. `ShaderResources::MovedReadOnlyBuffers`, the check a cached build makes before it serves a draw, does not: - It compares the size the build bound (cut at the target) with the descriptor's whole size, so it takes such a buffer as moved on every hit, even with the same words and target. - It then either rebinds all of the buffer, over the render target, or, when its overlap checks see pending writes there, leaves the cached build unused, so the draw builds again. So, from the code, a cached hit of the Boggle (CUSA03312) draw that #8224 fixed takes its vertex buffer as moved. This wasn't run in the title. **The change:** - `MovedReadOnlyBuffers` takes the draw's target and cuts a read-only buffer as the build does. - The cut moves into `ShaderResources::BytesUpToTarget`, which `addGuestBuffer`, `CheckBufferAliases` and `MovedReadOnlyBuffers` all call, each with the target only for a read-only buffer, as #8224's second commit does. - A buffer that runs a whole stride or more into the target is not cut, and still fails the alias checks. ### Tested - **`agc_driver_graphics`**, after #8224's alias cases: one cached build whose read-only stride-60, 4-record buffer runs 8 bytes into the render target. - The same words list nothing moved. - A buffer moved to run 4 bytes in is listed at the target minus 236, with 236 bytes. - One moved to run a whole stride (60) in is listed with all 240 bytes. - **GitHub's runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39576905283); it tests this commit's tree against a base that differs only in that size line): - Red: with only `MovedReadOnlyBuffers`' size line put back to `descriptor.GetSize()`, it fails in 3 of 3 runs on Linux and Windows: "a cached build whose strided buffer runs 8 bytes into the render target took it as moved for the same words and target (1 moved, the first 240 bytes)". - With the change, `agc_driver_graphics` passes 10 runs in a row on Linux and Windows. - The libc and libkernel suites pass, apart from libc's `precise_wait` timing test on Linux, which fails with `main`'s code too. - **Linux on a cloud worker** (CI's configuration, lavapipe), the same change on #8224's first head: - red in 20 of 20 runs: "a cached build whose strided buffer runs 8 bytes into the render target took it as moved for the same words and target (1 moved, the first 240 bytes)"; - green in 20 of 20; - `^agc`: 815 tests, 0 failed. - **Windows with an NVIDIA GPU**, by @gdols ([comment](https://github.com/boykopovar/AnyPS5/pull/9050#issuecomment-6318519759)): GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, `main` 80565c594 (with #8310 to build) and this PR at f65fda5c3, with `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`. - `agc_driver_graphics` passes 3 of 3. With only `MovedReadOnlyBuffers`' size line put back to `descriptor.GetSize()`, it fails 3 of 3 with the red line above. - As they note, the case runs on mock Vulkan, so the GPU doesn't change it. On the device, `^agc_` gave 870 passed, 3 skipped and 3 failed, the same as on `main`. They name the three as `agc_driver_sample_order*`, which they say #9056 fixes. - `python3 tools/check_conventions.py --base origin/main`: passed. ### Checklist - [x] Based on `main` 27c88a8d75, and merges cleanly with current `main` (2abfb1beb4); 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 (none added) - [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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none (related: #8224) - [x] Unblocks: none - [x] GPUs tested: lavapipe (Mesa, Linux: GitHub's runner and a cloud worker); the test is a mock-Vulkan resource test, so the Windows runner runs it without a GPU - [x] AI-assisted: yes
gdols commented 2026-10-21 14:26:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gdols on 2026-10-21T14:26:32Z.


NVIDIA, Windows. GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, main 80565c594 (+ #8310 to build), this PR at f65fda5c3, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1.

  • agc_driver_graphics passes 3 of 3. With only MovedReadOnlyBuffers' size line put back to descriptor.GetSize(), it fails 3 of 3 with the message in the description: "a cached build whose strided buffer runs 8 bytes into the render target took it as moved for the same words and target (1 moved, the first 240 bytes)".
  • The case runs on mock Vulkan, so the GPU doesn't change it. On the real device, ^agc_ gives 870 passed, 3 skipped and 3 failed, the same as main; the three are agc_driver_sample_order*, fixed by #9056.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318519759 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9050#issuecomment-6318519759). Originally posted by [gdols](https://github.com/gdols) on 2026-10-21T14:26:32Z. --- NVIDIA, Windows. GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, `main` 80565c594 (+ #8310 to build), this PR at f65fda5c3, `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`. - `agc_driver_graphics` passes 3 of 3. With only `MovedReadOnlyBuffers`' size line put back to `descriptor.GetSize()`, it fails 3 of 3 with the message in the description: "a cached build whose strided buffer runs 8 bytes into the render target took it as moved for the same words and target (1 moved, the first 240 bytes)". - The case runs on mock Vulkan, so the GPU doesn't change it. On the real device, `^agc_` gives 870 passed, 3 skipped and 3 failed, the same as `main`; the three are `agc_driver_sample_order*`, fixed by #9056. AI-assisted: yes
EagleBearerYS commented 2026-10-21 14:32:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T14:32:38Z.


@gdols, thank you for the RTX 3080 run and the revert check. It's now in Tested.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318625225 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9050#issuecomment-6318625225). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T14:32:38Z. --- @gdols, thank you for the RTX 3080 run and the revert check. It's now in Tested.
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!9050
No description provided.