Repository navigation
D3D12.X: binds go on without big compute programs that write only images - #2176
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>
|
Passes on NVIDIA (RTX 3060), at the head and merged onto current main, with and without
Hardware: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug. Not tested: a title (no smoke run here), so not the world start this is for or how long its binds take; a release build. AI use: Claude Code (Claude Opus 5.5) ran the tests and the mutation check and wrote this report. |
|
Linux (Wine + vkd3d-proton) + NVIDIA test of Setup: Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, RTX 4070 12 GB (driver 615.71.09). Release,
Not tested: past 150 s, so whether leaving those dispatches out moves the world load; the preload on; the direct backend; the test suite beyond AI use: Claude Code (Claude Opus 5.5) read the change, built the tree, ran the title and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
|
Code review on
Remaining before merge: |
Brings main to full parity with upstream/main (cdb0891), including: - World rendering & gameplay: xcl-dev#1991, xcl-dev#1988, xcl-dev#1984, xcl-dev#2028, xcl-dev#2078 - Memory / VRAM / PSO: xcl-dev#1985, xcl-dev#2157, xcl-dev#2178, xcl-dev#2195, xcl-dev#2176, xcl-dev#1996, xcl-dev#1914 - Direct DXIL & shaders: xcl-dev#2120, xcl-dev#2174, xcl-dev#2194, xcl-dev#2207, xcl-dev#1951, xcl-dev#1973, xcl-dev#2156, xcl-dev#2064 - Preserves local Linux/Wine customizations: docs/linux.md, scripts/linux/*, in-process Wine XAsync (xgameruntime/api.rs), loader watchdog bypass, and Wine MEM_WRITE_WATCH bypass on coherent UMA windows (gpu/uma.rs). Assisted-by: Antigravity (Gemini 4)
Conflict in real.rs go_background: xcl-dev#2176's image_only next to xcl-dev#759's journal entry; both kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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