Repository navigation
Conversation
A retail title's world start binds one ray-tracing resolve program per material (`<material>:CS_RaytracingResolve_*`, 801 variants of 16 KiB or more in its pack, about 1 MB of DXIL each). An RDNA2 driver takes 22 - 172 s to build each, the title binds them one after another and waits at every bind, so its world start stood still for 800 - 1 800 s of compiles per run. Leaving out dispatches of pipelines still being built (`XCL_PSO_WAIT_MS`) also leaves out culling passes whose counts an ExecuteIndirect reads next, which hung the GPU (xcl-dev#675). `gpu::effects` reads what a console program can write from its code: buffer, flat, global, scratch and scalar stores and atomics, and the global data share, are memory; image stores and atomics are images; LDS is the group's own. The whole program is read, past an early S_ENDPGM, and anything that does not decode before the end makes the answer unknown. With `XCL_PSO_IMAGE_SKIP=1` (off by default), a bind does not wait for a compute pipeline of 16 KiB or more of console code that writes no memory: it gets the stand-in, its dispatches are left out and the build goes to the workers; once built, binds get the real pipeline. A program that writes memory waits as before: 338 of the 801 resolve variants write no memory, the others write a typed buffer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A compute pipeline is waited for at its first bind, because a dispatch left out would leave its outputs unwritten. That is right for programs that write memory:
XCL_PSO_WAIT_MSgoes on without every late program, also culling passes whose counts anExecuteIndirectreads next, and ends in a GPU hang (#675). But many of the programs a retail title's world start waits on write nothing but images: ray-tracing resolves, one per material, 73 – 118 KiB of console code and about 1 MB of DXIL each, 22 – 172 s apiece in an RDNA2 driver, bound one after another. WithXCL_PSO_IMAGE_SKIP=1binds do not wait for those; everything that writes memory is waited for as before. Off by default. Part of #505 and #1269.What is in it
crates/xcl/src/gpu/effects.rs(new):of(code)reads a program's writes from its instructions. Memory: MUBUF / MTBUF / FLAT / GLOBAL / SCRATCH / SMEM stores and atomics, and the global data share (ds_append/ds_consume/ds_ordered_count/ GWS, any DS op with GDS set). Images: MIMG stores and atomics. LDS is the group's own. The whole program is read, also past an earlys_endpgm; an instruction that does not decode before the end makes the answer unknown (treated as memory).big_and_image_only(blob): the CS of a console container (FSSM or FSPX) with 16 KiB of code or more and no memory write. Not a translator source: translated caches keep their keys.crates/xcl/src/hle/d3d12x/pso_async.rs:image_skip()(XCL_PSO_IMAGE_SKIP=1);image_only(standin)marks a pending pipeline; its binds takeresolve_spared: the real pipeline once built, else the stand-in (its dispatches are left out, as for a late pipeline underXCL_PSO_WAIT_MS) with the build sent to the workers. Nobody waits for it, so the build is not "wanted" and takes its turn among the driver's compiles.crates/xcl/src/hle/d3d12x/real.rs: a compute pipeline whose shader is big and image-only is marked when it is created.gpu::effects::tests(4: images vs memory, code after an early end, GDS, code that does not decode) andpso_async::used_tests::a_bind_does_not_wait_for_a_pipeline_that_writes_only_images(fails without thesparedbranch: the bind waits for the build and the test times out after 5 s).Beside #2118, #2114, #1652, #2001. #2118 moves the wait from the bind to the submit, #2001 to the first
Dispatch; #2114 and #1652 cap how long binds wait and then go on without any late program. None chooses by what the program writes. This one goes on only without programs that write no memory, and can sit on top of any of them. It touchespso_async.rsandreal.rslike #2118; whichever merges first, I rebase.Tested
main6567c5f).cargo test --workspace --no-fail-fast -- --test-threads=4: 997 passed, 5 failed, 45 ignored. The same 5 fail onmain6567c5f in the same session (990 passed, 7 failed, 45 ignored; its two other failures aree2etests that passed in the PR's run):gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 540),hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory(Tests: align XMemVirtualQuery buffers and verify CPU flags #650), andtitle_textures::tests::placed_title_textures_share_vram_and_preserve_pixels,title_textures::tests::transitions_apply_when_their_list_is_submitted,vram::tests::d32s8_targets_take_their_own_size_of_video_memory, which pass when run alone on both. SKIPPED: the six wave32 / wave64 per-lane cases off16_programs_on_the_gpu/f32_programs_on_the_gpu(refused),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).XCL_NETWORK=0, cold driver cache, on a local tree with this change and other open PRs the title needs to reach its world load (XG: fix CopyFromSubresource 7-argument ABI and guard destination span #684, D3D12.X: title texture reads outside the coherent window use the safe copy #751, D3D12.X: render targets on one physical page share its video memory #1182, D3D12.X: tiny sampled textures take 4 KiB heap slots, not 64 KiB tiles #1248, D3D12.X: console UAV clears (#53 / #54) get the slots' PC descriptors #1291, DirectStorage: read a physical-page list again when its request runs #1405): withXCL_PSO_IMAGE_SKIP=1, binds went on without 65 such programs by 733 s, with no device removal and no GPU wait that did not complete. The tree also had two local changes for this machine: at most two driver compiles at once, and three screen-probe programs the driver never finishes left out. The world load still stopped presenting from about 480 s, held by builds of compute pipelines that write memory and of graphics pipelines (cold caches). A 90-minute run of the same kind on a newer tree (main62265d3, also with Recompiler: route huge compute programs through the direct DXIL translator #1809): 65 programs went on without a wait from 703 s on, no device removal and no crash in 5 400 s; the world load was still waiting on driver builds of memory-writing compute and of graphics pipelines when it ended.gpu::effects(a temporaryxcl shaderspass, not in this PR): 2 682 distinct compute programs; 1 051 have 16 KiB of code or more, and 444 of those write no memory (338 of the 801 bigCS_RaytracingResolvevariants, all 18CS_RTShadowTrace32*); none fails to decode. Of the 74 programs the driver cold-compiled one bind at a time in five earlier world-load runs (0.9 – 1.45 MB DXIL, 22 – 172 s each, 3 never finished), 30 write only images. The other 44 write a typed buffer (buffer_store_format_xyzw), 38 of them only past an earlys_endpgm, and are waited for as before.Regression run
scripts/smoke.ps1, 60 s, release builds, run back to back,XCL_PSO_IMAGE_SKIPunset (the default).main:
PR:
Not tested
AI use
🤖 Generated with Claude Code