Tests: pin direct DXIL bitstream, compact, and lowering invariants #2345

Open
safesearch77 wants to merge 1 commit from upstream-pr/2355 into main
safesearch77 commented 2026-11-25 16:27:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by safesearch77 on 2026-11-25T16:27:54Z.


Add six pure-CPU unit tests across existing Direct DXIL *_tests.rs modules (bitreader_tests.rs, compact_tests.rs, robustness_tests.rs, reusing graphics_tests::part) pinning bitstream serialisation, compact block-class planning and auto-nesting, split-Wave64 whole-live exchange elision, 64-bit integer compare lowering, and POPS ROV flag inference.

No runtime files are modified (*_tests.rs only), and every test runs purely in memory without requiring a GPU or dxcompiler.dll.

What is in it

  • crates/xcl/src/gpu/dxil/bitreader_tests.rs:
    • phis_encode_signed_relative_ids_and_prune_unreachable_predecessors: verifies FUNC_CODE_INST_PHI signed-VBR forward (-1 -> 3) and backward (+1 -> 2) relative value IDs across loop back-edges, and verifies unreachable predecessor blocks and their incoming phi edges are omitted from FUNC_CODE_DECLAREBLOCKS and FUNC_CODE_INST_PHI.
    • alloca_explicit_type_bit_and_unused_symbol_elision: verifies FUNC_CODE_INST_ALLOCA sets the LLVM 3.7 explicit-type bit (1 << 6) alongside log2(align) + 1 with distinct pointee types (i32 vs i64), and verifies unreferenced globals and unreferenced external dx.op declarations are elided from MODULE_CODE_GLOBALVAR, MODULE_CODE_FUNCTION, and BLOCK_VALUE_SYMTAB.
  • crates/xcl/src/gpu/dxil/compact_tests.rs:
    • plan_splits_getpc_static_samplers_and_loop_headers: verifies compact::plan splits byte-identical blocks when s_getpc_b64 sits at distinct PCs, when static_samplers binds distinct constant S# words (while merging matching S# words), or when only one copy is a natural loop header spending VAR_BUDGET, plus checks packed Plan::words().
    • auto_nest_threshold_switches_at_512_classes_in_emitted_ir: verifies compact::emit_with_nest(..., Nest::Auto) emits a single flat switch at 511 classes (AUTO_NEST_MIN_CLASSES - 1) and transitions at 512 classes (AUTO_NEST_MIN_CLASSES) to two-level dispatch (1 outer switch + 16 inner switches of 32 targets).
  • crates/xcl/src/gpu/dxil/robustness_tests.rs & crates/xcl/src/gpu/dxil/graphics_tests.rs:
    • Widen graphics::tests::part to pub(in crate::gpu::dxil) so robustness_tests reuses it without duplicating container parsing.
    • split_wave64_whole_live_elides_exchange_barriers_for_lane_local_masks: verifies split-Wave64 compute lowering keeps only the xcl_wt wave counter (1 addrspace-3 global, 4 TGSM bytes, 1 barrier) when VCC is read per-lane (v_cndmask_b32), while allocating xcl_x64_s (2 addrspace-3 globals, 12 TGSM bytes, 3 barriers) when VCC is read as a scalar SGPR (s_mov_b32), and verifies 64-bit integer compares (v_cmp_lt_i64) do not set D3D_SHADER_REQUIRES_INT64_OPS (0x8000) in SFI0.
    • pops_pixel_shader_gates_rov_sfi0_flag_on_surviving_uav_handles: verifies pixel-shader D3D_SHADER_REQUIRES_ROVS (0x1000 in SFI0) under HEAP_WINDOWS is set iff POPS (src_pops_exiting_wave_id) is used and an IsROV heap UAV annotateHandle survives dead-code elimination.

Tested

  • Linux x86_64 host native unit test execution (rustc --edition 2021 --test harness over gpu::dxil on commit b2da28c, base 0829441): 34 passed; 0 failed (bitreader_tests: 6 passed, compact_tests: 10 passed, robustness_tests: 10 passed, graphics::tests: 8 passed).
  • Offline cross-target check: cargo check --offline --target x86_64-pc-windows-gnu --workspace --tests (0 errors, 0 new warnings).
  • python3 scripts/pr_check.py --local (description ok, *_tests.rs-only diff).

Not tested

  • Full Windows cargo test --workspace -- --test-threads=4 GPU suite (authored and executed on a Linux CPU host without a D3D12 GPU or dxcompiler.dll; all 6 added tests are pure-CPU unit tests that run on the standard no-GPU Windows CI runner).
  • Retail title / GPU runs (test-only *_tests.rs change; no runtime code modified).

AI use

  • Authored with Antigravity (Gemini 4 Carbon) and reviewed with Claude Opus 5.5: audited Direct DXIL bitstream/compact/lowering invariants against open PRs, wrote and ran the six unit tests on host CPU, and verified cargo check --workspace --tests and scripts/pr_check.py --local.
<!-- greyfinch-sync:ivall/xcl:issue:5495102547 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2355). Originally posted by [safesearch77](https://github.com/safesearch77) on 2026-11-25T16:27:54Z. --- Add six pure-CPU unit tests across existing Direct DXIL `*_tests.rs` modules (`bitreader_tests.rs`, `compact_tests.rs`, `robustness_tests.rs`, reusing `graphics_tests::part`) pinning bitstream serialisation, compact block-class planning and auto-nesting, split-Wave64 whole-live exchange elision, 64-bit integer compare lowering, and POPS ROV flag inference. No runtime files are modified (`*_tests.rs` only), and every test runs purely in memory without requiring a GPU or `dxcompiler.dll`. **What is in it** - `crates/xcl/src/gpu/dxil/bitreader_tests.rs`: - `phis_encode_signed_relative_ids_and_prune_unreachable_predecessors`: verifies `FUNC_CODE_INST_PHI` signed-VBR forward (`-1 -> 3`) and backward (`+1 -> 2`) relative value IDs across loop back-edges, and verifies unreachable predecessor blocks and their incoming phi edges are omitted from `FUNC_CODE_DECLAREBLOCKS` and `FUNC_CODE_INST_PHI`. - `alloca_explicit_type_bit_and_unused_symbol_elision`: verifies `FUNC_CODE_INST_ALLOCA` sets the LLVM 3.7 explicit-type bit (`1 << 6`) alongside `log2(align) + 1` with distinct pointee types (`i32` vs `i64`), and verifies unreferenced globals and unreferenced external `dx.op` declarations are elided from `MODULE_CODE_GLOBALVAR`, `MODULE_CODE_FUNCTION`, and `BLOCK_VALUE_SYMTAB`. - `crates/xcl/src/gpu/dxil/compact_tests.rs`: - `plan_splits_getpc_static_samplers_and_loop_headers`: verifies `compact::plan` splits byte-identical blocks when `s_getpc_b64` sits at distinct PCs, when `static_samplers` binds distinct constant `S#` words (while merging matching `S#` words), or when only one copy is a natural loop header spending `VAR_BUDGET`, plus checks packed `Plan::words()`. - `auto_nest_threshold_switches_at_512_classes_in_emitted_ir`: verifies `compact::emit_with_nest(..., Nest::Auto)` emits a single flat switch at `511` classes (`AUTO_NEST_MIN_CLASSES - 1`) and transitions at `512` classes (`AUTO_NEST_MIN_CLASSES`) to two-level dispatch (`1` outer switch + `16` inner switches of `32` targets). - `crates/xcl/src/gpu/dxil/robustness_tests.rs` & `crates/xcl/src/gpu/dxil/graphics_tests.rs`: - Widen `graphics::tests::part` to `pub(in crate::gpu::dxil)` so `robustness_tests` reuses it without duplicating container parsing. - `split_wave64_whole_live_elides_exchange_barriers_for_lane_local_masks`: verifies split-Wave64 compute lowering keeps only the `xcl_wt` wave counter (`1` addrspace-3 global, `4` TGSM bytes, `1` barrier) when `VCC` is read per-lane (`v_cndmask_b32`), while allocating `xcl_x64_s` (`2` addrspace-3 globals, `12` TGSM bytes, `3` barriers) when `VCC` is read as a scalar SGPR (`s_mov_b32`), and verifies 64-bit integer compares (`v_cmp_lt_i64`) do not set `D3D_SHADER_REQUIRES_INT64_OPS` (`0x8000`) in `SFI0`. - `pops_pixel_shader_gates_rov_sfi0_flag_on_surviving_uav_handles`: verifies pixel-shader `D3D_SHADER_REQUIRES_ROVS` (`0x1000` in `SFI0`) under `HEAP_WINDOWS` is set iff POPS (`src_pops_exiting_wave_id`) is used and an `IsROV` heap UAV `annotateHandle` survives dead-code elimination. **Tested** - Linux x86_64 host native unit test execution (`rustc --edition 2021 --test` harness over `gpu::dxil` on commit `b2da28c`, base `0829441`): `34 passed; 0 failed` (`bitreader_tests`: `6 passed`, `compact_tests`: `10 passed`, `robustness_tests`: `10 passed`, `graphics::tests`: `8 passed`). - Offline cross-target check: `cargo check --offline --target x86_64-pc-windows-gnu --workspace --tests` (`0` errors, `0` new warnings). - `python3 scripts/pr_check.py --local` (`description ok`, `*_tests.rs`-only diff). **Not tested** - Full Windows `cargo test --workspace -- --test-threads=4` GPU suite (authored and executed on a Linux CPU host without a D3D12 GPU or `dxcompiler.dll`; all 6 added tests are pure-CPU unit tests that run on the standard no-GPU Windows CI runner). - Retail title / GPU runs (test-only `*_tests.rs` change; no runtime code modified). **AI use** - Authored with Antigravity (Gemini 4 Carbon) and reviewed with Claude Opus 5.5: audited Direct DXIL bitstream/compact/lowering invariants against open PRs, wrote and ran the six unit tests on host CPU, and verified `cargo check --workspace --tests` and `scripts/pr_check.py --local`.
DavidM1911 commented 2026-11-25 19:09:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:37:31Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7171167215 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2355#issuecomment-7171167215). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T18:37:31Z. --- 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!
SlopTart commented 2026-11-25 19:09:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T19:05:59Z.


Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).
gpu_ suite, cold cache: 143 passed / 4 failed. The fourth failure besides the baseline trio is gpu_geometry_wave32_prefix_count_over_a_mask, which passes 3/3 solo at --test-threads=1 on this tree and passes in-suite on other trees; order-dependent flake family, not attributable to this PR. The tests this PR pins all ran inside the suite and passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7171817771 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2355#issuecomment-7171817771). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T19:05:59Z. --- **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite, cold cache: 143 passed / 4 failed. The fourth failure besides the baseline trio is `gpu_geometry_wave32_prefix_count_over_a_mask`, which passes 3/3 solo at `--test-threads=1` on this tree and passes in-suite on other trees; order-dependent flake family, not attributable to this PR. The tests this PR pins all ran inside the suite and passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
github-actions[bot] commented 2026-11-30 08:39:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:39:19Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273177039 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2355#issuecomment-7273177039). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:39:19Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:54:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:54:28Z.


Triage (#1607) – head b2da28c

No open or merged PR adds these tests. The diff only adds tests, plus a widened visibility on graphics_tests::part. The APIs it calls (Module::phi/add_incoming, compact::emit_with_nest, AUTO_NEST_MIN_CLASSES, kernel::compute_init, try_finish_graphics) exist on main.
Some assertions pin exact implementation counts, which will need updating whenever the lowering changes. Examples: 1 TGSM global / 4 bytes / 1 barrier for the split-wave64 setup in robustness_tests.rs, and the exact alloca and phi record layouts in bitreader_tests.rs. split_wave64_whole_live_elides_exchange_barriers_for_lane_local_masks prints its own SKIPPED line when XCL_X64_ALL_MASKS is set.
The PR conflicts with main in compact_tests.rs (appended tests).
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304631899 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2355#issuecomment-7304631899). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:54:28Z. --- **Triage (#1607)** – head b2da28c No open or merged PR adds these tests. The diff only adds tests, plus a widened visibility on `graphics_tests::part`. The APIs it calls (`Module::phi`/`add_incoming`, `compact::emit_with_nest`, `AUTO_NEST_MIN_CLASSES`, `kernel::compute_init`, `try_finish_graphics`) exist on main. Some assertions pin exact implementation counts, which will need updating whenever the lowering changes. Examples: 1 TGSM global / 4 bytes / 1 barrier for the split-wave64 setup in `robustness_tests.rs`, and the exact alloca and phi record layouts in `bitreader_tests.rs`. `split_wave64_whole_live_elides_exchange_barriers_for_lane_local_masks` prints its own `SKIPPED` line when `XCL_X64_ALL_MASKS` is set. The PR conflicts with main in `compact_tests.rs` (appended tests). Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2355:upstream-pr/2355'
git switch 'upstream-pr/2355'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2355'
git switch 'upstream-pr/2355'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2355'
git switch 'upstream-pr/2355'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2355'
git switch 'main'
git merge --squash 'upstream-pr/2355'
git switch 'main'
git merge --ff-only 'upstream-pr/2355'
git switch 'main'
git merge 'upstream-pr/2355'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2345
No description provided.