Skip to content

Recompiler: a DXC folder that fails to load leaves its dxil.dll unloaded (#2413) - #2467

Open
crastinator wants to merge 1 commit into
xcl-dev:mainfrom
crastinator:dxc-free-failed-candidate-2413
Open

crastinator wants to merge 1 commit into
xcl-dev:mainfrom
crastinator:dxc-free-failed-candidate-2413

Conversation

@crastinator

Copy link
Copy Markdown

load() loads a candidate folder's dxil.dll before its dxcompiler.dll. When dxcompiler.dll did not load, or had no DxcCreateInstance, the loop went on to the next folder and left both libraries loaded. A dxil.dll kept from a failed folder is then the one the next folder's dxcompiler.dll gets when it loads dxil.dll by name, so the validator could come from the wrong DXC.

Part of #2413 (the empty-blob half is #2441; the two touch different functions of dxc.rs).

What is in it

  • crates/xcl/src/gpu/recomp/dxc.rs: the per-folder attempt moves into load_candidate, which frees dxcompiler.dll and dxil.dll when the folder gives no DxcCreateInstance. The success path is unchanged. A unit test gives it a folder with a copy of a real dxil.dll and a dxcompiler.dll that is not a library, and checks that the copy is no longer loaded afterwards. It fails without the FreeLibrary calls ("the failed folder's dxil.dll is still loaded"), and skips with no DXC when there is no DXC to copy from.

Tested

  • AMD Radeon RX 6700 XT (RDNA2, RADV, Mesa 26.3.1), Ryzen 7 5700X, Linux 7.3.5 (CachyOS), under Wine (proton-cachyos 11.0, vkd3d-proton v3.1 + Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #257's patch with Linux: build vkd3d-proton with a dxil-spirv that structures the retail title's compute programs (#611) #775's dxil-spirv 53aac418); cross-built for x86_64-pc-windows-msvc, Rust stable, DXC 1.9.2609.5.
  • cargo test -p xcl --lib -- recomp::dxc: 17 passed, 0 failed, 0 ignored; with the two FreeLibrary calls removed, the new test fails (16 passed, 1 failed).
  • Whole suite (cargo test -p xcl --lib -- --test-threads=1 and every integration test), merged onto main 06055a7 and compared per test with the same run of that main: 1394 passed, 17 failed, 46 ignored (main: 1393 / 17 / 46; the extra pass is the new test). The 17 failures all fail on main too. tests/d3d12_create_placed_resource.rs stops without a result line on both main and this PR under Wine.
  • SKIPPED: the two debug-layer title runs and uploads_start_from_each_subresources_state (no D3D12 debug layer under Wine).

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: 2898511af1c038a2ef809719e9b6f89e5675c422
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

this PR:

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

Not tested

  • The case where dxcompiler.dll loads but has no DxcCreateInstance (the second failure branch): it frees the same two handles, but the test only covers a dxcompiler.dll that does not load.
  • Windows. On Windows, a full-path LoadLibraryW of a second dxil.dll while one is already loaded may behave differently from Wine; the test's check holds either way.
  • NVIDIA.

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.

…ded (xcl-dev#2413)

load() loads a candidate folder's dxil.dll before its dxcompiler.dll. When
dxcompiler.dll did not load, or had no DxcCreateInstance, the loop went on to
the next folder and left both libraries loaded. A dxil.dll kept from a failed
folder is then the one the next folder's dxcompiler.dll gets when it loads
dxil.dll by name, so the validator could come from the wrong DXC.

The per-folder attempt is now load_candidate, which frees both on failure. The
test gives it a folder with a copy of a real dxil.dll and a dxcompiler.dll that
is not a library, and checks that the copy is no longer loaded afterwards; it
fails without the FreeLibrary calls.

Part of xcl-dev#2413 (the empty-blob half is xcl-dev#2441).
@frenziedcoder

Copy link
Copy Markdown

NVIDIA test report for eaecb86: no new test failures (the 4 that fail also fail on 2898511), its own test a_folder_whose_dxcompiler_does_not_load_leaves_its_dxil_unloaded passes, and a clean smoke pair on the retail title (1650 vs 1671 frames). Native Windows, so the test's check that FreeLibrary really unloads the failed folder's dxil.dll holds outside Wine too (it ran here, no no DXC skip; it copies the Windows SDK's dxil.dll).

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 eaecb86dc7315fb52c11cffaaf8c2ec13dca129c, no local changes.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 1360 passed, 4 failed, 46 ignored; the PR's own test a_folder_whose_dxcompiler_does_not_load_leaves_its_dxil_unloaded 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 4 failures are fuzz_validate_and_gpu_0, fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_2, fuzz_validate_and_gpu_3 in gpu::dxil::fuzz_tests. They fail the same way on the base 2898511 here (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), 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 (2898511, this PR's merge base with main):

xcl-smoke v1
commit: 2898511af1c038a2ef809719e9b6f89e5675c422
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: 13942 MB

this PR:

xcl-smoke v1
commit: eaecb86dc7315fb52c11cffaaf8c2ec13dca129c
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1650 (PresentX 1650)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13980 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 covers it).

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

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.

2 participants