Skip to content

GPU: compile the indirect-argument clamp with DXC when D3DCompile refuses it (Wine/Proton) - #178

Closed
Ortomanic wants to merge 3 commits into
Marvisak:mainfrom
Ortomanic:pr/indirect-clamp-dxc
Closed

Ortomanic wants to merge 3 commits into
Marvisak:mainfrom
Ortomanic:pr/indirect-clamp-dxc

Conversation

@Ortomanic

Copy link
Copy Markdown

What

Under Wine/Proton, D3DCompile is Wine's d3dcompiler_47 (vkd3d-shader HLSL), which rejects the argument clamp:
clamp:19:27: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'.
clamp() then fails and every indirect execution is dropped on Linux.

Change

If D3DCompile fails, the same source is compiled with DXC (dxcompiler.dll, which shader validation already needs) as cs_6_0; the root signature stays inside the shader. Behaviour on Windows, where D3DCompile succeeds, is unchanged. Adds the Win32_Graphics_Direct3D_Dxc feature to windows (no new crates; Cargo.lock unchanged).

Testing

  • cargo check for x86_64-pc-windows-msvc, with and without diagnostics.
  • GTA VI under Wine 11.22 + vkd3d-proton (RTX 5080): the log shows the D3DCompile refusal followed by the DXC path, and indirect executions now run instead of all being dropped.

…piler refuses it

Wine's d3dcompiler_47 (vkd3d-shader HLSL) rejects RWByteAddressBuffer.Load
(E5005), so under Wine every indirect execution was dropped. The same source
now goes to dxcompiler.dll (cs_6_0, root signature inside) instead.
@DaviTostes

Copy link
Copy Markdown

Tested dd6f75a under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: the fallback works, and it fixes the clamp on the Wine path.

  • With Wine's builtin d3dcompiler_47 (which rejects the clamp with E5005) and no dxcompiler.dll: indirect::tests::argument_clamp_builds still fails, i.e. the fallback needs the DLL.
  • With dxcompiler.dll on the DLL search path (taken from an installed Chromium build): argument_clamp_builds passes, and the suite is 41 passed, 2 failed, 1 ignored — the two failures are the environment-only a_rejected_blob_gives_an_empty_library (vkd3d wants a non-empty blob) and Wine/vkd3d: deferred uploads are skipped because VirtualQuery() reports mapped memory as MEM_FREE #128. With Microsoft's d3dcompiler instead, the result is the same 41/2, so DXC and FXC both give a working clamp here.
  • Deployment note: Wine does not ship dxcompiler.dll; anyone running this path needs to provide it (DXC redistributable or a game's copy) for indirect execution to work. Worth a line in the README next to the Wine notes.

With the 12 indirect tests from #40 merged on top this would exercise the whole path; on its own branch those tests are not present yet.

No game data used.

@SkippySteve

Copy link
Copy Markdown

Tested this independently on Linux under UMU-Proton. I used only crate tests: no game data, no title run, and VICTORY_GAME_DIR was unset.

Environment

  • Host: Arch-based Linux, kernel 7.2.15. GPU: RTX 2060 SUPER on NVIDIA 615.78.08.
  • Proton: UMU-Proton-11.0-2e (wine-11.0) with its bundled vkd3d-proton (vkd3d-1.1-5153-g212991fc). It ran inside the steamrt4 container, launched the same way umu-run does (_v2-entry-point --verb=waitforexitandrun -- proton waitforexitandrun), in a fresh prefix.
  • Build: cross-built from Linux with cargo xwin (xwin CRT/SDK, clang-cl, lld-link), toolchain 1.98.1.
  • Head tested: dd6f75a (fetched from pull/178/head), compared against main at d2a4bae.

Build

  • cargo xwin check -p victory-gpu --target x86_64-pc-windows-msvc passes.
  • cargo xwin check -p victory-gpu --features diagnostics --target x86_64-pc-windows-msvc passes.
  • cargo xwin test -p victory-gpu --target x86_64-pc-windows-msvc --no-run builds.

Tests under Proton
The existing indirect::tests::argument_clamp_builds exercises the changed path end to end: vkd3d-proton gives a real host device, so the test does not skip. For these runs I added a local tracing subscriber to the test so the log lines show up; that change was never committed.

Build argument_clamp_builds Full victory-gpu suite
main FAIL 40 pass / 3 fail / 1 ignored
PR, no dxcompiler.dll on the search path FAIL (same as main) 40 / 3 / 1
PR, dxcompiler.dll + dxil.dll (DXC v1.9.2609) next to the exe PASS 41 / 2 / 1

What the logs show:

  • On main, the system compiler refuses the clamp with E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'. The log then says no argument clamp: indirect execution dropped (0x80004005). That is the bug described in this PR, reproduced.
  • On the PR with DXC present, the log shows the same refusal and then trying DXC. The clamp is built: CreateRootSignature and the compute PSO succeed under vkd3d-proton.
  • On the PR without DXC, LoadLibraryW fails with Module not found (0x8007007E) and the run falls back to the old behaviour. That is not a regression, but stock Proton does not ship dxcompiler.dll. On Linux the fix only takes effect if VIctory's existing shader-translation requirement already puts DXC on the search path.

The two remaining failures fail the same way on main, so they are already there and unrelated to this PR:

  • pipeline::library::tests::a_rejected_blob_gives_an_empty_library
  • resource::tests::buffer_data_reaches_the_host_texture (fails its row 0 assert)

Non-blocking nit: when DXC's GetStatus fails, the DXC error text (DXC_OUT_ERRORS) isn't logged. That would help if the shader ever stops compiling under DXC.

Recommendation: merge, from a Linux/Proton point of view. The fallback does what it says, nothing changes on the path where D3DCompile succeeds, and no tests regressed.

@Sunkiller-qc

Copy link
Copy Markdown

The fallback idea makes sense for Wine, but nothing in VIctory ships or locates dxcompiler.dll. Translation only loads dxil.dll (from VICTORY_DXIL or the Windows Kits folder, victory-shader/src/emit/validator.rs:121), so the comment at indirect.rs:153 saying shader translation "already needs" it isn't accurate. As written, LoadLibraryW(w!("dxcompiler.dll")) (crates/victory-gpu/src/indirect.rs:85) only works if the user has put the DLL on the search path. It also loads by bare name, while the rest of the crate restricts system DLLs with LOAD_LIBRARY_SEARCH_SYSTEM32 (root.rs:64).

Maybe look for dxcompiler.dll beside the dxil.dll that Validator::default_path() finds (the SDK ships them together), with an env override, and note the requirement in the Proton docs (#149)?

Static review, not built or run.

Review on Marvisak#178: load DXC from VICTORY_DXC, beside the dxil.dll that shader
validation finds, then only the executable's folder and System32 (no bare
LoadLibraryW search path). When DXC refuses the clamp, its error text is
logged. README notes the Wine/Proton requirement.
@Ortomanic

Copy link
Copy Markdown
Author

Thanks for testing (RADV, UMU-Proton/RTX 2060 SUPER) and for the review. Pushed f435ad1, which addresses it:

  • dxcompiler.dll is now loaded explicitly: VICTORY_DXC (the DLL or its folder), then beside the dxil.dll that Validator::default_path() finds (the SDK ships them together), then only the executable's folder and System32 (LoadLibraryExW with LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | DEFAULT_DIRS for paths, APPLICATION_DIR | SYSTEM32 for the bare name). No more bare LoadLibraryW.
  • When DXC refuses the source, its error buffer is logged (@SkippySteve's nit).
  • The misleading comment is fixed, and the README notes that Wine/Proton users need dxcompiler.dll + dxil.dll for indirect execution.

Checked: cargo check for x86_64-pc-windows-msvc with and without diagnostics.

@deadkid14

deadkid14 commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested on Linux: RTX 5070 Ti, driver 620.73.04, GE-Proton11-14's vkd3d-proton. #178 was merged into a diag build of d2a4bae with other open PRs (#177, #454, #189, #493, …), with DXC 1.9.2609's dxcompiler.dll and dxil.dll in a folder named by VICTORY_DXC.

The log shows Wine's D3DCompile refusing the clamp (E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer') and then the DXC path building it. No "DXC failed too".

In one traced world frame, dropped operations went from 4,273 (every indirect execution, "not bounded") to 2,836, and the G-buffer's writers that run went from 211 to 1,043. Details in #71.

AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.

@aycow

aycow commented Nov 24, 2026

Copy link
Copy Markdown

I composed #40 at 22b9ed1 with #178 at f435ad1. The in-process x64 Windows SDK DXC 1.7.2308.16 successfully compiled the clamp and reported that its DXIL signing library was unavailable. The resulting container had a zero digest, and native D3D12 rejected its pipeline as unsigned.

The focused change uses VIctory's existing DXIL validator with the selected compiler's companion library to validate and sign an unsigned fallback blob. The resulting digest matched the same SDK's dxc.exe output. With the change, all 14 indirect cases passed on both AMD and WARP in enhanced and forced legacy modes, with native FXC and with the DXC path forced. Full GPU-based validation was enabled. The isolated fix cherry-picks cleanly onto your exact #178 head. Signer fix · Composition and reproduction

The Windows SDK 26100 DXC DLL can compile a valid shader without finding its sibling signing library. Native D3D12 then rejects the unsigned shader. Sign only zero-digest output with the existing DXIL validator, resolving a sibling from the loaded compiler path.

(cherry picked from commit f7411d0)
@Ortomanic

Copy link
Copy Markdown
Author

Thanks @aycow, good catch on the unsigned container from older SDK DXC. Cherry-picked your signer fix onto this PR with attribution (eb635f7, -x of f7411d0). It reuses VIctory's validator (VICTORY_DXIL, then the dxil.dll beside the compiler, then the Windows Kits one) to sign the blob only when the digest is zero. Windows type-check passes; the branch still merges cleanly with current main (ffe310e). Thanks also @deadkid14 for the RTX 5070 Ti run.

Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
…Marvisak#358 Marvisak#89 Marvisak#331 Marvisak#86 Marvisak#83 Marvisak#211 Marvisak#260 Marvisak#275)

Conflict in crates/victory-gpu/src/descriptor/host.rs: gpu-state (Marvisak#251)
moved the dynamic-slot search into free_table(); gpu-draw (Marvisak#86) bounds
the search by the heap's spare slots instead of DYNAMIC. free_table() works
over taken.len(), which is the spare count, so the helper is kept with
gpu-draw's spare-based cursor wrap. Both sides' tests kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ortomanic

Copy link
Copy Markdown
Author

Heads-up for reviewers: #994 (4828716, @Slaktarn700) solves the same problem differently. It writes the clamp with structured buffers, so Wine's d3dcompiler_47 accepts it and no DXC is needed. I ported it to our Linux/NVIDIA branch and it works there; its 2 GPU tests pass under Wine + vkd3d-proton. If #994 (or that commit on its own) lands, this PR is unnecessary, and I'll close it.

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
The tester tree (upstream main ffe310e plus its PRs, update 8; see its
INTEGRATION.md) ran 11-25 minutes in the world on an RTX 5070 without a
device removal. Where both sides carry the same PR (the wave64 stack
#223/#233/#320 with #439 and #180, #454, #336, #259, #331 and others), the
tester tree's newer head is taken; our own work and the PRs only we
merged are kept.

Conflicts, file by file:

- descriptor/host.rs: the tester layout (`spare`, the guard slot after the
  dynamic slots, `free_table`, the capped sampler heap). A capped view
  heap keeps `capped_reserve()` dynamic slots, now 2^18 by default (the
  tester measurement, and our 91fed158), still `VICTORY_DYNAMIC_SLOTS` in
  diagnostics builds; uncapped hosts keep our 2^19. Our slot statistics
  (TAKEN/PEAK/SHORT), the bindless plan cache (`CommittedRegions`,
  `timed_valid_title_address`, `timed_find`, `title_bounds`) and the
  revision triple are kept beside the tester's `guard_slot`.
- Buffer states: the tester tree's buffer-state tracker (#334: every list
  moves host copies of title memory between GENERIC_READ and
  UNORDERED_ACCESS and back to common before it closes) and depth twins
  (#469) are taken. #40's enhanced/legacy indirect barriers (the indirect
  prelude, `use_indirect_buffers`, the title buffer handoff mirrored in
  `host_barrier`) cannot share buffers with that tracker and are dropped;
  #40's argument checks (`byte_len`, exact spans, overflow-safe clamp
  shader, aligned counts) stay. `indirect::bound` and #282's
  `rectangles` go through `buffer_state`, and `indirect::execute` (#334)
  replaces `done`. #178's DXC fallback compiles both of our passes.
  Our segments (#387: `close` ends the segment, `close_native` closes a
  native list) carry the tracker: each native list returns its buffers
  to common and its twins to their depth targets, and each prelude also
  holds our texture uploads.
- shadow.rs: our write flow (`queue_write`, one `snapshot` after the
  batch's refreshes, `finish_writes`, the unchanged-page cache) with
  #261's copy-back that also gives the snapshot the title's bytes; its
  tests run through our flow.
- pipeline/make.rs: #275's per-frame budget and per-pipeline wake pair,
  with our compute waits (a dispatch waits for its pipeline, up to 20 s).
- pipeline/library.rs: the tester version (#347, #275's saver thread);
  our concurrent-write test kept. shader_cache.rs: our byte-returning
  cache API with #358's "translated, only not kept".
- draw.rs: #493's root SRV tables; where no table can stand in, our
  drop of a draw whose root view is unset or outside title buffers. Our
  refusal of a table offset past the capped heap stays.
- resource.rs: `HostTexture` has both our `staged` generation and the
  depth twin.
- Shaders: the tester's lower.rs for the wave64 stack, #160's image
  sampling (it covers our #73 and #136 sample forms) and #453/#587; kept
  from our side: #136's preference for an image or buffer use of a
  descriptor read as data and its `s_buffer_` arm, #422's nearest-even
  narrowing (also for #169's d16 loads and #453's interpolation), #452's
  spin-wait limit, #391's LDS limit, #302's spilled root arguments (now in
  `NativeProgram::translation_ir`), #136's PSV0 interpolation beside the
  tester's row harmonisation. split_tests.rs, lane_read_loop_tests.rs and
  docs/wave64-on-wave32.md are the tester versions (the same PRs at newer
  heads).
- Tests: #483's heap guard dwords filled in our GPU tests of #200
  (v_div_scale) and #437 (scalar loads from a raw view), which read
  through the guard slot otherwise; #334's debug-layer test passes an
  offset to our `indirect::bound`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
… when D3DCompile refuses it (Wine/Proton)
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
… when D3DCompile refuses it (Wine/Proton)
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 24, 2026
Reuse the compiler loader and signing path for the indirect clamp, depth twins, card comparison, and in-place probe

Based-on: Marvisak/VIctory#178
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
… when D3DCompile refuses it (Wine/Proton)
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 24, 2026
Reuse the compiler loader and signing path for the indirect clamp, depth twins, card comparison, and in-place probe

Based-on: Marvisak/VIctory#178
@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1279. Wine-only: when D3DCompile refuses the indirect-argument clamp it loads dxcompiler.dll (from VICTORY_DXC, beside dxil.dll, the exe folder or System32) and adds a windows-crate feature. #1279 solves the same problem by writing the clamp in HLSL both compilers take, with no external DLL and no Cargo change.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
Reuse the compiler loader and signing path for the indirect clamp, depth twins, card comparison, and in-place probe

Based-on: Marvisak/VIctory#178
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
Reuse the compiler loader and signing path for the indirect clamp, depth twins, card comparison, and in-place probe

Based-on: Marvisak/VIctory#178
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
Reuse the compiler loader and signing path for the indirect clamp, depth twins, card comparison, and in-place probe

Based-on: Marvisak/VIctory#178
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
Reuse the compiler loader and signing path for the indirect clamp, depth twins, card comparison, and in-place probe

Based-on: Marvisak/VIctory#178
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
Reuse the compiler loader and signing path for the indirect clamp, depth twins, card comparison, and in-place probe

Based-on: Marvisak/VIctory#178
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
FXC can reject required shader profiles under Wine. Reuse the DXC loader
and signing path for the indirect clamp, depth twins, card comparison,
and in-place probe so their runtime pipelines can still be created.

Based-on: Marvisak/VIctory#178
Tested-on: AMD Radeon RX 6800, Fedora Linux 45 (Wine/vkd3d-proton) (focused GPU tests on the integrated stack)
Assisted-by: gpt-6.2-sol
gmankab added a commit to gmankab/fxceless-victory that referenced this pull request Nov 25, 2026
With in-flight card fetches enabled, the comparison and clamp shaders
can reach FXC under Wine, where profiles with embedded root signatures
fail to compile. Use the runtime compiler fallback for both shaders so
the fetch setup can create its pipelines on Wine.

Based-on: fxceless#648
Based-on: Marvisak/VIctory#178
Tested-on: AMD Radeon RX 6800, Fedora Linux 45 (Wine/vkd3d-proton) (156 focused tests and a title launch)
Assisted-by: gpt-6.2-sol
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.

7 participants