d3d12x: accelerate sparse UMA window chunk scanning #1051
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1058"
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 UnkwnDev on 2026-11-24T11:03:33Z.
This pull request accelerates the sparse UMA window chunk scanner:
In
crates/xcl/src/hle/d3d12x/sparse.rs,scan_pageandread_chunk_wordsscanned 64-byte chunks with scalar 64-bit integer arithmetic and unaligned reads. We optimizeread_chunk_wordswith an aligned pointer cast for page-aligned allocations, enabling 256-bit vector loads. Inscan_page, we add an 8-word zero reduction test so unchanged zero chunks across mapped sparse windows bypass the 5-multiplication hash computation entirely, eliminating CPU sync latency during command list execution.Originally part of #985, split into its own single-purpose PR per CONTRIBUTING.md.
Tested
cargo test --workspace(672 passed, 0 failed, 21 ignored in lib; 13/13 console_dlls_e2e passed; 3/3 console_shaders passed; 1/1 disasm_e2e passed; 3/3 e2e passed; 1/1 sparse_reinit passed; 1/1 texture_states passed; 6/6 xg_oracle passed)hle::d3d12x::sparse::tests: 13 passed, 0 failed, 1 ignored, verifyingscan_page_lazy_alloc_and_coalesceand dirty chunk detection.Regression run
main(e74dda2):PR (
dbcaee7):Not tested
AI use
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:16:58Z.
Full-suite run, since this PR has no test report yet. Tested exact head
dbcaee7(on its basee74dda2).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 727 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.#[test]functions in the diff.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 727 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by thaqiart139-alt on 2026-11-24T22:49:04Z.
Test report for this PR's head
dbcaee7, merged intomain689f2db(no conflicts), on AMD RDNA2 with native 64-lane waves and on a 32-lane NVIDIA card.Tested
XCL_ADAPTER.cargo test --workspace --no-fail-fast -- --test-threads=4:main689f2dbmain, from #1679's new fuzz tests, and both are already reported on #1679:fuzz_validate_and_gpu_0to_3(CreateComputePipelineState:0x8007000E)fuzz_validate_and_gpu_1(seed 540: res[833] = 0x7, CPU 0x6)hle::d3d12x::sparse::tests, includingscan_page_lazy_alloc_and_coalesce, passed on both GPUs (14 passed, 1 ignored).SKIPPED tests (the same on
mainand with this PR)gpu::recomp::lower::tests:a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpugpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu, and the wave64 cases of itsf16/f32/f64/integer_programs_on_the_gpugpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwarelower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused ("its #1426 semantics differ from the console's")heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is off)gpu::dxil::geometry_tests::gpu_geometry_direct_records,emitted_ms_primitive_attribute_reaches_the_pixel_shader,emitted_ms_ps_draw_a_triangle,gpu_geometry_mode_es_gs_strip,gpu_geometry_mode_es_gs_strip_with_branches,gpu_mesh_mode_two_passeslower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused, as aboveheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)pso_measurement_compiles_an_exact_synthetic_record(Developer Mode is off)Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:04:43Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T11:43:19Z.
Test report for head
dbcaee7as pushed (not merged onto currentmain) – NVIDIA, wave32.Tested
.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 727 passed, 0 failed, 41 ignoredgpu_memory_windows_above_4_gib,gpu_memory_windows_reject_out_of_uma_aliasing,gpu_sparse_vram_descriptors_buffers_and_xmem,gpu::umatests) passXCL_SAMPLE_*data set (game-data tests not run)Not tested
main; any timing of the scan (no benchmark run)AI use
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T10:10:31Z.
merge-check claim
head:
dbcaee766aImported from ivall/xcl. Originally posted by BBareth on 2026-11-30T10:22:39Z.
merge-check
base:
9dfbe3ea66head:
dbcaee766amerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2885 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. The sparse tests passed, among them
scan_page_plans_without_publishing_and_coalesces.review: no blocking finding; one file, every hunk read, and the merge result read too, since the PR was written against a much older
sparse.rs(git places the three hunks correctly in today'sscan_page). (1)read_chunk_wordsreads an 8-byte-aligned chunk through one[u64; 8]load and keeps the unaligned byte-wise path otherwise; the two agree on little-endian x64, the only target. (2) In the pass over a page with sent hashes, an all-zero chunk whose sent hash isZERO_HASHis skipped before hashing; in the tail pass of a never-sent page, an all-zero chunk is skipped before hashing. Both are the decisions the hash comparison made before (ZERO_HASHis the hash of eight zero words), reached earlier. No new test; the existing scan tests cover the result, not the speed.performance: CPU only, in the direction of less work per chunk (an OR of eight words in place of the hash for zero chunks). The PR gives no timing and I did not measure one; its smoke blocks show unchanged presents and commit.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by Elytes on 2026-11-30T11:47:05Z.
Measured on a retail title (RTX 5090, 60 s runs, base
9dfbe3evs this PR merged, scripted input, two pairs): the chunk scan this PR changes takes the same time with and without it ("sparse windows timing: chunk scan" at 2048 submits, same 1586 MB uploaded: 53 ms on base, 51 / 53 ms with the PR). On this title the scan is about 53 ms per minute, under a tenth of the sparse-window time (write-watch is ~576 ms), so the change has no visible effect here. No regression either: frames, peak commit, device removals and crashes as on base. Behaviour is unchanged (the dirty runs are the same), so it is safe, but it does not show the gain the description claims.AI use: Claude Code (Claude Opus 5.5) ran the builds, runs and log comparison and drafted this.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T12:12:27Z.
merge-check
base:
9dfbe3ea66head:
dbcaee766amerge: clean
build: cargo build --workspace -> ok (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2885 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing:
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it). The PR adds no test.review: whole diff read (+28/-14,
sparse.rs), and the three hunks checked where git placed them in today'sscan_page. The result is the same as before for every input. (1)read_chunk_wordsreads an 8-byte-aligned chunk with one[u64; 8]load and keeps the byte-wise little-endian path otherwise; on x86-64, the only target, both give the same words. A chunk is a fixed-size slice fromchunks_exact, so there is no partial last chunk to handle and a page cannot wrap. (2) In the pass over a page with sent hashes, an all-zero chunk whose sent hash isZERO_HASHis skipped before hashing. Before, it was hashed toZERO_HASH(ZERO_HASHishash_words([0; 8])), found equal to the sent hash and skipped, so the outcome is the same. A zero chunk whose sent hash is something else still goes through the hash and is sent, as before. (3) In the tail pass of a page with no sent hashes, an all-zero chunk is skipped before hashing, and theh2 == ZERO_HASHcheck stays for a non-zero chunk that hashes to it, so the same chunks are skipped. Which chunks are sent and in which runs does not change; only the hash of zero chunks is saved.performance:
scripts/smoke.ps1, 60 s of a retail title, release, after one warm-up run of the base: 1668 frames and 17308 MB peak commit against 1649 frames and 17417 MB on the base (warm-up: 1609, 17266 MB). No device removal, no crash. The "sparse windows timing" line at about 51 s, at the same point in each run (13406 mapped tiles): chunk scan 30 ms with the PR, 57 ms on the base and 32 ms in the base's warm-up run. The two base runs differ as much as base and PR do, so this does not show a speed-up; it shows no regression.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite and smoke, reviewed the diff against the merged source and wrote this)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:43:09Z.
Triage (#1607) – head
dbcaee7No open or merged PR makes the same change (#985, which this was split out of, is now only about DP4a). Main's
scan_pagehas since lost thesentupdate and takes&Option<...>, but the PR still merges cleanly onto it and the merged function keeps the zero shortcuts.The two shortcuts in
sparse.rs:scan_pagekeep the old results: an all-zero chunk hashes toZERO_HASH, so skipping it whensent[k] == ZERO_HASH(first loop) or unconditionally (second loop, where zero chunks were already skipped) changes nothing. The aligned fast path inread_chunk_wordsreads native-endian words where the slow path usesfrom_le_bytes; this is the same only on little-endian targets, which is all XCL builds for. 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.
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.