Skip to content

DXIL: fix heap_structured_buffer, texture_load, and wave_all_equal feature flags - #2476

Open
Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-dxil-ops-feature-flags
Open

Decodere wants to merge 1 commit into
xcl-dev:mainfrom
Decodere:fix-dxil-ops-feature-flags

Conversation

@Decodere

Copy link
Copy Markdown
Contributor

What is in it
Align three Shader op builders in crates/xcl/src/gpu/dxil/ops.rs (+5/-5) with DXC 1.9's validator feature-flag rules and add DXC 1.9 validator + SFI0 coverage in crates/xcl/src/gpu/dxil/ops_tests.rs (+59/-0, 69 lines total):

  • heap_structured_buffer: remove spurious self.require(Feature::RawAndStructuredBuffers) — ResourceDescriptorHeap structured buffers require only ResourceHeapIndexing (1 << 30, SFI0 = 0x200_0000), not the static raw/structured binding metadata flag (1 << 4), which caused dxil.dll to reject standalone heap structured-buffer shaders with Flags must match usage.
  • Texture / srv_texture / heap_texture / texture_load: record pub ncomp: u32 on Texture and gate Feature::TypedUavLoadAdditionalFormats (1 << 13, SFI0 = 0x800) on tex.uav && tex.ncomp > 1 instead of tex.comp != U32/I32/F32, fixing both 1-component false positives (UNormF32, SNormF32, F16) and multi-component F32/I32/U32 false negatives without removing typed_uav_load_additional_formats().
  • wave_all_equal: call self.wave_int64(v) matching the other typed wave helpers so Feature::Int64Ops and Feature::Doubles are recorded immediately on i64/f64 inputs.

Part of #1401
Part of #1833

Tested

  • Failing-first on unmodified origin/main (9ba6804f, DXC/dxil 1.9.2609.5): cargo test -p xcl --lib gpu::dxil::ops_tests::ops_feature_flags -- --test-threads=1 --nocapture failed 3 of 3 (ops_feature_flags_heap_structured_buffer rejected declared=1073741840, actual=1073741824; ops_feature_flags_typed_uav_texture_load rejected declared=1073741824, actual=1073750016; ops_feature_flags_wave_all_equal_64bit missed Int64Ops 16384 != 49152).
  • Post-fix gpu::dxil::ops_tests (c20e5829, rebased onto origin/main 06055a7a, DXC/dxil 1.9.2609.5):
    • Release RTX 4060 (cargo test --release -p xcl --lib gpu::dxil::ops_tests -- --test-threads=1 --nocapture): 27 passed; 0 failed; 0 ignored (0.33 s, 0 skips).
    • Release WARP (XCL_ADAPTER=warp cargo test --release -p xcl --lib gpu::dxil::ops_tests -- --test-threads=1 --nocapture): 27 passed; 0 failed; 0 ignored (0.06 s; 0 skips on all 3 new pure-CPU/DXC 1.9 tests, pre-existing GPU dispatch tests skip cleanly with no wave32).
  • Full release workspace (cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture, RTX 4060): 37 test binaries, 1416 passed; 0 failed; 46 ignored (183/183 gpu::dxil::*).
    • 29 pre-existing SKIPPED lines on this RTX 4060 host (21 no wave64, 3 per-lane wave32 refused, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no heap windows, 1 cannot disable driver cache; 0 skipped in gpu::dxil::ops_tests).

Regression run
Paired 60 s RTX 4060 smoke (scripts/smoke.ps1 -Seconds 60) on base origin/main vs PR head (1539 vs 1466 frames = 105.0%, 60 60 60 steady pace, 0 device removals, 0 crashes):

Base (origin/main):

xcl-smoke v1
commit: 06055a7a0fb43c5f83f55e7a2ce201417de171e9
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1466 (PresentX 1467)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13983 MB

PR head:

xcl-smoke v1
commit: c20e5829a7b6bac8ff2acddcd58e697872b7bc00
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1539 (PresentX 1539)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14005 MB

Not tested

  • Wave64 GPU execution paths (21 pre-existing wave64 tests skip on RTX 4060 wave32-only hardware; all feature-flag cases are validated directly by DXC/dxil 1.9.2609.5 and SFI0 assertions).
  • D3D12 debug layer (d3d12SDKLayers.dll not installed on this host).

AI use
Written and verified with Google Antigravity (Gemini 4 Neon). All changes were validated locally with failing-first DXC 1.9 tests, full release workspace tests, and paired 60 s RTX 4060 smoke runs.

…ature flags

Align three `Shader` op builders in `gpu/dxil/ops.rs` with DXC 1.9's
validator feature-flag rules:
- `heap_structured_buffer`: drop spurious `Feature::RawAndStructuredBuffers`
  (`ResourceDescriptorHeap` structured buffers require only
  `ResourceHeapIndexing`, not the static raw/structured binding flag).
- `Texture` / `texture_load`: record `pub ncomp: u32` on `Texture` (set in
  `srv_texture` and `heap_texture`) and gate
  `Feature::TypedUavLoadAdditionalFormats` on `tex.uav && tex.ncomp > 1`
  instead of `comp != U32/I32/F32`, fixing both 1-component false positives
  (`UNormF32`, `SNormF32`, `F16`) and multi-component `F32`/`I32`/`U32`
  false negatives.
- `wave_all_equal`: call `self.wave_int64(v)` matching the other typed wave
  helpers so `Int64Ops` and `Doubles` are declared immediately on `i64`/`f64`
  inputs.

Part of xcl-dev#1401
Part of xcl-dev#1833

Assisted-by: Google Antigravity (Gemini 4 Neon)
@DarkPanda69

Copy link
Copy Markdown

The wave64 GPU paths listed as untested, on an AMD card with native wave64, plus an RTX 3060, paired against main with the direct translator on for the whole GPU suite (so every directly translated program carries the changed flags).

Head c20e582 applied on main 6d051da, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, on main and on this PR for each card:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64) 696 passed, 2 failed, 6 SKIPPED 699 passed, 2 failed, 6 SKIPPED
RTX 3060 (32.0.16.1088, wave32) 698 passed, 0 failed, 24 SKIPPED 701 passed, 0 failed, 24 SKIPPED

Per-test comparison: on both cards the only differences are the 3 new ops_feature_flags_* tests (all ok). No existing test changes result or skip state; on the RX 9070 XT none of the wave64 tests skip, so the drivers accept the pipelines with the new flags there too. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same on main.

Not tested: the D3D12 debug layer (not installed here), a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head c20e5829a7b6bac8ff2acddcd58e697872b7bc00 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1414 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • All 3 PR tests passed: gpu::dxil::ops_tests::ops_feature_flags_heap_structured_buffer, ops_feature_flags_typed_uav_texture_load, and ops_feature_flags_wave_all_equal_64bit.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: c20e5829a7b6bac8ff2acddcd58e697872b7bc00
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1613 (PresentX 1613)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16252 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
…#2127, xcl-dev#2476, xcl-dev#2479, xcl-dev#2467, xcl-dev#2444, xcl-dev#2447, xcl-dev#2448

Integrates compositor RT tracking fix (xcl-dev#2480), split shader cache budget
(xcl-dev#2475), foreign-thread deferred release (xcl-dev#2474), Wine 4-thread DXC cap
(xcl-dev#2127), DXIL feature/reload fixes (xcl-dev#2476, xcl-dev#2479), DXC loader cleanup
(xcl-dev#2467), console xcl-dev#14 null ppv guard (xcl-dev#2444), root-sig flag stripping
(xcl-dev#2447), and two-pass stream canonicalization (xcl-dev#2448).

Assisted-by: Antigravity (Gemini 4 Neon)

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: scalar additional typed-UAV formats no longer declare TypedUavLoadAdditionalFormats. ops.rs:816-818 sets the flag only when tex.ncomp > 1, so scalar R16_FLOAT/F16 and R8_UNORM/UNormF32 typed UAV loads omit the required SFI0 capability. Only R32_FLOAT/R32_UINT/R32_SINT are universally supported; these scalar formats are additional and require the flag. The new test at ops_tests.rs:3191-3204 explicitly asserts the incorrect F16x1 and UNorm/SNormF32x1 behavior. Please predicate on base format (the universal scalar formats), not component count, and add scalar additional-format positive cases.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@Decodere

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing! We verified this directly against Microsoft dxc.exe / dxil.dll 1.9.2609.5 (and all 8 format/component-count cases in ops_feature_flags_typed_uav_texture_load pass live dxil.dll validation via check(&c)):

Compiling RWTexture2D<T> u; u[t.xy] = u[t.xy]; with dxc -T cs_6_6 emits:

  • float, unorm float, snorm float (ncomp == 1): SFI0 = 0x00000000 (TypedUAVLoadAdditionalFormats = false)
  • float16_t (ncomp == 1, -enable-16bit-types): SFI0 = 0x00040000 (NativeLowPrecision only, TypedUAVLoadAdditionalFormats = false)
  • float4, uint4 (ncomp == 4): SFI0 = 0x00000800 (TypedUAVLoadAdditionalFormats = true)
  • float16_t4 (ncomp == 4, -enable-16bit-types): SFI0 = 0x00040800 (TypedUAVLoadAdditionalFormats = true)

DXIL resource metadata encodes component type + component count (not DXGI_FORMAT), and dxil.dll's validator requires TypedUAVLoadAdditionalFormats (0x800) strictly when a typed UAV load reads > 1 component (ncomp > 1) — setting 0x800 on 1-component UNormF32/SNormF32/F16 (as main did previously) is rejected by dxil.dll with a shader feature-flag mismatch.

@SlopTart

Copy link
Copy Markdown

gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.

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