Repository navigation
Conversation
|
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.
|
|
Tested on Minecraft Dungeons II (PPSA16064, UE). Windows 11 (26200), NVIDIA GeForce RTX 5070 (driver 610.88), WinLibs GCC 15.2, Release. Build: With
Verify run ( Rendering. Correct. We took screenshots every 3 s over 90 s of gameplay in both runs: no missing or wrong textures, no flicker, and frames match the base build. First boot with an empty shader cache. It reached gameplay on the first try with these switches and Summary line (second run) |
CnRJay
left a comment
There was a problem hiding this comment.
Stacked on #6946, #5656 and #6632, so this should be reviewed after those land. Notes on the numbers and the design.
- The gain over #6946 is p50 12.2 to 10.9 ms, but
gpu_busy_ms_per_presentgoes from 2.157 to 3.438 (+59%), and p99/max are slightly worse (15.49 to 15.92 ms, 17.89 to 18.81 ms). This moves per-draw descriptor work from the CPU to the GPU. On a 4090 at 1080p that is free; on a card that is already GPU-bound it is a regression. Please run the same pair on a mid-range card (RX 6600 or RTX 3060 class) and in a scene where GPU time is the limit. - One run each in a menu again; no gameplay scene and no repeat to show the spread.
- Known limit: the heap holds every texture it placed until its sweep frees the slot, so heap textures escape the texture cache's budget, and a scene with more than 4096 distinct textures of one kind stops with "the global image heap is full". That is a hard stop on a path meant to be a speed-up. It needs either eviction or a fall back to the per-draw path when the heap fills, and a test for it.
- Known limit: a pre-rasterization layout with an empty set 1 against a heap layout with vertex-visible bindings is a validation error (
VUID-VkGraphicsPipelineCreateInfo-pLibraries-06758), listed in debt. A validation error that gives undefined behaviour on some drivers is not debt; the combination should be rejected or avoided. - 5.7k lines and 98 files including the stacked PRs. Once the stack lands, check whether the heap and the "space reuse" part (which also depends on
APS5_DRAW_PIPELINE) can be two PRs.
|
@CnRJay on splitting the heap from the space reuse: I tried the heap in smaller steps first, and it did not help on its own.
The GPU time and the other points are a separate reply; the Minecraft Dungeons II numbers from @TideOPL are on that side too. LLM assistance used. |
|
@TideOPL thanks, this is very useful. It is the first run on a title that is not Hades II, and also the first on Windows, at 4K, and on a GPU that is not a 4090. Draw pipeline. That matches what the PR moves. Here queue 0 spends about 53 ms per frame in Heap. That is a real regression on this title. Thanks for the verify lines too: 0 wrong slots and 0 differing constants means it is slow but correct. In your slower run, GPU busy goes from about 45 to 60.5 ms per present, and Abort in the base mode ( LLM assistance used. |
|
@TideOPL's run shows the heap 12 to 23% slower on Minecraft Dungeons II at 4K (GPU busy 45 to 60.5 ms per present), correct but slow, and @Raghav314 agrees it's a real regression on a GPU-bound title. @CnRJay's asks stand: a mid-range card and a scene where GPU time is the limit, an eviction or a fall back to the per-draw path when the heap holds 4096 textures, and |
|
@TideOPL I reproduced the Minecraft Dungeons II slowdown with my own dump (PPSA16064 01.100, Linux, RTX 4090, 4K output), at a fixed spot in Squid Coast, and pushed three commits that fix it. With
The first two rows are local builds with extra timing marks, the last is these commits as pushed. GPU time was never the difference; the heap made queue 0's draws slower on the CPU, and the compute queue waited on them (
Hades II with both switches on the same build: 909 presents in 10 s (899 before), p99 13.4 ms (15.9), GPU busy 2.07 ms per present (3.44). Your other points (the trace files and the base-mode abort on LLM assistance used. |
|
@Raghav314 Updated in place: #7002 is now qualified at Current Windows evidence is 99 focused passes (87 actual NVIDIA/AMD GPU, 12 CPU), full builds, and nine AMD DCC failures matching literal main If your adjacent GPU-heap eligibility/read-path change lands first, I will retain this handoff before its new early return. The combined GPU-heap/space-reuse path and your unchanged branch remain untested here. AI-assisted: Codex; author responsible. |
|
007 First Light (PPSA11386 v01.018.000), 4K output. The setup, base and draw-pipeline numbers are in my comment on #6946: #6946 (comment) Head ddb3938; the commits pushed since (
Cold boot with an empty shader cache and no pipeline journal, switches off:
I can rerun with the current head, or with timing marks if you add them. AI-assisted: yes (Claude Code) |
There was a problem hiding this comment.
Tested fab8dc6 on Linux, RTX 5080 (driver 615.78.08), Ryzen 7 7800X3D, stacked as in the body on main 2fab88d, all runs with APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1 APS5_DRAW_PIPELINE=1.
Hades II (PPSA36082) crashes on a first boot with an empty shader cache when APS5_GPU_HEAP=1 is set: SIGSEGV at 17 to 30 s in 4 of 4 runs, before the title screen. The core shows the title calling memcpy with a NULL destination (corrected, see my later comment). The same lib set with the heap off reaches the first area of a new game at 340 s (2 of 2), as do the base and 6946 (2 of 2 each). Warm, the heap runs reach gameplay (3 of 3).
Warm numbers, frames in 10 s, two traces each:
| 6946 | 6947 with the heap | |
|---|---|---|
| Astro's Playroom (PPSA01325), first level | 138, 135 | 84, 83 |
| Hades II, first area | 1122, 1054 | 1192, 1194 |
Captures match and the earlier Playroom flicker is gone (burst of consecutive frames). APS5_VERIFY_GPU_HEAP=1 in Playroom: up to 9,200,002 image slots checked, 0 hold another texture; Hades II: 8 GPU-loaded constant words, 0 differing. Playroom cold-boots into the level. The PR's tests pass on the RTX 5080, a Radeon 610M (RADV) and lavapipe.
…its render pass recordDraw passed every address-based draw to the pass hazard tracker as both an unknown reader and an unknown writer of guest memory. An unknown writer conflicts with any earlier access in the pass, so no address-based draw ever continued the previous draw's pass: each one ended the pass and began a new one, which loads and stores the attachments again. At Resident Evil Village's menu about half of all draws are address-based, and about 590 render passes begin for about 850 draws per frame. A build whose programs only read through the BDA table now reports unknown reads only. The tracker already orders unknown reads behind any recorded range write in the pass and keeps later range writes behind them, so such a draw continues a pass whose earlier draws wrote no guest ranges. Builds with stores through the table, copied writes, or an address lease without a table keep both flags. APS5_NO_ADDRESS_READ_PASSES=1 restores the old behaviour. Render targets reach guest memory only by explicit write-backs, so a read through the table sees the same bytes whether or not the pass breaks. Raghav314's boykopovar#6947 makes the same change inside its GPU descriptor heap, with the read-only fact from boykopovar#6946's recompiler field; this one keeps it in the driver, without a shader cache format change. The idea also comes from fable-void's 5d57298 (wip/new-gpu-path), which orders address-based builds by their known access ranges; this takes the read-only half without his run-time pre-pass bounds.
|
@Raghav314, a question before we build on this. We'd like to add run-time image tables on top of your heap. A T# that a shader loads from a table, at a key it computes, would be looked up on the GPU in a device-side key table: the T# words, an image interface id and a sampler class give the heap slot and view mode. A miss ring is drained after each batch. That replaces the CPU snapshotting and resolving every table record per draw. Resident Evil Village (PPSA01556) snapshots tables of 32,768 records at its menu, about 8 ms each. Its menu's draws are all indirect, which Are image tables, or indirect draws in GPU mode, already on your list? If they are, we'll wait for yours rather than overlap. If not, we'd stack this as a follow-up with |
|
@Raghav314, Windows notes for this stack, from a Windows build of current main merged with this PR's head fab8dc6 (WinLibs GCC, as the Windows job uses): https://github.com/EagleBearerYS/AnyPS5/actions/runs/39008923574
The other driver tests set variables with
Those are the only Windows failures the build and the suite show. |
|
@fma-rc thanks for the runs. I can't reproduce the cold-boot crash here (RTX 4090, 615.78.08): first boots with an empty Hades II needs
On Astro's Playroom (138 to 84 with the heap): a 70:10 trace pair ( LLM assistance used. |
|
@Raghav314, in case they help with the Windows notes above: tested fixes for all nine thread_locals are on EagleBearerYS/AnyPS5
Both move the scratch into |
|
@EagleBearerYS thanks, I took your three commits as they are: bdeb1ad is on #6946 (d63a804) and all three are on this PR (27d2b5e). On Linux the Image tables and indirect draws in GPU mode are not on my list, so go ahead with them as a follow-up with LLM assistance used. |
|
Thanks! We'll do image tables and indirect draws in GPU mode as a follow-up with |
|
@Amoenus thanks for checking. I don't see an ordering constraint from this side. The The early return LLM assistance used. |
|
@Raghav314 I have to correct my earlier description of the core. The title does not call an unmapped address: at Playroom 70:10 traces on the same lib set, same scene in the captures (one no-heap run whose window landed at 420 s in another scene is left out). Per frame, from
So both the recording on queue 0 and the GPU time per frame grow with the heap. I can attach the traces if they help. |
|
Rebase handoff — rebased onto current
Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
|
@Raghav314, you mentioned in the dev chat that you'll close this PR in favour of a
|
|
When, and does it replace #6947? Yes, it replaces #6947 wholesale; I'll close #6947 when the new one opens. Expect it in about 1–2 days. The heap itself works, but I'm finishing the GPU descriptor walk on top of it. Right now that's a residency bug with fast-cleared render targets. It will likely be split into a few PRs: the VK_EXT_descriptor_heap heap first, the GPU walk after it. Run-time lookup or CPU resolve? Both, depending on where the T# comes from:
Without VK_EXT_descriptor_heap? It falls back to the current descriptor-set path. The heap only turns on when the device reports the extension, and the heap tests check for that, so lavapipe CI and other drivers keep running the existing path. Stacking #7642? Yes, that's fine. The table part of #7642 is the piece my heap doesn't cover, so it would fill a gap rather than overlap. Once the heap PR is open, rebase #7642 onto it. The slot table key layout is in |
|
@Raghav314, thanks, that's clear. We'll rebase the table part of #7642 onto your heap PR once it's open, keyed to |
|
@Raghav314, two follow-ups on the slot table, since #7642's table lookups would best go through it rather than a second device table:
|
|
DeviceSlotTableAbi.hpp: right, it's only on my local branch so far; the slot table landed after f911c70. I'll push the branch to my fork once the residency fix I'm on now passes CI, and I'll post the branch name here. How the shader reaches the table: no push data. The heap's ring buffer is already in the root push data (
The shader reads the address from that header and probes the table from one lane. A bucket is 16 dwords:
The ring header also has the counters and the walk-miss flags, which a miss sets so the driver walks that draw on the CPU next time. Table lookups can use the same route: build the key from the table T#'s 8 words plus interface and kind, then probe. One condition: the driver only inserts keys for images it has registered and proven current, and a miss gives the placeholder for that draw plus a walk-miss flag. So table entries need to be registered on the CPU side too, at least the first time each T# is seen. That's the part to coordinate once you have the branch. |
7e06676 to
f901322
Compare
|
@EagleBearerYS, a correction to what I wrote on the 21st:
LLM assistance used. |
What
An opt-in GPU descriptor heap,
APS5_GPU_HEAP=1, so eligible stages stop rebuilding their descriptors on the CPU for every draw. Stacked on the draw pipeline PR (#6946) and #5656 (#6632 is inmainnow); only the last 23 commits are this PR.HeapLookupResolve.comp) submitted before the batch.APS5_DRAW_PIPELINEis also set.APS5_VERIFY_GPU_HEAP=1checks heap slots against the bound textures, builds 1 in N GPU-mode stages again on the CPU path and compares, compares GPU-read constants with the CPU walk, and checks that every binding a heap stage's readers see equals the patched stage result. WithAPS5_VERIFY_DRAW_ENTRIES=1, ring vertex hits are compared with a fresh build.Update (rebased on
main48d61f5)userDataRegisterReadsa second time at the end of the invocation; perf(agc): data-only draw hits compare only the user words a stage reads #5656 already encodes it, so the second copy is gone.EncodeResult), so the journal format goes to 5 (4 is perf(agc): data-only draw hits compare only the user words a stage reads #5656's). The disk cache format is 40.main48d61f5, the linux job of currentbuild.ymlrun locally: configure with SPIRV tools on, test registration check, build, libs, the whole ctest (1537) and conventions. All pass exceptagc_driver_bda_device, which fails on plainmaintoo on this machine.Update (rebased on
maine5f18ea)main. The space reuse check usesmain's read-only rule from perf(agc): let a draw that only reads through the BDA table continue its render pass #7184 (SpirvStoresThroughAddresses); this branch's own rule, from the dropped straight-line SRT walk commit, is gone. Where a render pass may continue,main's condition stands unchanged.main's BDA anchor ranges (perf(shader): look up the BDA range of a user-data pointer once at program entry #5859) stay out of the BDA range cache that GPU constants use.docs/dev/ENVIRONMENT.mdrows forAPS5_GPU_HEAP,APS5_HEAP_SLOT_CAPandAPS5_VERIFY_GPU_HEAP(and in perf(agc): draw finisher pipeline (APS5_DRAW_PIPELINE) #6946 for its switches), sincemainchecks them now.maine5f18ea, the linux job of currentbuild.ymlrun locally: configure with SPIRV tools on, test registration check, build, libs, the whole ctest (1510) and conventions. All pass exceptagc_driver_bda_device, which fails on plainmaintoo on this machine (NVIDIA Xid 109, a context switch timeout, during the test).Update (rebased on
main47a266c)memcpyateboot+0x28fba9wrote to a null destination. Heap variants are now prepared and prebuilt at registration. Hades II cold boot (emptyANYPS5_SHADER_CACHE_DIRand NVIDIA shader cache) now reaches the menu, with no shader prepared at use.FMallocBinned3 Attempt to free an unrecognized pointer, once, in Squid Coast): most likely because only the heap write path applied a draw's own user data and flattened SRT, while data hashing, the unchanged-data check and validation saw the template draw's. Every reader now sees the draw's words. Found with the newAPS5_VERIFY_GPU_HEAPcheck (64+ mismatches before, 0 after); Squid Coast did not crash in three runs since.APS5_HEAP_SLOT_CAP=1(plain and pipelined); Astro's Playroom withAPS5_HEAP_SLOT_CAP=256andAPS5_VERIFY_GPU_HEAP=4fell back once, kept 155-158 presents in 10 s and 0 of 200004 checked slots held another texture.DrawGuestWords, like its other bindings. A vertex stage with tables is no longer kept as a ring variant, since ring hits reuse the inserting draw's template.APS5_GPU_HEAPwas set, compute included, although compute is off the heap. WithAPS5_PROFILE_GPU=1the draws took the same GPU time with the heap on and off (11.95 vs 11.89 ms a frame); the gap was three compute shaders, one of them 4.02 ms a frame against 1.71 ms. The range cache is now only in vertex and fragment stages; that shader is at 1.70 ms and GPU busy is 30.7-31.3 ms per present (34.3-34.6 before, 31.7-33.1 with the heap off).Same machine, both switches,
APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1, one run each, compared with the same switches before today's commits (not with the heap off):APS5_TRACE_SUMMARY_EVERY=10): 861 / 856 / 869 presents in 10 s, p50 11.4-11.6 ms (832-833 at a488793), GPU busy 2.05 ms per present. This was a cold boot; no shader was prepared at use.APS5_DRAW_PIPELINE=1only): 156 / 157 / 156 presents, p50 63.5-64.0 ms, so parity; GPU busy is 34.5 ms per present with the heap and 31.9 ms without, which does not cost frames in this CPU-bound scene. With the range cache fix (last commit): 161-164 presents, p50 59.8-61.3 ms, GPU busy 30.7-31.3 ms.PPSA36082
The base is the draw pipeline PR (ecfd43302) with
APS5_DRAW_PIPELINE=1. In the level UI/menu, addingAPS5_GPU_HEAP=1takes the frame time p50 from 12.2 to 10.9 ms (807 to 899 presents in 10 s). Against #5656 + #6632 alone (469 presents, p50 21.1 ms) the two switches together are 1.92x. The picture is unchanged.Level UI/menu standing still, same machine,
APS5_HOST_IMPORT_MIB=6784 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1(the #6632 spin at its default, 150 us on this 16-thread CPU), noAPS5_PROFILE_*switch,APS5_TRACE_EVENTS=1048576so the traces are whole, shader cache warmed for each build, one run each. The runs are from before the rebase onto currentmain(on f474fb7, same commits otherwise); the rebase had no conflicts.APS5_DRAW_PIPELINE=1:APS5_GPU_HEAP=1 APS5_DRAW_PIPELINE=1:aps5-trace-c05527b38c16-1070518.json.gz - Main
aps5-trace-ecfd43302cbd-1070858.json.gz - PR 'A'
aps5-trace-b23fdf65f521-1071243.json.gz - PR 'A' + B
PPSA16064 (Minecraft Dungeons II)
@TideOPL measured this PR slower than the draw pipeline alone in Squid Coast. Reproduced locally (01.100, 4K output, same machine as below) and fixed by the last three commits. Same standing spot in Squid Coast,
APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1, warm shader cache, trace70:10:APS5_DRAW_PIPELINE=1: 151.7 / 153.0 / 155.9 presents in 10 s over three runs, p50 63.5-64.6 ms.+ APS5_GPU_HEAP=1before the fixes: 129.5 presents, p50 76.4 ms.+ APS5_GPU_HEAP=1at a488793: 152.9 presents, p50 64.5 ms, p99 76.8 ms; GPU busy 36.3 ms per present in all of them.With the fixes, Hades II in the level UI with both switches: 909 presents in 10 s (899 before), p99 13.4 ms (15.9), GPU busy 2.07 ms per present (3.44).
Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090, NVIDIA 615.78.08.
main47a266c, the linux job of currentbuild.ymlrun locally: configure with SPIRV tools on, test registration check, build, libs, the whole ctest (1428) and conventions. All pass. The draw pipeline PR alone on the samemain: 1391, all pass.agc_driver_store_over_untrackedhas been flaky before; it passed in both runs.Earlier, on
mainf474fb7 (before the rebase) with #5656, #6632 and the draw pipeline PR:The linux job of current
build.ymlrun locally on this branch: configure with SPIRV tools on, test registration check, build, libs, and theagc_*andshader_*scope (686 tests): all pass exceptagc_driver_store_over_untracked, which fails the same way onmain. The whole ctest (1313) passed the same way on this change before the last review fixes.With
APS5_GPU_HEAP=1 APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1, theagc_*andshader_*scope: the same, plusagc_driver_draw_cache_relocation(the draw pipeline PR's known limit).APS5_GPU_HEAPwithoutAPS5_DRAW_PIPELINEpassed with onlyagc_driver_store_over_untrackedfailing before the last review fixes.The draw pipeline PR's switched tests and eight sampling tests also run with both switches and
APS5_VERIFY_GPU_HEAP=1(*_gpu_heap).New tests:
agc_driver_heap_draw_sample_heap,_nogpl,_nogpl_heap,agc_driver_heap_compute_sample_heap,_heap_pipelined,agc_driver_bindless_images_heap(a draw and compute stages that sample a texture write the expected texels, with and without pipeline libraries; with the switch the heap takes the sampling fragment and compute stages, while a compute stage without samplers and a sampling vertex stage whose constants are read on the CPU stay off it) andagc_driver_heap_slots_tests(a held slot is not reused, a freed slot moves its generation and its lookup key is revived for the new texture).Cold boot: Hades II boots with a cold Vulkan pipeline cache and a fresh NVIDIA shader disk cache, with and without a pipeline journal, and with an empty
ANYPS5_SHADER_CACHE_DIR; a frozen journal replays all 54 GPU-mode pipelines (0 rejected).At a488793 plus the test update: the
agc_*andshader_*scope passes exceptagc_driver_store_over_untracked(fails onmaintoo), and with both switches alsoagc_driver_draw_cache_relocation; conventions pass.Known limits
APS5_DRAW_PIPELINE=1alone in GTA V (@MichonGoddijn231849, 105.5 vs 126.8 presents) and in Astro's Playroom (@fma-rc). Playroom is at parity on the new head here; GTA V needs a retest.VUID-VkGraphicsPipelineCreateInfo-pLibraries-06758; listed in the technical debt file).Why this is one PR
Getting this to work took several days of builds and Hades II runs: several parts on their own made the frame rate worse, and only the combination below gave the gain.
The heap only helps when the CPU stops walking the stages it serves, so its pieces cannot land one at a time:
Testing other titles
The heap changes how most textured draws bind their images, so it needs testing on more games than Hades II, on NVIDIA and AMD alike. Please post:
APS5_TRACE_SECONDS=70:10 APS5_TRACE_EVENTS=1048576) withAPS5_DRAW_PIPELINE=1and withAPS5_GPU_HEAP=1 APS5_DRAW_PIPELINE=1, both withAPS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1and nothing else changed;APS5_VERIFY_GPU_HEAP=1, the last[heap-slots]and[gpu-heap]lines in the log (any slot holding another texture or any differing constant is a bug), and any Vulkan validation error that names a heap set;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)