Repository navigation
Conversation
A GCN vertex shader reaches its fetch subroutine through s_swappc. The driver links that subroutine into the program, so its buffer loads stay generic guest-buffer loads indexed by v0 rather than lifted vertex attributes. Their V#s describe the whole vertex ring, so every draw bound and, when the draw cache reused a draw at a moved base, snapshotted the ring whole. The resource tracker now proves, per buffer resource, that every access is an IDXEN load whose index is the VertexIndex builtin and whose VGPR offset and SOFFSET are immediates, and records how far past index * stride those loads read (formatted loads count 16 bytes). The value reaches the driver as DescriptorBinding::bufferVertexExtent (shader disk cache format 37). For a direct draw on the vertex path without mesh or tessellation stages, a read-only element with that proof is bound, alias-checked and snapshotted when its V# moves only up to maxIndex * stride plus the extent, rounded up to 16 bytes and never past the V#'s own size. maxIndex is the bound vertex attributes already use: the highest index plus the base vertex, or the last vertex of an auto draw. A recipe hit whose template was bound for another vertex range is a miss. Indirect draws, written elements, swizzled or ADD_TID V#s and any other access keep the whole range. Monopoly Plus (CUSA03312) draws its quads from a 40 MB ring whose base advances 0x60 bytes per draw. Its 0x27ffff0-byte draw snapshots are gone, and its language screen runs at about 6.1 instead of 2.9 frames per second on an RX 9070 XT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 20, 2026
Owner
|
Thanks @savvaniss. boykopovar#6977 is now a draft integration branch, and its own work is split into boykopovar#9429 to boykopovar#9433 (details). The maintainers asked that the branch not land anything without its own review, so could you open this upstream against AI-assisted: yes (Claude Code) 🤖 Generated with Claude Code |
This was referenced Oct 21, 2026
Author
|
Moved upstream as boykopovar#9897, straight on |
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A PS4 vertex shader reads its vertices through a fetch subroutine that it calls with
s_swappc. On boykopovar#6977's branch the driver links that subroutine into the program (LinkUserDataCallees), so its loads stay ordinary guest-buffer loads indexed byv0, not vertex attributes. Their V#s describe the title's whole vertex ring, so each draw binds the ring whole. When the draw cache reuses a draw at a moved base,PrepareDrawBindingssnapshots the ring whole as well. In Monopoly Plus that is 0x27ffff0 bytes per draw, about 870 times per frame.This PR bounds such buffers by the draw's vertex range, as lifted vertex attributes already are (
VertexBufferReadSize):IDXENload whose index is theVertexIndexbuiltin and whose VGPR offset andSOFFSETare immediates. It records how far pastindex * stridethe loads read, with 16 bytes for a formatted load. The value reaches the driver asDescriptorBinding::bufferVertexExtent(shader disk cache format 37).maxIndex * stride + extent. The same limit applies when its V# moves and it is snapshotted. The size is rounded up to 16 bytes and never exceeds the V#'s own size.maxIndexis the one the vertex attributes already use: the highest index plus the base vertex, or the last vertex of an auto draw.DrawRecipeMiss::VertexRange), and the draw then takes the template-hit path.ADD_TIDV#s, and any element with another kind of access.Nothing in it depends on the title. The proof also applies to PS5 vertex shaders that read a buffer by
v5.Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, on boykopovar#6977's head
93eeee014.agc_shader_vertex_index_extents(new) compiles RDNA (indexv5) and GCN (indexv0) vertex shaders and checks the extent reported for each:buffer_load_format_xyzwby the vertex index: 16.buffer_load_dwordx2at offset 8 withSOFFSET4: 20.With the tracker change reverted it fails with "vertex extent 0, expected 16".
agc_driver_vertex_range_bindings(new, mock device) checks the bound size and that each unproven case keeps the whole V#. It buildsShaderResourceswith and without a vertex range. It moves the V# by one quad throughMovedReadOnlyBuffersandPrepareDrawBindingsand checks the snapshot's size and bytes, and it checksBindsVertexRange. With the driver cut reverted it fails with "a read-only element indexed by the vertex index was not cut to the draw's last vertex".agc_driver_vertex_indexed_ring(new, Vulkan) runs an RDNA vertex shader that reads a 64 KiB ring by the vertex index and stores what it read. It checks every value for auto draws from vertex 0 and from vertex 5, and for an indexed draw with base vertex 20. It passes on both GPUs. With the bound made one fetch short it fails with "vertex 7 component 0 is 0", so it exercises the bound on the GPU. A GCN variant is not included: GCN V#s carry 40-bit addresses, and the test's arrays sit above 2^40 on Windows.agc_shader_disk_cachepasses.Validation layer: 28 focused tests on
93eeee014, and the same 28 plus the three new ones on this branch, on both GPUs, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The tests cover draw cache reuse and relocation, draw snapshots, vertex fetch, rect lists, offset indices and write ranges. All pass.VUID-vkDestroyDevice-device-05137, from the unchangedagc_driver_vertex_target_range_copied, on each GPU.was not found but was requested by env var VK_INSTANCE_LAYERS, and each log'sSelected GPUline names the GPU of its run.agc_driver_gpu_indirect_arguments_misaligned_writer_ahead_testsdoes not compile with MinGW on either side ("requested alignment '65536' exceeds object file maximum 8192"). That is unrelated to this change.tools/check_conventions.py --base 93eeee014passes.tools/pr_overlap.pyreports only fix(agc): PS4 display, textures and GCN instructions for CUSA03312 #1, on the two adjacentstatic_assertlines ofShaderDiskCache.cpp. They compose:BufferResource13 from here andImageResource39 from fix(agc): PS4 display, textures and GCN instructions for CUSA03312 #1.Monopoly Plus (CUSA03312), RX 9070 XT,
APS5_RESIDENT_LINEAR=1, on the local PS4 stack the title needs to start: boykopovar#6977's head with #1, #2 and #5 and local stand-ins. Base is that stack. Change is the same stack with this commit cherry-picked. The stack carries the closed boykopovar#8243, and the conflicts were resolved by applying both cuts. Base and change runs alternated.APS5_LOG_BIG_SNAPSHOTS=1: base logs 400 new draw snapshots of+0x27ffff0(the log stops at 400). The change logs none.APS5_TRACE_SUMMARY_EVERY=15over the whole run:On the language screen (one 240:15 and two 120:15 windows each):
device_lockms/framecapture_resourcesms/frameWhat remains on that screen is the per-draw resource capture (
Shader.DrawStage.capture_resources). This PR does not address it.Summary lines of the 240:15 windows on the language screen:
{"commit":"02fc0a86a4fe","dirty":true,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","presents":42,"frame_ms":{"p50":339.4,"p90":433.2,"p99":520.4},"gpu_busy_ms_per_present":98.1,"top_phases_ms_per_frame":{"Driver.Packet":357.2,"Driver.Packet.draw":201.7,"Driver.Packet.device_lock":150.6,"Driver.Draw.shader_compile_and_link":148.1,"Shader.DrawStage.capture_resources":117.1}}. Base is dirty because that prx was built with the experiment's extent logging uncommitted.{"commit":"9c5c8619f7ab","dirty":false,"env":{...same...},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","presents":91,"frame_ms":{"p50":166.6,"p90":168.6,"p99":170.6},"gpu_busy_ms_per_present":97.4,"top_phases_ms_per_frame":{"Driver.Packet":164.7,"Driver.Packet.draw":153.0,"Driver.Draw.shader_compile_and_link":143.7,"Shader.DrawStage.capture_resources":113.6},"trace_dropped":true}. The worker's slice buffer filled after 8.4 s, but its totals are complete (totals_fullfalse).tools/trace_digest.pyof the same two traces:Driver.Packet352.8,Driver.Packet.draw201.6,Driver.Packet.device_lock149.7,Driver.Draw.shader_compile_and_link146.5.Driver.Packet89.5 in the slices kept, and nodevice_lockamong the largest slices.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