Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
EagleBearerYS:fix/agc-moved-buffer-render-target-cut
Oct 27, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
EagleBearerYS:fix/agc-moved-buffer-render-target-cut

Conversation

@EagleBearerYS

@EagleBearerYS EagleBearerYS commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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 fix(agc): bind a strided buffer's last record only up to the render target it runs into #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 fix(agc): bind a strided buffer's last record only up to the render target it runs into #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 fix(agc): bind a strided buffer's last record only up to the render target it runs into #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 80565c5 (with test(agc): align the array window test's texels at run time #8310 to build) and this PR at f65fda5, 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 test(agc): read the sample order tests' depth through a sampled copy #9056 fixes.
  • python3 tools/check_conventions.py --base origin/main: passed.

Checklist

  • Based on main 27c88a8, and merges cleanly with current main (2abfb1b); 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: fix(agc): bind a strided buffer's last record only up to the render target it runs into #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

…uild does

Since boykopovar#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, and the cached build keeps that size. MovedReadOnlyBuffers
compared it with the descriptor's whole size, so a hit with the same
words took the buffer as moved and rebound all of it, over the render
target.

MovedReadOnlyBuffers takes the draw's target and cuts a read-only buffer
as the build does. The cut lives in ShaderResources::BytesUpToTarget,
which addGuestBuffer, CheckBufferAliases and MovedReadOnlyBuffers call;
a buffer that runs a whole stride or more into the target is not cut and
still fails the alias checks.

agc_driver_graphics checks a cached build whose read-only stride-60,
4-record buffer runs 8 bytes into the target: the same words list
nothing moved, a buffer moved to run 4 bytes in is listed at 236 bytes,
and one moved to run a whole stride in keeps its 240.
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7310 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp L1044-1045
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp L4389-4391
PR 7689 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp L4376-4377

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6194 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6223 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6412 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6959 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6970 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7275 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 7369 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 7410 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8223 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9012 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9020 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9193 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9335 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9356 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9489 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9592 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9674 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9675 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9748 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9891 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 9897 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10049 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10194 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10348 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10435 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10556 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 10678 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11265 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 11557 core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@gdols

gdols commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

NVIDIA, Windows. GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, main 80565c5 (+ #8310 to build), this PR at f65fda5, 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 test(agc): read the sample order tests' depth through a sampled copy #9056.

AI-assisted: yes

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

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

@github-actions github-actions Bot added the agc libSceAgc* label Oct 21, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit 1764e01 into boykopovar:main Oct 27, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants