fix(agc): bind a strided buffer's last record only up to the render target it runs into #8224
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8224"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-20T04:34:12Z.
What
A vertex fetch often gets one buffer descriptor per attribute, with its base at the attribute's offset inside the vertex and the vertex size as stride. Such a descriptor's
stride * num_recordstherefore ends up to one stride past the bytes the fetch reads, by the attribute's offset. When the buffer sits right before the current render target, that tail runs a few bytes into the target, and the draw stopped with "shader buffer aliases the render target" although no read reaches the target. In Boggle (CUSA03312) a 4-vertex buffer of stride 60 ended 8 bytes into the 1920x1088 target that follows it in memory.A strided buffer that starts below the render target and runs less than one stride into it is now bound only up to the target. This is the rule the allocation bound from #2912 already applies when the next allocation starts there, with the same assumption: the tail is the part of the last record no fetch reads. The build check (
ShaderResources::addGuestBuffer) and the check repeated for a cached build (CheckBufferAliases) apply it alike. A buffer that runs a whole stride or more into the target still fails. The strided-overhang debt entry records the rule.Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, on
main32e88ad847.agc_driver_graphicshas two new cases in its alias checks: a stride-60, 4-record V# that ends 8 bytes into the render target is accepted, and one that ends 60 bytes into it is still refused. Onmain's code the first case fails ("shader buffer aliases the render target"); with the change both pass.agc_driver,agc_driver_native_msaa_vertex_inputandagc_driver_sample_multisample_targetpass onmainand with the change on the RX 9070 XT. On the UHD 770,agc_driver_sample_multisample_targetfails at its sample-store check on both, as onmain(#6957, fix in #6971).Validation layer: those four tests on
mainand on this branch, on both GPUs, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: noVUID-line in any log. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS, and each log'sSelected GPUline names the GPU of its run.Boggle (CUSA03312), on #6977's branch with local changes for its PS4 render targets: starting a round stopped at the alias above. With this change it shuffles the dice and plays a round, and the traced words show on the board.
tools/check_conventions.py --base origin/mainpasses.21 Oct, after review: the trim applies only to read-only buffers (
!writteninaddGuestBufferandCheckBufferAliases). A written strided V# that runs 8 bytes into the render target still fails as an alias.agc_driver_graphicsgains that case and marks the accepted case read-only. Without the!writtencheck, it fails with "expected graphics rejection: aliases the render target"; with it, it passes, with this branch merged ontomainb77bd5880. The debt entry now says read-only.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T04:41:48Z.
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.
main)core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL806core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL806Some 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.
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by janzezno on 2026-10-20T21:25:13Z.
Linux run on AMD; the Tested section covers Windows only.
Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release,
BUILD_TESTING=ON.mainca74ef217; PR head9d659c509applied on top.ctest --test-dir build -R '^agc_driver_graphics$' --repeat until-fail:3: 1 of 1 pass, 3 repeats, as onmain. These tests do not open a Vulkan device.ctest -j12: no new failures. The three that fail also fail onmainon this machine:agc_driver_guest_memory_lifetime(#7849),agc_driver_image_array_window_past_layer_limit(#8361) andagc_driver_tessellation(Mesa, #5444).agc_driver_pixel_interlockandagc_driver_sgpr_pattern_fill_keysalso failed in the first full run; both pass 3 of 3 rerun with the PR and fail intermittently onmainunderctest -j12here.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T01:45:40Z.
@savvaniss thanks, the rule fits the per-attribute vertex fetch case: the overhang is the attribute offset, so the trimmed range never drops a byte a fetch reads.
One question: the trim also applies when the buffer is written (
writtenis known in bothaddGuestBufferandCheckBufferAliases). For a store, the reasoning "no fetch reads the tail" doesn't carry over: a strided RW buffer whose last record runs into the render target would now be bound short, and stores to those bytes would be dropped instead of failing as an alias. Could the trim be limited to read-only buffers (!written &&in both conditions)? The case in your description is a vertex fetch, so it should still pass.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-21T07:15:40Z.
@oneandonlydean agreed, and done in
1c0e23afc. Both conditions now start with!written, so a written strided buffer whose last record runs into the render target is bound in full and fails as an alias, as before.agc_driver_graphicsmarks the accepted case read-only. A new case, the same V# marked written, must still fail with "aliases the render target".!writtencheck removed, the test fails with "expected graphics rejection: aliases the render target". With it, the test passes, with the branch merged ontomainb77bd5880.@janzezno thank you for the Linux AMD run.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T07:24:47Z.
@savvaniss thanks, checked on
1c0e23afc: both trims (Draw.cppandShaderResources.cpp) now require!written, and the new written case fails with "aliases the render target". Next is a full CI run on this head.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T10:55:02Z.
@savvaniss, a follow-up to this PR: #9050 makes the moved-buffer check of a cached build (
MovedReadOnlyBuffers) cut a read-only buffer at the render target the wayaddGuestBufferandCheckBufferAliasesnow do. Without it, a cached build holding such a buffer compares the cut size it bound with the descriptor's whole size, so it takes the buffer as moved on every hit: the hit either rebinds all of it over the render target or the draw builds again. The follow-up has a test next to your alias cases. Review welcome.