You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
D3D12.X: copy root constants without a temporary buffer - #3345
The graphics and compute multi-word root-constant setters allocate a temporary byte Vec and then copy it into the command-list state. Borrow the caller's bytes for the synchronous destination copy on Windows x64, where the words are already little-endian.
What is in it
Remove the temporary buffer in both setters; preserve null handling, locking and destination-range handling.
Add tests for 180 combinations of path, parameter, count and offset, source mutation after return, null input and invalid destinations.
AMD Ryzen 7 8840HS, Radeon 780M (32.0.31033.3), 16 GB RAM, Windows 11, rustc 1.100.0 MSVC; head 6603fdcb.
cargo test -p xcl --lib root_constants_ --jobs 2 -- --nocapture: 2 passed, 0 failed, 0 ignored, no skips.
cargo test -p xcl --lib hle::d3d12x::bind::tests --jobs 2 -- --test-threads=2 --nocapture: 116 Cargo passes, 0 failed, 0 ignored; one early-return SKIPPED test (two_pass_binds_set_the_shared_view_heap). Rerunning that exact test binary with XCL_HEAP_WINDOWS=1: 1 passed, no skips. These are 116 unique tests, including the two new tests.
A temporary, uncommitted release measurement harness compared the original setter bodies with the new real setters, including state lookup, locking and copying. Two process runs, nine alternating pairs of 300,000 calls per version for each path and 1/4/16/64 words: median 48–56 ns before, 14–18 ns after (68–74% lower setter time). Each run also passed both correctness tests. This measures hot, uncontended CPU setters, not game FPS. The harness was removed from the source before committing.
cargo build --workspace --jobs 2: passed.
cargo test --workspace --jobs 2 -- --test-threads=4 --nocapture: aborted in the library test process while restoring a coherent UMA window (Windows error 487, exit code 130088963); no complete suite totals from that run.
cargo test --workspace --no-fail-fast --jobs 2 -- --test-threads=1 --nocapture: 2595 passed, 2 failed, 49 ignored across 41 completed targets; 12 explicit SKIPPED messages (early returns remain included in Cargo passes).
heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)
shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): Die Anwendung hat einen Vorgang angefordert, der von einer nicht vorhandenen oder nicht übereinstimmenden SDK-Komponente abhängig ist. (0x887A002D)
the title under the debug layer (dred: false): no d3d12SDKLayers.dll
the title under the debug layer (dred: true): no d3d12SDKLayers.dll
uploads_start_from_each_subresources_state: no D3D12 debug layer (Die Anwendung hat einen Vorgang angefordert, der von einer nicht vorhandenen oder nicht übereinstimmenden SDK-Komponente abhängig ist. (0x887A002D))
Failed tests: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (the latter also prints a nested child failure; counted once).
Targeted baseline comparison
Both failed tests were rerun individually on clean checkouts of PR head 6603fdcb7b28f7483a359479ed1d45863cdbc969 and its unchanged main base 227d2cb388f103268dac7635ea720eb3e5352d4e, on the same machine/toolchain above:
cargo test -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 --jobs 2 -- --exact --test-threads=1 --nocapture: on each commit, 0 passed, 1 failed, 0 ignored, no skips. Identical failure at fuzz_tests.rs:1171: seed 722, res[30] = 0x1, CPU expectation 0x7fffffff.
cargo test -p xcl --test gpu_two_pass_cache_e2e two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs --jobs 2 -- --exact --test-threads=1 --nocapture: on each commit, 0 passed, 1 failed, 0 ignored, no skips. Identical assertion at gpu_two_pass_cache_e2e.rs:584: releasing the title PSOs leaves one two-pass state, expected zero. The nested child failure is counted once.
These two failures therefore also occur without this change. This was a targeted comparison against the PR's exact base, not a full baseline-suite rerun or a test of today's latest main. The original four-thread UMA restoration abort was not reproduced in the paired full-suite rerun below. Its cause remains unconfirmed; this is not a claim that it has been fixed. Draft pending paired retail regression runs. Tests requiring unavailable game samples do not provide game-data coverage.
Parallel workspace rerun
On the same machine/toolchain, ran cargo test --workspace --no-fail-fast --jobs 2 -- --test-threads=4 --nocapture sequentially on clean checkouts of PR head and its unchanged main base. --no-fail-fast lets Cargo continue to the other test binaries after a failing binary; the tests still use four threads.
Commit
Passed
Failed
Ignored
Completed targets
Explicit SKIPPED messages
pr 6603fdcb7b28f7483a359479ed1d45863cdbc969
2595
2
49
41
12
base 227d2cb388f103268dac7635ea720eb3e5352d4e
2593
2
49
41
12
Both runs completed all test targets without the UMA restoration process abort. Both still failed the same Fuzz and two-pass cache tests documented above; the PR has two additional passing root-constant tests. The suites therefore did not pass completely. Early-return skips remain included in Cargo's pass counts and do not provide coverage. One complete parallel rerun was performed per commit; the earlier abort remains a recorded, currently non-reproduced event. No game regression or FPS result is implied.
Regression run
Not run: no retail title is available on this machine. Keeping this PR in draft pending paired main/head retail smoke results.
Not tested
Retail gameplay, FPS/frame-time impact, actual setter frequency, other CPUs/GPUs, concurrent contention and diagnostic tracing performance.
No claim that existing parameter-boundary issues are fixed.
AI use
This PR was created with AI assistance from OpenAI Codex (GPT-6).
Review (head 6603fdc, diff read, not a merge-check; draft, PR description red):
The speed-up isn't measured in anything a reviewer can rerun. The 48 -> 14 ns figure comes from a harness that isn't in the PR, and there's no frame-time number or smoke pair (which is why PR description fails). The setters probably run on every draw, so a smoke pair would show whether it matters.
Fine: a byte slice needs no alignment and n * 4 can't overflow on x64. Source (title memory) and destination (XCL's argument buffer) can't overlap, and put_in copies before returning. Null and bounds handling are unchanged. It reads only the part that fits, where the old code read all n words, so it is no worse when a title passes too large an n.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
No open or merged PR makes the same change. Main still builds a temporary Vec<u8> in set_graphics_root_constants/set_compute_root_constants. #3511 only adds tests for main's clipping in put_in and does not overlap. The byte view of the title's u32 words is equivalent on x64, and put_in copies the bytes before returning. The new tests stay inside each parameter's bounds, so they also pass with main's clipping put_in. No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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
area:d3d12D3D12.X runtime, command lists, resources, sparse memorygpu:bothCode affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)
2 participants
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.
The graphics and compute multi-word root-constant setters allocate a temporary byte Vec and then copy it into the command-list state. Borrow the caller's bytes for the synchronous destination copy on Windows x64, where the words are already little-endian.
What is in it
Tested
6603fdcb.cargo test -p xcl --lib root_constants_ --jobs 2 -- --nocapture: 2 passed, 0 failed, 0 ignored, no skips.cargo test -p xcl --lib hle::d3d12x::bind::tests --jobs 2 -- --test-threads=2 --nocapture: 116 Cargo passes, 0 failed, 0 ignored; one early-return SKIPPED test (two_pass_binds_set_the_shared_view_heap). Rerunning that exact test binary withXCL_HEAP_WINDOWS=1: 1 passed, no skips. These are 116 unique tests, including the two new tests.cargo build --workspace --jobs 2: passed.cargo test --workspace --jobs 2 -- --test-threads=4 --nocapture: aborted in the library test process while restoring a coherent UMA window (Windows error 487, exit code 130088963); no complete suite totals from that run.cargo test --workspace --no-fail-fast --jobs 2 -- --test-threads=1 --nocapture: 2595 passed, 2 failed, 49 ignored across 41 completed targets; 12 explicit SKIPPED messages (early returns remain included in Cargo passes).Explicit SKIPPED test results
Failed tests:
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(the latter also prints a nested child failure; counted once).Targeted baseline comparison
Both failed tests were rerun individually on clean checkouts of PR head
6603fdcb7b28f7483a359479ed1d45863cdbc969and its unchanged main base227d2cb388f103268dac7635ea720eb3e5352d4e, on the same machine/toolchain above:cargo test -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 --jobs 2 -- --exact --test-threads=1 --nocapture: on each commit, 0 passed, 1 failed, 0 ignored, no skips. Identical failure atfuzz_tests.rs:1171: seed 722,res[30] = 0x1, CPU expectation0x7fffffff.cargo test -p xcl --test gpu_two_pass_cache_e2e two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs --jobs 2 -- --exact --test-threads=1 --nocapture: on each commit, 0 passed, 1 failed, 0 ignored, no skips. Identical assertion atgpu_two_pass_cache_e2e.rs:584: releasing the title PSOs leaves one two-pass state, expected zero. The nested child failure is counted once.These two failures therefore also occur without this change. This was a targeted comparison against the PR's exact base, not a full baseline-suite rerun or a test of today's latest main. The original four-thread UMA restoration abort was not reproduced in the paired full-suite rerun below. Its cause remains unconfirmed; this is not a claim that it has been fixed. Draft pending paired retail regression runs. Tests requiring unavailable game samples do not provide game-data coverage.
Parallel workspace rerun
On the same machine/toolchain, ran
cargo test --workspace --no-fail-fast --jobs 2 -- --test-threads=4 --nocapturesequentially on clean checkouts of PR head and its unchanged main base.--no-fail-fastlets Cargo continue to the other test binaries after a failing binary; the tests still use four threads.6603fdcb7b28f7483a359479ed1d45863cdbc969227d2cb388f103268dac7635ea720eb3e5352d4eBoth runs completed all test targets without the UMA restoration process abort. Both still failed the same Fuzz and two-pass cache tests documented above; the PR has two additional passing root-constant tests. The suites therefore did not pass completely. Early-return skips remain included in Cargo's pass counts and do not provide coverage. One complete parallel rerun was performed per commit; the earlier abort remains a recorded, currently non-reproduced event. No game regression or FPS result is implied.
Regression run
Not run: no retail title is available on this machine. Keeping this PR in draft pending paired main/head retail smoke results.
Not tested
AI use
This PR was created with AI assistance from OpenAI Codex (GPT-6).