Skip to content

Direct DXIL: fix compute init and metadata - #1952

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

mokkamokacaffe wants to merge 2 commits 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 was merged in #1950 and item 2 is handled 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.
  • Add focused regression coverage for default-aligned Alloca validation and unused TGSM exclusion.
  • The current revision still bumps TRANSLATOR_VERSION from 7 to 8. This must be dropped when rebasing onto current main: Direct DXIL: TG_SIZE counts a partial last wave #1950 already took version 8 and Recompiler: direct DXIL cache entries change when its sources do #1947 now hashes gpu/dxil sources automatically.

Tested

  • Exact head fb7b2ea96d0201e3ca08b560c4241ba794dec987, Windows 11, AMD Radeon RX 6800M, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5:
    • XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 2 default_aligned_alloca_validates_without_inalloca -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored; DXIL validation passed.
    • The same command filtered to groupshared_bytes_follow_the_16bit_layout: 1 passed, 0 failed, 0 ignored.
    • cargo build --locked --workspace -j 2: passed.
    • cargo build --locked --workspace --release -j 2: passed.
  • The full AMD workspace run completed with 845 passed, 140 failed and 45 ignored. All 140 failures occurred after the RX 6800M D3D12 device suspended with 0x887A0005; this is not a green full-suite result.
  • RTX 3060 Ti verification of the branch merged with then-current main: cargo test -p xcl --lib passed with 0 failures and approximately 26 ignored; an intermittent parallel-scheduling abort is tracked in Test suite: parallel cargo test intermittently dies with 0xc0000005 (hle::d3d12x queue_tests × list_x race) #1978 and passed on a single-threaded rerun.
  • On predecessor 13d7253, 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 its failing test are absent from this head.
  • Windows no-GPU CI: passed.
  • git diff --check: passed.

Regression run

Exact-head paired retail smoke from scripts/smoke.ps1; same title and 60-second duration. This is a regression check only and does not prove that the title reached either changed metadata path.

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB

PR:

xcl-smoke v1
commit: 6831c4486c72709cc79f46276fcc91e570f2a9d1
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1634 (PresentX 1635)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14593 MB

The PR produced 104.3% of main frames and 100.0% of main peak commit, with no crash or device removal.

Not tested

  • A green full workspace run on AMD or NVIDIA.
  • NVIDIA DXIL validation on this exact head.
  • Retail-title execution of either changed Direct-DXIL metadata path; the smoke pair stopped at the intro frame with zero draws.
  • Intel and Wine/Linux execution.

AI use

@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
Contributor

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!

@luckyteagirl

Copy link
Copy Markdown
Contributor

RX 6800M validation for PR #1952 at fb7b2ea96d0201e3ca08b560c4241ba794dec987

Windows 11 build 26200, AMD Radeon RX 6800M (driver 30.0.13002.13003), Ryzen 9 5980HX, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. Clean checkout of the PR's exact head. This tests the two remaining #1894 fixes before the requested rebase.

Tested

  • With XCL_DIRECT_DXIL=1 in the environment, cargo test --locked -p xcl --lib -j 2 default_aligned_alloca_validates_without_inalloca -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored; DXIL validation passed.
  • Same command filtered to groupshared_bytes_follow_the_16bit_layout: 1 passed, 0 failed, 0 ignored.
  • cargo build --locked --workspace -j 2 and cargo build --locked --workspace --release -j 2: passed.
  • cargo test --locked --workspace --no-fail-fast -j 2 -- --test-threads=4 --show-output: 845 passed, 140 failed, 45 ignored across completed binaries. All 140 failures are gpu:: tests after the RX 6800M D3D12 device suspended (0x887A0005). The full suite is not green on this machine.

Regression run

The repository's scripts/smoke.ps1 ran for seven seconds per commit on the same owned title folder, with fresh separate data and DXIL caches. The first PR attempt reached one frame but its wrapper was stopped by a 1 GB free-commit monitor before it printed a smoke block; the clean PR run below completed with the monitor still active at a 768 MB guard. Neither clean run reported a crash or device removal.

Current main:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 6939 MB

PR head:

xcl-smoke v1
commit: fb7b2ea96d0201e3ca08b560c4241ba794dec987
gpu: AMD Radeon RX 6800M
title: 2ef5fd64
seconds: 7
exit: 0x0
frames shown: 1 (PresentX 1)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 7069 MB

Limits: These short runs show only one intro frame and zero draws; they do not exercise the changed Direct DXIL translation in the title. The smoke runs used the default shader path. World loading and GPU execution of a shader affected by Alloca/TGSM metadata were not tested. The PR's older base still needs the rebase requested by the maintainer; this report is for the exact head above. No game data was uploaded.

AI assistance: OpenAI Codex (GPT-6) ran the tests and paired smoke, extracted the reported counts and blocks from logs, and drafted this report.

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 6831c448 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 568e7db7, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: 6831c4486c72709cc79f46276fcc91e570f2a9d1
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1634 (PresentX 1635)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14593 MB

Against the limits in CONTRIBUTING.md: 104 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #2227 #2255 solves the same problem (for #1894) in a different way: #1607, group D73. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

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.

9 participants