Skip to content

Recompiler: an empty DXC blob reads as no bytes (#2413) - #2441

Open
crastinator wants to merge 1 commit into
xcl-dev:mainfrom
crastinator:dxc-empty-blob-2413
Open

crastinator wants to merge 1 commit into
xcl-dev:mainfrom
crastinator:dxc-empty-blob-2413

Conversation

@crastinator

Copy link
Copy Markdown

DXC can return an empty blob with a null buffer pointer: an empty error buffer when a compile fails, or an empty result. compile_here passed that pointer straight to slice::from_raw_parts, which needs a non-null pointer even for length 0. That is undefined behaviour, and a debug build aborts on the precondition check. Both places now read the blob through blob_bytes, which returns an empty slice for a null pointer or a zero size.

Part of #2413. The dxil.dll handle left loaded after a failed candidate folder (the second half of the issue) is a separate change.

What is in it

  • crates/xcl/src/gpu/recomp/dxc.rs: blob_bytes / bytes_at, used for the error buffer and the result in compile_here; a unit test for the null and zero-size cases.

Tested

Regression run
The blocks come from #257's scripts/linux/smoke.sh (the smoke.ps1 block under Wine; its title: line hashed as smoke.ps1 does), XCL_COHERENT_MB=512 for both.

main:

xcl-smoke v1
commit: 3ceb5507a05355719ff1d7b5c29bc52aff142000
gpu: AMD Radeon RX 6700 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1485 (PresentX 1485)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: d723284fd75157b062296e53ac10bacd0b7b7601
gpu: AMD Radeon RX 6700 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1475 (PresentX 1475)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • A DXC compile that actually returns an empty error buffer or result: I have no shader that makes DXC do that, so only the helper is tested directly. The old code had no separate function to test.
  • Windows, NVIDIA.
  • The other from_raw_parts(GetBufferPointer…) calls on DXC blobs (gpu/recomp/dxil/assemble.rs lines 21 and 53) are left as they are; root signature blobs elsewhere are never empty.

AI use

  • Claude Code, Claude Opus 5.5: wrote the change, the test and this description, and ran the tests and the regression runs. I reviewed the diff and the results.

DXC can hand back an empty blob with a null buffer pointer (an empty error
buffer when a compile fails, or an empty result). compile_here passed that
pointer to slice::from_raw_parts, which requires a non-null pointer even for
length 0: undefined behaviour, and a debug build aborts on the precondition
check. Both places now read the blob through blob_bytes, which gives an empty
slice for a null pointer or a zero size.

Part of xcl-dev#2413 (the dxil.dll handle left loaded after a failed candidate is a
separate change).
@SlopTart

Copy link
Copy Markdown

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: 160 passed / 4 failed. Three are the known baseline trio on this lane; the fourth is the new gpu_promoted_uav_clear_values_pass_create_committed_resource failure that current main carries (reported here), not caused by this PR. Everything else is green.
Targeted run of the new an_empty_blob_with_a_null_pointer_reads_as_no_bytes (not caught by the gpu_ sweep): 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.

@frenziedcoder

Copy link
Copy Markdown

NVIDIA test report for d723284: no new test failures (the 5 that fail also fail on 3ceb550), its own test an_empty_blob_with_a_null_pointer_reads_as_no_bytes passes, and a clean smoke pair on the retail title (1619 vs 1671 frames). Native Windows, MSVC build, for a second platform next to the Wine run above.

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 621.40, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head d723284fd75157b062296e53ac10bacd0b7b7601, no local changes.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 1343 passed, 5 failed, 46 ignored; the PR's own test an_empty_blob_with_a_null_pointer_reads_as_no_bytes passes. SKIPPED: gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole (no wave64), gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (const_mask, wave64: no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 compares, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 rounding, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 three-source, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 transcendentals, wave64: no wave64), gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu (f64, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer carries, wave64: no wave64), gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (mask_ff0_flbit, wave64: no wave64), gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), uploads_start_from_each_subresources_state (no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))).
  • The 5 failures fail the same way on the base 3ceb550 here (rerun of just those tests): fuzz_validate_and_gpu_0–_3 in gpu::dxil::fuzz_tests (0x8007000E from CreateComputePipelineState on seeds 70, 545, 1019 and 1507, the NVIDIA refusal @PHeitor1 reported on Direct DXIL: geometry mode, MSAA loads and directed f32 rounding #1679), and a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, which Tests: check divergent block barriers in a_bridged_mask_write #2420 fixed on main after this branch's base. So this PR adds no failure.

Regression run (scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen; XCL_PSO_PRELOAD=0 for both builds, because this machine's preload list holds the program of #1307)

base (3ceb550, this PR's merge base with main):

xcl-smoke v1
commit: 3ceb5507a05355719ff1d7b5c29bc52aff142000
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1671 (PresentX 1671)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13984 MB

this PR:

xcl-smoke v1
commit: d723284fd75157b062296e53ac10bacd0b7b7601
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1619 (PresentX 1619)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14008 MB

Not tested: the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD (the description and @SlopTart's run cover it).

AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report.

@ahmetbagci8

Copy link
Copy Markdown

Tested

  • Commit: d723284fd75157b062296e53ac10bacd0b7b7601
  • Hardware / OS: Intel Core i7-11800H, NVIDIA GeForce RTX 3070 Laptop GPU (driver 32.0.16.1714), Windows 11 Pro (Build 26300), DXC v1.9.2609
  • cargo test -j 2 -p xcl --lib dxc -- --test-threads=4: 41 passed; 0 failed; 3 ignored (0.46s)

Not tested

  • Full workspace suite and scripts/smoke.ps1 (no unpacked title locally).

AI use

  • Antigravity harness (Gemini 4 Neon) ran the targeted unit tests on this commit and drafted this report; the author reviewed it before posting.

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.

4 participants