D3D12.X: keep each recording's barrier states for submission order #3599
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3599"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-01T18:00:44Z.
Stacked on #3559; only the top commit (
D3D12.X: keep each recording's barrier states for submission order) belongs here.Part B of the plan on #3094 (7298369429).
barrier_groupsandalias_copytake the state a texture is in from what was recorded last, but the GPU runs lists in the order they are submitted. This part records, without using it yet: per recording (a PC list between two resets), the state it needs each texture in when it starts (first) and the one it leaves it in (now), from the words the PC list really gets; and the state each texture is in after the recordings accepted so far, in submission order (one map for all queues: a legacy state is the resource's, whichever queue moves it), advanced only by chunks the driver accepted, fromExecuteCommandListsand from KickoffX. What D3D12 returns to COMMON when the call ends (all a copy queue's list used, a buffer, a simultaneous-access texture) is COMMON there too. What a recording needs and the queue does not have is what part C's fix-up lists put before it.XCL_SUBMIT_STATES=1; with it off each hook is one atomic load.Related: #3094 (7297382882), #3489, #3558
What is in it (one commit)
crates/xcl/src/hle/d3d12x/submit_states.rs(new):Recording(per-texturefirst/now/ mixed / pending),Queued(the queue's states;applyper accepted list,fixupsfor part C), the hooks, and 10 unit tests (the hooks with the switch forced on and off per thread, whatever the environment says).crates/xcl/src/hle/d3d12x/list_x.rs:resource_barrier_xreports the words it sends; KickoffX's submissions advance the queue's states; the recording is forgotten on Reset, list creation, KickoffX, a mid-list split, a segment back in the pool and release (one line each).crates/xcl/src/hle/d3d12x/real.rs:q_execute_command_listsadvances the queue's states after each accepted chunk, on its queue (one line).crates/xcl/src/hle/d3d12x/mod.rs:mod submit_states;.Tested
After the review fixes (head
04eb8071), RTX 5090, driver 621.40, Ryzen 7 9800X3D, Windows 11 Pro build 26200.9974, Rust 1.99.1, debug:cargo test -p xcl --lib -- hle::d3d12x --test-threads=4without and withXCL_SUBMIT_STATES=1in the environment: 1217 passed, 0 failed, 3 ignored both times.cargo test -p xcl --lib -- hle::d3d12x hle::d3d12x::list_x hle::d3d12x::real hle::d3d12x::submit_states --test-threads=4(the modules the commit touches), head04eb8071: 1213 passed, 4 failed, 3 ignored; the 4 are thetitle_texturestests below, which fail onmainon this machine too.cargo test --workspace --no-fail-fast -- --test-threads=4, head04eb8071: 2897 passed, 5 failed, 51 ignored.maind0832e61(the commit #3559 is on) on the same machine: 2882 passed, 5 failed, 51 ignored. The same 5 fail on both:title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, the threetitle_textures::tests::stream_recheck_*tests, andtest_title_runs_and_game_folder_is_untouched.no wave64, 2no heap windows, 3no D3D12 debug layer,pso_measurement_compiles_an_exact_synthetic_record(Developer Mode off). Left out by the run on this VM (no GPU_UPLOAD heaps): 3uma_drivertests.Regression run
These blocks are of
a7c1ddd3, before the review fixes; a pair on04eb8071follows.main-full-d8bd), the same frozen accepted-terms profile (r18-terms:gamesaveandpls/settings), and held Enter.XCL_SUBMIT_STATESwas unset in the head arm. The script-made blocks below are verbatim.Main
9dfbe3ea:Part B
a7c1ddd3:Not tested
XCL_SUBMIT_STATES=1on a title: nothing reads the records yet (part C).AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T20:48:52Z.
Review (head
a7c1ddd3, diff read, not a merge-check; draft):submittedis hooked only inq_execute_command_lists(real.rs~12048).kickoff_xsends the earlier segments and the list itself through the queue's originalExecuteCommandLists(list_x.rs~5397, ~5443, wheregpu_times::executedandlut3d::submittedare called) without callingsubmit_states::submitted, so a texture moved by a list submitted through KickoffX keeps its old state inQueued, against the module doc (submit_states.rs~16-19).Queued::applyignores state decay.apply(~124) stores each recording'snowfor every submission, but D3D12 returns resources used on a copy queue, and simultaneous-access textures, to COMMON when theExecuteCommandListscompletes. After a copy list leaves a texture in COPY_DEST,Queuedholds COPY_DEST while the runtime has COMMON, so a part C fix-up built from it would use the wrong before-state. There is also one globalQUEUEDfor all queues (~153-156), not the per-queue state the description describes.RECORDINGSis keyed by the list's address and cleared only inreset(~167), from theResethook. A list made byCreateCommandListstarts recording without aReset, so a new list at a released list's address adds to the oldRecording, inherits itsfirstvalues, and its submission writes the old list'snowvalues intoQueued. Entries of released lists are never freed.fixupsdrops textures that end the recording in a split.split_pendingdescribes the end of the recording, butfixups(~114) uses it to skip the move before the recording starts: a recording that does SRV→RT then BEGIN_ONLY RT→SRV on a texture the queue has in COPY_DEST gets no fix-up.a_pending_split_is_neither_stateonly covers a texture with a begin half alone.a_reset_forgets_the_recording_and_only_accepted_lists_advance_the_queue(~305) only checks that nothing is recorded whenXCL_SUBMIT_STATESis unset; nothing testsrecorded,resetorsubmittedwith it on, and the env assertion makes the test fail when the suite runs withXCL_SUBMIT_STATES=1.Fine: the transition word offsets (resource +8, subresource +16, before/after +20/+24) and split flags match what
resource_barrier_xsends after masking and parking; the default path is one relaxed atomic load per hook. Stacked on #3559; the top commit was reviewed.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T21:19:22Z.
Follow-up review (head
04eb8071, sincea7c1ddd3, diff read, not a merge-check; draft, checks red):kickoff_xnow callssubmit_states::submitted(q_raw, …)after each accepted chunk of earlier segments and after the list itself (list_x.rs~5403, ~5451), then forgets those recordings (~5416, ~5454).Queued::applyignores state decay; one globalQUEUED: partly fixed.applynow takes adecayspredicate and storesCOMMONfor every resource on a copy queue and for buffers and simultaneous-access textures on any queue (submit_states.rs~143-158, ~195, ~238), tested bydecaying_resources_are_common_after_their_submission(~388). The single map for all queues is kept on purpose (module doc ~8-10, ~188-191), but the description still says "per queue".submit_states::resetis also called fromon_create_with_backing(list_x.rs~1849),on_release(~1870),clear_segment_state(~1895) andsplit_recording(~4728).fixupsdrops textures that end the recording in a split: fixed. Thesplit_pendingfilter is gone (~128-138), a begin half setsfirstonly when it is the texture's first move (~82), anda_recording_that_ends_in_a_split_still_gets_its_start(~374) covers the case.TEST_ONoverride (~165-177) letswith_the_switch_on_the_hooks_record_reset_and_advance_the_queue(~404) exerciserecorded,resetandsubmitted_onwith the switch on, and the off test forces the switch off instead of asserting on the environment.New:
xcl-smokeblocks and the test counts are fora7c1ddd3, while04eb8071adds runtime hooks inkickoff_x,on_create_with_backing,on_release,clear_segment_stateandsplit_recording;PR descriptionfails on that. The description is also stale elsewhere ("7 unit tests", now 10; "one line each" inlist_x.rs; "per queue").Fine: every list lifecycle path now forgets its recording, KickoffX advances the queue, decay follows the D3D12 rules, and the default path is still one relaxed atomic load per hook.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-01T21:31:04Z.
@Foniass Thanks, all five were real. Fixed in the one commit, now
04eb8071(force-pushed; the description is updated):kickoff_x(the earlier segments and the list itself) now callsubmit_states::submitted(queue, lists)after the driver accepts them, next togpu_times::executed. Each submitted list's recording is then forgotten, aslut3d::list_resetis.Queued::applytakes a decay rule. After an accepted submission, everything a copy queue's list used, and any buffer or simultaneous-access texture on any queue, is COMMON inQueued, as D3D12 has it when the call ends. The queue type comes from the queue, the buffer and simultaneous-access facts from the resource's description. (Part C's planner applies the lists of one call without decay, since decay comes only at the call's end.) On "per queue": a legacy state is the resource's, whichever queue moves it, so the single map in submission order is intended. The description said "per queue", which was wrong; it now says what the code does.list_xresets its own per-list state:split_pendingnow only affects where the recording ends (apply).fixupsno longer skips the texture. A begin half that is the texture's first move setsfirstto its before-state, so SRV→RT then BEGIN_ONLY RT→SRV on a texture the queue has in COPY_DEST gets the COPY_DEST→SRV move. Test:a_recording_that_ends_in_a_split_still_gets_its_start.a_pending_split_is_neither_statenow expects the begin half's before-state as the start.XCL_SUBMIT_STATESsays, and the env assertion is gone.with_the_switch_on_the_hooks_record_reset_and_advance_the_queuedrivesrecorded,submitted(also on a copy queue) andresetwith the switch on, including a new recording at a reset list's address.with_the_switch_off_the_hooks_keep_nothingchecks the off path.decaying_resources_are_common_after_their_submissioncovers point 2.cargo test -p xcl --lib -- hle::d3d12x: 1217 passed, 0 failed, 3 ignored, both without and withXCL_SUBMIT_STATES=1in the environment (RTX 5090).04eb8071are queued; their results and a new smoke pair replace the old ones in the description.The parts stacked on this (the fix-up pool and parts C2a and C2b, local drafts) are rebased onto it. In part C2a, the harness's
setup()now pins the switch off for its today's-path cases, so the suite also passes withXCL_SUBMIT_STATES=1set.AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.