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>
…or the GPU A COPY_DATA, DMA_DATA or DUMP_CONST_RAM store of up to 64 KiB that the driver resolves while GPU work is open is recorded into the batch as a vkCmdUpdateBuffer into the host import, and its range becomes a pending write. The next draw's resource capture reads the dumped descriptor table through the flush hook, which submits the batch and waits for the GPU although the driver already holds the bytes. The recorder now keeps the bytes of stores wider than the 64-byte label table too, in record order, and flags them overwritten like table entries when later GPU work writes over them. Recorder::LookupStoredBytes composes a range from the newest store of each dword. It refuses a dword without a store, one a later GPU write covers, a label behind a completion action and a range under a queued label. Everything recorded before the store lands first and the store lands before anything recorded after it, so the bytes are what the next draw reads on the GPU. classifyPendingWrite answers KnownValue for such a range when the caller takes the bytes (captures, cached draw and dispatch validation), so the capture reads them without the wait. Callers that pass no buffer, and every other pending write, sync as before. APS5_NO_STORED_KNOWN_VALUES=1 turns the path off, and APS5_VERIFY_KNOWN_VALUES=1 checks each served word against the GPU's; the [capture] profile line now reports both counts. Monopoly Plus (CUSA03312) dumps 144- to 512-byte descriptor tables from constant RAM about 100 times per frame on its language screen, each followed by a draw whose capture waited about 1 to 2 ms for the GPU. That screen now runs at about 8.3 instead of 6.1 frames per second on an RX 9070 XT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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 |
|
Moved upstream with #11 and #21 as boykopovar#9898 on |
What
A PS4 title that uses the constant engine builds its descriptor tables in constant RAM and dumps them to memory with
DUMP_CONST_RAMbefore each draw. While GPU work is open,preparePacketMemoryresolves such a store (Pm4::ResolveStore, up to 64 KiB, alsoCOPY_DATAandDMA_DATA) andVulkanDevice::WriteLabelOnGpurecords it into the batch as avkCmdUpdateBufferinto the host import. The range is then a pending write. The next draw's resource capture reads the dumped table through the flush hook, which submits the batch and waits for the GPU, although the driver already holds the bytes it stored.This PR lets a capture read those bytes instead of waiting:
LabelTableBytes(64). Wider stores were ranges only (wideLabels). They now keep their bytes and a record sequence too.markOverwrittenflags them like table entries when later GPU work writes over them, and they leave with their batch as before.Recorder::LookupStoredBytescomposes a dword-aligned range from the newest recorded store of each dword. A table entry wins over wide stores, since a wide store erases the table entries it covers when it is noted. The lookup refuses a dword with no store, one a later GPU write covers, a label behind a completion action and any range under a queued label.Driver::classifyPendingWriteanswersKnownValuewith those bytes when the caller passes a buffer for them. Callers that do are the capture's word reads (ShaderMemory),captureStableandvalidateCaptured. Callers that pass none, and every other pending write, sync as before. The store lands after everything recorded before it and before everything recorded after it, so its bytes are what the next draw reads on the GPU. An earlier CPU store to the range is overwritten by it there as well.APS5_NO_STORED_KNOWN_VALUES=1turns the path off. WithAPS5_VERIFY_KNOWN_VALUES=1each served word is also read through the hook and compared. The[capture]profile line now reports those counts; before this they only reached the[copy]line, which a title without copy kernels never prints.Nothing depends on the title: any resolved store, label or constant RAM dump that a capture reads is served the same way.
Tested
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, on boykopovar#6977's head
93eeee014with #8, which this branch stacks on.agc_driver_dumped_constant_capture(new, Vulkan, driver end to end) submits one DCB:DMA_DATAfill, so a batch is open (in this harness each draw runs as its own synced batch);WRITE_CONST_RAMof 36 words and a 144-byteDUMP_CONST_RAMinto guest memory;It checks that the dump landed, that the draw wrote 255 and that the capture was served from the recorded store. It skips when the dump was not recorded on the GPU. It passes on the RX 9070 XT, also with
APS5_VERIFY_KNOWN_VALUES=1. With the path off (APS5_NO_STORED_KNOWN_VALUES=1, today's behaviour) it fails with "the capture of the draw after a constant RAM dump recorded on the GPU waited for the GPU instead of reading the dumped words".agc_recorder_stored_bytes(new,agc_driver_recorder_tests --stored-bytes-only) checks:Validation layer: 28 focused tests on the base and the same 28 plus the two new ones here, on the RX 9070 XT (
ANYPS5_GPU=AMD), withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. They cover recorder stores, pending writes, key stores, unit shadows, draw cache reuse and relocation, label order and waits, gated dispatch capture, store results and vertex ranges. All pass.VUID-vkCmdPipelineBarrier-srcAccessMask-02815(agc_unit_shadow,agc_shadowed_key_stores),VUID-vkBeginCommandBuffer-commandBuffer-00050(agc_driver_partially_resident_pending_stores) andVUID-vkDestroyDevice-device-05137(agc_driver_vertex_target_range_copied).Vulkan devicelines and the driver'sPhysical device selectedlines.was not found but was requested by env var VK_INSTANCE_LAYERS.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 theShaderDiskCache.cpplines of perf(agc): bound vertex-indexed guest buffers by the draw's vertex range #8's commit.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, #5 and #8, plus local stand-ins. Base is that stack, and change is the same stack with this commit cherry-picked.Profile of the base (
APS5_PROFILE_DRAW=1) on the language screen:[hooksync]charges every one of those waits to thecaptureread site.DUMP_CONST_RAMper 10 s, of 144, 256 or 512 bytes.APS5_VERIFY_KNOWN_VALUES=1with the change: 22,709 words served from recorded stores in 80 s, 22,709 verified, 0 mismatches. Capture waits fell to 11 words.Alternating runs,
APS5_TRACE_SUMMARY_EVERY=15with a 120:15 window. Both builds sit on the language screen from about 30 s.shader_compile_and_linkms/framecapture_resourcesms/framedevice_lockms/frameThe worker now waits about 69 ms per frame for the device lock while about 90 ms of GPU work runs per frame. That is the next cost on this screen, and this PR does not address it.
Summary lines of the first pair:
{"commit":"9c5c8619f7ab","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120: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":92,"frame_ms":{"p50":163.553,"p90":169.755,"p99":179.944},"gpu_busy_ms_per_present":97.573,"top_phases_ms_per_frame":{"Driver.Packet":162.891,"Driver.Packet.draw":151.459,"Driver.Draw":151.119,"Driver.Draw.shader_compile_and_link":142.416,"Shader.DrawStage":140.547,"Shader.DrawStage.capture_resources":112.045,"Shader.DrawStage.prepared_invocation":17.515,"Shader.DrawStage.materialize":10.915}}{"commit":"2c09e4328dc6","dirty":false,"env":{...same...},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","presents":125,"frame_ms":{"p50":119.541,"p90":122.234,"p99":126.64},"gpu_busy_ms_per_present":90.018,"top_phases_ms_per_frame":{"Driver.Packet":118.492,"Driver.Packet.device_lock":69.187,"Driver.Packet.draw":44.439,"Driver.Draw":44.12,"Driver.Draw.shader_compile_and_link":35.537,"Shader.DrawStage":33.836,"Shader.DrawStage.prepared_invocation":16.829,"Shader.DrawStage.materialize":9.906}}tools/trace_digest.pyof the same two traces (slices kept before the drop):Driver.Packet87.2,Driver.Draw.shader_compile_and_link78.1,Shader.DrawStage.capture_resources58.1.Driver.Packet50.0,Driver.Packet.device_lock29.4,Driver.Draw.shader_compile_and_link15.8.capture_resourcesis not among them.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)e3841ecdc5plus one; review the top commitedf584d568)🤖 Generated with Claude Code