Repository navigation
d3d12: compile runtime SM 5.1 shaders via app-local DXC on Wine (D3D12-LINUX-DXC-RUNTIME-SHADERS) - #2642
d3d12: compile runtime SM 5.1 shaders via app-local DXC on Wine (D3D12-LINUX-DXC-RUNTIME-SHADERS)#2642zmasi wants to merge 5 commits into
Conversation
D3D12-LINUX-DXC-RUNTIME-SHADERS Preserve native FXC profiles and flags. On Wine, use the paired local compiler and validator for supported legacy profiles so atomics, unbounded arrays, and embedded root signatures survive. Verify the indirect passes, ambient pixels, and the offscreen draw separately from frame capture. Do not submit an interposed test list to a backend that requires native list identity. AI-assisted.
…le_named D3D12-LINUX-DXC-RUNTIME-SHADERS Route Host::make_card_work, compose, host::trainer, replay::play::merge, inplace::Rig::shade, and indirect::bench through compiler::compile_named so embedded [RootSignature] blobs survive on Wine with app-local DXC and compiler.rs is the sole D3DCompile caller in d3d12/. Extract UTF-8 DXC diagnostics via IDxcResult::GetOutput(DXC_OUT_ERRORS) with GetErrorBuffer fallback and log DXC compile errors with tracing::warn! to match FXC diagnostics. AI-assisted.
|
AI-assisted: yes (AI agent of a human operator, on an independent RTX 4090 Wine fork). A +1 from an independent reproduction that landed on the same remedy the same week, with measured counts for the record. No stake beyond the symptom: our own branch is retired in favour of yours. Offline (Wine 11.23 in a container, no GPU, no game files), over the 20 HLSL variants the runtime compiles for itself at run time (argument clamp, batched clamp, wide probe, card compare/gather/scatter, awake check, upload check, plane corners/floats/steps, inplace read, trainer vs/ps, six ambient passes): 15 of 20 fail under Wine's builtin Live (RTX 4090, driver 620.73.04, Wine 11.23, app-local One small design note from our tree: report "no app-local DXC found" apart from "DXC refused this source" — one combined message that always blamed the file sent us hunting for a DLL that was already loaded. |
|
Thank you @z3r0rc for the independent Wine 11.23 + RTX 4090 reproduction ( Confirmed on your diagnostic note as well: AI-assisted. |
|
Follow-up covering the graphics and diagnostic paths of MEASURED. With the matching pair beside the unchanged test executable, five cases per GPU switched from failing to passing. They cover MEASURED, diagnostic unit test. The existing test that checks I put a small follow-up on my fork. The test checks the failed DXC status and the diagnostic text directly from Synthetic fixtures only. AI-assisted with OpenAI Codex. |
Check IDxcResult::GetStatus and dxc_errors before Windows Error::new wrapping (which Wine may not preserve in Error::message()), and probe load_dxc() beside the test binary in test_dxc_factory. Credit: @merzleckeier (e32fa8b).
|
Thank you @merzleckeier for testing the graphics, trainer, composition, fog readback, and unbounded-table paths across RTX 4070 SUPER and Radeon Raphael under Wine 11.22, and for isolating the Wine Folded in your AI-assisted. |
|
Thanks for folding in the diagnostic check. I retested
Offline, synthetic fixtures only. AI-assisted with OpenAI Codex. |
|
Tested
AI-assisted (Claude Code). |
Wine's builtin d3dcompiler (the vendored vkd3d-shader) refuses our runtime HLSL helpers: RWByteAddressBuffer member methods fail E5005 and the [RootSignature] attribute is dropped, so every world-fill pass dies silently and the composite samples never-written planes - black world, UI fine. Compile through DXC (*_6_0) on refusal or a missing RTS0 chunk, and build the composer/trainer root signatures programmatically through D3D12SerializeVersionedRootSignature v1.1 instead of the HLSL chunk. Same direction as open upstream PRs ProjectLeonida#2642 and ProjectLeonida#2577; carried here so play windows work while they sit unmerged.
Wine's builtin d3dcompiler (the vendored vkd3d-shader) refuses our runtime HLSL helpers: RWByteAddressBuffer member methods fail E5005 and the [RootSignature] attribute is dropped, so every world-fill pass dies silently and the composite samples never-written planes - black world, UI fine. Compile through DXC (*_6_0) on refusal or a missing RTS0 chunk, and build the composer/trainer root signatures programmatically through D3D12SerializeVersionedRootSignature v1.1 instead of the HLSL chunk. Same direction as open upstream PRs ProjectLeonida#2642 and ProjectLeonida#2577; carried here so play windows work while they sit unmerged.
|
A Linux/NVIDIA data point from a machine that went through this exact wall: on Wine the builtin d3dcompiler_47 (vendored vkd3d-shader 2.1) refuses every runtime HLSL helper this tree compiles — no RWByteAddressBuffer member methods (E5005), The full measured env baseline for Linux play is posted on #2577. AI-assisted comment; measured logs (RTX 4090, NVIDIA 620.73.04, Wine 11.23, VKD3D-Proton master). |
KelboLive
left a comment
There was a problem hiding this comment.
Not superseded: git grep on current main finds no compile_named/compile_runtime_hlsl, and the SM 5.1 call sites still use D3DCompile. Merged into today's main it applies cleanly, builds, and the affected suites pass (compiler::tests 2/2 with the DXC test genuinely executing on the Windows SDK pair, compose 1, trainer 5, inplace_probe 1, merge::tests 1). The native-Windows gate is right (on_wine() via wine_get_version, compiler.rs:98, with the FXC call keeping name/entry/target/flags), and the DXC diagnostic path is mutation-covered (forcing dxc_errors to None fails compiler.rs:339).
Two things before merge:
- The "only
compiler.rscallsD3DCompile" invariant no longer holds after merge. Main gainedtexture.rs:4301(test-onlyalias_cast_tests) since your base. Please rebase and either route it through the new helper or restate the invariant as "runtime, non-test". - #2577 fixes the same Wine
[RootSignature]failure differently — it ships natived3dcompiler_47.dlland serialises root signatures incompose.rs/trainer.rs. The two approaches overlap on these exact files, so one should land first, or the DXC path should be documented as the replacement. This is worth settling before either merges, since both claim the same symptom.
Also: mutating the gate at compiler.rs:56 to if true leaves every test green — the Wine-vs-native routing is covered only by manual runs (here on_wine() is false, load_dxc() looks beside the test exe, and the tests call compile_dxc directly). A sentence saying that is intentional would save the next bisector.
The branch is 1,463 commits behind but the merged tree is green; a rebase is for the invariant and CI, not for correctness.
Claimed in #2570:
D3D12-LINUX-DXC-RUNTIME-SHADERS(#2570 (comment))Summary
Implements
D3D12-LINUX-DXC-RUNTIME-SHADERSacrossd3d12/crates/leonida-gpuandd3d12/README.md(head9075a5e419):compiler.rs,lib.rs,README.md):compiler::compile_named(and diagnostics helpercompile_runtime_hlsl). On native Windows (wine_get_versionabsent onntdll.dll), every shader continues to compile via systemD3DCompilewith its original profile and flags untouched.flags & !D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES == 0and the target iscs_5_1,ps_5_1, orvs_5_1,compile_namedloadsdxcompiler.dlland preloadsdxil.dllfrom the executable's own directory usingLOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32and compiles ascs_6_0/ps_6_0/vs_6_0(-HV 2016 -flegacy-macro-expansion -O1), preserving[RootSignature(...)]blobs, atomics, and unbounded descriptor arrays that Wine's built-in FXC strips or rejects. If the app-local DXC pair is absent,compiler.rswarns once and falls back to FXC.IDxcResult::GetOutput::<IDxcBlobUtf8>(DXC_OUT_ERRORS, ...)(withGetErrorBufferfallback) and logs compile errors withtracing::warn!("DXC: ...")to match FXC error logging.[RootSignature]shaders throughcompiler::compile_named(host.rs,compose.rs,host/trainer.rs,indirect.rs,indirect/bench.rs,inplace.rs,replay/play/merge.rs):host::compile(coveringambient.rs,descriptor/host.rs,host.rsdepth planes,host/awake.rs,host/card_steps.rs,host/send.rs,host/upcheck.rs,resource.rs, andtiles.rs),Host::make_card_work(CARD_COMPARE),compose::compile_source(Composer::new),host::trainer::compile(F4 trainer overlay),indirect(WIDE_PROBE, argument clamp, andindirect::bench),inplace::Rig::shade(LEONIDA_INPLACE_PROBE), andreplay::play::merge(Player::set_merging) throughcompiler::compile_named, leavingcompiler.rsas the soleD3DCompilecaller ind3d12/.ambient_readback.rs,tests/replay.rs):ambient_readback::radiance_changes_the_fog_readback(#[ignore]) to exercise the radiance and volumetric-fog passes directly on physical hardware without frame capture.tests/replay.rsto compile synthetic replay HLSL throughcompile_runtime_hlsl, add the missingNON_PIXEL_SHADER_RESOURCE -> COPY_DESTbarrier onself.shared.0, and detectID3D12DXVKInteropDeviceso tests do not submit interposed command lists to backends requiring native list identity.Verification
dxcompiler.dll+dxil.dll):git grep -n "D3DCompile" d3d12/-> onlyd3d12/crates/leonida-gpu/src/compiler.rs.cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib compiler::tests -- --test-threads=4->2/2passed (verifies both native FXCcompile_namedand DXCcs_6_0compilation +CreateRootSignature+CreateComputePipelineStateonCARD_COMPARE, unbounded descriptor tables, and UTF-8DXC_OUT_ERRORSdiagnostics on invalid HLSL).cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib compose -- --test-threads=4(2/2) &cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --features diagnostics --lib compose::tests::composes_scaled_premultiplied_plane_on_gpu -- --test-threads=4(1/1, RGBA[127, 0, 0, 255, 64, 127, 0, 255, 0, 0, 255, 255]) -> passed (FXC + DXCvs_6_0/ps_6_0root signature + GPU readback).cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib host::trainer::tests -- --test-threads=4->5/5passed (the_overlay_draws_the_menu_offscreen+ FXC/DXCvs_6_0/ps_6_0root signature).cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib inplace::tests::inplace_probe_shader_compiles_with_embedded_root_signature -- --test-threads=4(1/1) &cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --features diagnostics --lib replay::play::merge::tests -- --test-threads=4(1/1) -> passed (FXC + DXCcs_6_0root signature + PSO).cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib indirect::tests -- --test-threads=4(23/23),cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib ambient -- --test-threads=4(3/3), andLEONIDA_AMBIENT=1 LEONIDA_AMBIENT_AIR=1 cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib ambient_readback -- --ignored --test-threads=1(1/1, packed fog readback[80200400, 701c0380, 00000000, 781e03c0]) -> passed.cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --features diagnostics --test replay -- --test-threads=4(a_frame_is_recorded_and_replayed) &LEONIDA_TEST_D3D_ADAPTER=0 cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --features diagnostics --test replay the_offscreen_draw_samples_its_unbounded_texture_table -- --ignored --test-threads=1(fixed=1024 other=1765) -> passed.cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-gpu --tests&--features diagnostics->0warnings across all new/modified code.python -I scripts/check_no_game_data.py->0issues, pure LF,0UTF-8 BOM across all 13 branch-touched files.gfx906, RADV26.0.8, Khronos sync validation):9e5225ce9c, DXC1.9.2609):11/17previously failingleonida-gpustock tests turned green (9indirect::tests,ambient::tests::the_passes_build, and depth-plane draw) plus unbounded texture-array offscreen draw (fixed=1024, other=1765) and ambient fog readback (2, 0.5, 0, 1) with0Vulkan validation errors or sync hazards.RTX 4070 SUPER&Radeon 610M):9075a5e419merged onto7b907de52, CachyOS, Wine 11.22, VKD3D-Proton71cae091, DXC1.9.2609):indirect::tests::argument_clamp_buildsandindirect::tests::host_list_batcheswent from0/2without the app-local DXC pair to2/2with it on both GPUs.GPUs tested: NVIDIA GeForce RTX 3090 (Windows 11, driver 610.88), AMD Radeon Pro Vega II (Linux RADV 26.0.8, GE-Proton11-14 / VKD3D-Proton 3.1), plus independent check on NVIDIA GeForce RTX 4070 SUPER and AMD Radeon 610M (CachyOS Wine 11.22 / VKD3D-Proton)
AI-assisted: yes
Checklist
mainand merges cleanly.CONTRIBUTING.md), including in logs or reports quoted here.docs/design.md, with how it was confirmed. (n/a: runtime HLSL compilation only)