Skip to content

Direct DXIL: fix compute init and metadata - #1952

Open
mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:dxil/fix-init-and-metadata
Open

mokkamokacaffe wants to merge 1 commit into
xcl-dev:mainfrom
mokkamokacaffe:dxil/fix-init-and-metadata

Conversation

@mokkamokacaffe

@mokkamokacaffe mokkamokacaffe commented Nov 24, 2026 •

Copy link
Copy Markdown

Addresses #1894 items 3 and 4. Item 1 is handled by #1950 and item 2 by #1818. The proposed item 5 was rejected after DXIL validators 1.8 and 1.9 independently confirmed that descriptor-heap-only raw buffers do not require the legacy RawAndStructuredBuffers flag.

What is in it

  • Encode an Alloca with default alignment as alignment record zero instead of accidentally setting LLVM's inalloca flag.
  • Count only globals retained by the bitcode writer when reporting TGSM bytes in PSV0 metadata.
  • Bump the Direct-DXIL translated-cache version from 7 to 8.
  • Add focused regression coverage for default-aligned Alloca validation and unused TGSM exclusion.

Tested

  • git diff --check: passed on fb7b2ea96d0201e3ca08b560c4241ba794dec987.
  • Source-level audit against the bitcode writer's live-global rules and DXIL feature requirements.
  • Independent Windows validation on predecessor 13d7253 found that the Alloca and TGSM tests passed with DXIL 1.8.2502.11.
  • Independent DXIL 1.8.2502.11 and 1.9.2602.17 runs showed that the proposed heap-only raw-buffer flag was invalid; that change and test were removed from the current head.

The current Linux workspace does not contain Cargo/Rust or the Windows D3D12/DXIL validator, so the Rust and validator tests were not rerun after removing that isolated flag change.

Regression run

Not run: this Direct-DXIL runtime change needs paired Windows/GPU smoke runs on the exact head and a commit of main. Please apply test-only until matching xcl-smoke v1 blocks are available.

main:

Pending for a current commit of main.

PR:

Pending for fb7b2ea96d0201e3ca08b560c4241ba794dec987.

Not tested

  • Full Windows workspace and DXIL validator suite on the current head.
  • AMD and NVIDIA execution of affected Direct-DXIL shaders.
  • Retail-title smoke or world-load run.

AI use

OpenAI Codex reviewed #1269, #1894, current main, open shader PRs and the independent validator reports; implemented the two remaining Direct-DXIL fixes and focused tests; audited cache identity and overlapping work; removed the invalid heap-only raw-buffer flag expectation after confirmation from DXIL validators 1.8 and 1.9; and performed source-level/diff validation. No hardware or generated test results are claimed as Codex-produced.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

The first item in the description (round TG_SIZE[5:0] up for a partial last wave) isn't in the diff at 13d7253. dxil/kernel.rs changes only TRANSLATOR_VERSION, and its compute prologue still has let w = lw.c(total / lanes);. I checked on an RTX 3070 (driver 616.56): with this PR merged onto main 20cf130 and gpu_compute_tg_size_counts_a_partial_last_wave routed through direct_or, XCL_DIRECT_DXIL=1 still fails with left: 1 for 96 threads in wave64 (the HLSL path passes).

#1950 has that fix (total.div_ceil(lanes)) with the test routed through the direct translator. It also bumps TRANSLATOR_VERSION to 8, so whichever of the two merges second needs 9. If you'd rather keep the TG_SIZE item here, I'm happy to close #1950; it's only the one line plus the test change.

AI-assisted (Claude Code).

@GustavoEllwanger

Copy link
Copy Markdown

Tested exact head 13d7253590a740c9ff96e3d38a5d3673ac8263a1 on Windows 11 with the Windows SDK DXIL validator (dxil 1.8.2502.11) and AMD RDNA3 (RX 7600).

Finding
The new test gpu::dxil::ops_tests::heap_raw_buffer_sets_the_required_shader_flags fails DXIL validation:

thread 'gpu::dxil::ops_tests::heap_raw_buffer_sets_the_required_shader_flags' panicked at crates\xcl\src\gpu\dxil\ops_tests.rs:70:9:
validator rejected the kernel:
error: Flags must match usage.
note: Flags declared=1073741840, actual=1073741824
Validation failed.

declared = 0x4000_0010 (ResourceDescriptorHeapIndexing | EnableRawAndStructuredBuffers) vs actual = 0x4000_0000 (ResourceDescriptorHeapIndexing only). dxil.dll does not expect EnableRawAndStructuredBuffers (0x10) for a ByteAddressBuffer accessed solely via CreateHandleFromHeap + AnnotateHandle with no !dx.resources entry, so self.require(Feature::RawAndStructuredBuffers) in Shader::heap_raw_buffer (crates/xcl/src/gpu/dxil/shader.rs:290) causes validation to fail on heap-only raw-buffer shaders.

Tested

  • cargo build --workspace: passed.
  • cargo test -p xcl --lib default_aligned_alloca_validates_without_inalloca -- --nocapture: passed (DXIL 1.8.2502.11).
  • cargo test -p xcl --lib groupshared_bytes_follow_the_16bit_layout -- --nocapture: passed.
  • cargo test -p xcl --lib heap_raw_buffer_sets_the_required_shader_flags -- --nocapture: FAILED (error above).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip fuzz_validate_and_gpu_1: 984 passed, 1 failed (heap_raw_buffer_sets_the_required_shader_flags), 45 ignored, 1 filtered out, 0 wave64/mesh capability skips (8 expected SKIPPED lines: 6 per-lane #1426 refusals, 1 driver-cache / no Developer Mode, 1 no heap windows).
  • XCL_ADAPTER=warp cargo test -p xcl --lib fuzz_validate_and_gpu_1 -- --nocapture: passed (validated 500/500 modules 500..1000, GPU-compared 0).
  • XCL_SAMPLE_* variables were unset.
  • Machine: Windows 11 Home build 26200; AMD Ryzen 5 5600T; AMD Radeon RX 7600 (8133 MiB VRAM, RDNA3, Adrenalin 26.11.2 / driver 32.0.32029.2010); Rust 1.100.0 MSVC x64; DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0); debug profile.

Not tested

  • Retail-title smoke or world-load run, release builds, or XCL_SAMPLE_* game-data tests.

AI use
Antigravity (Gemini 4 Neon) ran the commands and drafted this report; only the measured results above are posted.

@futurepro62

Copy link
Copy Markdown

Same failure here with the newer validator, so it is not specific to DXC 1.8: gpu::dxil::ops_tests::heap_raw_buffer_sets_the_required_shader_flags fails identically at head 13d7253 with DXC / dxil.dll 1.9.2602.17, on both GPUs of this machine:

validator rejected the kernel:
error: Flags must match usage.
note: Flags declared=1073741840, actual=1073741824

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 621.40, XCL_REQUIRE_GPU=mesh) and the AMD Radeon iGPU of a Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon); Windows 11, Rust 1.100.0 MSVC, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 (plus the skips for tests that also fail on main): that one test fails on both GPUs; everything that ran before it passed (NVIDIA 927 passed, AMD 935 passed). The run stopped at the first failing test binary, so later test binaries did not run.

Not tested: retail-title smoke or world-load run, release build.

AI-assisted (Claude Code).

@mokkamokacaffe
mokkamokacaffe force-pushed the dxil/fix-init-and-metadata branch from 13d7253 to fb7b2ea Compare November 25, 2026 00:52
@raylitebull

Copy link
Copy Markdown
Member

Reviewed fb7b2ea: replacing the invalid-flags test with default_aligned_alloca_validates_without_inalloca looks clean alongside the Alloca align-0 fix and live-global byte count in module.rs.

Next steps before merge:

  1. Rebase onto main (dropping the manual TRANSLATOR_VERSION = 8 bump in kernel.rs, since #1950 took 8 and #1947 now auto-hashes gpu/dxil sources).
  2. Fix the failing PR description check (xcl-smoke block).
  3. Get AMD + NVIDIA verification (including DXIL validation) on the rebased head.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants