GPU: build the indirect-argument clamp with our own writer (no shader compiler at run time) #190
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!190
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/190/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@LaunchDoesntCode on GitHub · 2026-11-24 01:16 UTC · original
gpu/clamp-as-dxil→main· +559 −103 · 8 files · 1 commits · closed without mergingCloses #170. An alternative to #178, which fixes the same thing by falling back to DXC; the comparison is at the end.
What
Under Wine and Proton,
indirect::clamp()fails and every indirect execution is dropped, because the clamp is HLSL compiled at run time byD3DCompile, and Wine'sd3dcompiler_47cannot compile it. As #170 records, rewriting the HLSL does not help: that compiler has no store to a raw or structured buffer and ignores the[RootSignature]attribute.This emits the same shader as DXIL with the shader crate's own writer and makes its root signature from a description, so no shader compiler is involved on any host.
Changes
victory-shader/src/emit/clamp.rs(new):argument_clamp()returns the clamp as a DXIL container. Same behaviour as the HLSL it replaces: one thread per record; draws, dispatches and mesh dispatches clamped in place with the same bounds; the cost added to the list's budget atomically; a record past the budget emptied.emit/shader.rs: the builder learns root UAVs (raw buffers) beside root CBVs and SRVs:root_uav_handle, theirdx.resourcesrecords and theirPSV0bindings. Translated shaders do not use it, so their output is unchanged.victory-gpu/src/indirect.rs:make()takes that DXIL and a root signature frompipeline::host::root_signature(nowpub(crate)).D3DCompileand theWin32_Graphics_Direct3D_Fxcfeature are gone.emit/host.rs(test harness):Root::Uav, a root UAV whose contents come back after the dispatch, androot_signature_of, split out ofroot_signature_for.Tested
Cross-built for
x86_64-pc-windows-msvcon Linux Mint, Proton 10.0 (wine-10.0, vkd3d-proton), RTX 5090, driver 595.99.2,mainatd2a4bae:indirect::tests::argument_clamp_builds: fails onmain, passes here.emit::clamprun the clamp and read the buffers back:records_are_clamped_in_place: records of all four kinds against the bounds written out in Rust, the untouched fourth dword of each record, a record past the count left alone, and the budget's total.records_past_the_budget_run_empty: a record that fits exactly, one that crosses the budget and one after it is spent, for draws and for a dispatch.cargo test -p victory-shader: 70 passed, 1 failed (stub_pipeline_is_created, which fails the same way onmainunder Proton).cargo test -p victory-gpu: 41 passed, 2 failed, both failing onmaintoo (a_rejected_blob_gives_an_empty_library, andbuffer_data_reaches_the_host_texture, which is #128).Not tested: Windows, and the title
dxil.dllvalidation of this particular module and a run on a Windows driver are unchecked. A Windows run ofcargo test -p victory-shader clampand-p victory-gpu argument_clampwould settle it.VICTORY_INDIRECT=1under Proton this should turn "indirect execution dropped" into executed draws; I have not captured that.Against #178
dxcompiler.dllin the prefix whenD3DCompilerefusesThey are not exclusive in spirit but they do touch the same function, so only one should land. #178 is the smaller change and is already seen working in the title; this one removes the dependency instead of adding a second compiler. Your call.
No game data used. AI-assisted (Claude Code).
🤖 Generated with Claude Code
@raffclar on GitHub · 2026-11-24 01:16 UTC · original
Reviewing
@raffclar on GitHub · 2026-11-24 01:19 UTC · original
This will conflict with #178 and #40 They're all touching
indirect.rsand it's getting a little hectic. Worth noting for merge order@SkippySteve on GitHub · 2026-11-24 01:25 UTC · original
Independent run of #190 under Proton on a second machine. Synthetic crate tests only; no game data and no title run.
Host: Arch Linux (kernel 7.2), RTX 2060 SUPER, NVIDIA 615.78.08. Runtime: UMU-Proton 11.0-2e (its
files/bin/wine), a fresh dedicated prefix,WINEDLLOVERRIDES="d3d12=n;d3d12core=n;dxgi=n;d3d11=n"so the prefix's vkd3d-proton and DXVK DLLs are used.+loaddllshows natived3d12.dll/d3d12core.dll, and vkd3d-proton reports SM 6.8.Build:
cargo xwin test --target x86_64-pc-windows-msvc -p victory-shader -p victory-gpu --no-runatffa1310, then the test exes run underwine.D3DCompile,Direct3D_Fxcanddxcompilerdo not appear anywhere in the tree on this branch, so the clamp is built with no runtime shader compiler.main@d2a4baeffa1310victory-gpu indirect::tests::argument_clamp_buildsclamp().is_some()atindirect.rs:215)victory-shader emit::clamp::tests::records_are_clamped_in_placevictory-shader emit::clamp::tests::records_past_the_budget_run_emptycargo test -p victory-shader, all testscargo test -p victory-gpu, all testsThe failures left on this branch are the same ones that fail on
mainhere:stub_pipeline_is_created,a_rejected_blob_gives_an_empty_libraryandbuffer_data_reaches_the_host_texture(#128). That is the same as your Proton 10 / RTX 5090 numbers, so the result holds on an older Turing card and a newer Proton.Against #178:
git merge-tree pr190 pr178conflicts incrates/victory-gpu/Cargo.tomlandcrates/victory-gpu/src/indirect.rs, as you said. Both changemake()/the Fxc feature, so only one of them can land as-is. I have not run this on Windows, so the opendxil.dllvalidation question from the PR body still stands.@DaviTostes on GitHub · 2026-11-24 01:26 UTC · original
Tested
ffa1310under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build, with Wine's builtind3dcompiler_47and nodxcompiler.dll: pass.indirect::tests::argument_clamp_buildspasses, and the suite is 41 passed, 2 failed, 1 ignored. The two failures are the environment-onlya_rejected_blob_gives_an_empty_library(vkd3d wants a non-empty blob) and #128.dxcompiler.dllon the host (Wine does not ship it, though it does work once the DLL is provided — 41/2 as well). Here no shader compiler is involved at all, so indirect execution runs out of the box under Proton.D3DCompilesucceeds, behaviour is unchanged. Keeping #178 as a fallback for hosts where both compilers refuse the source still seems worthwhile, but #190 alone unblocks the Linux path.No game data used.
@raffclar on GitHub · 2026-11-24 01:30 UTC · original
I think it's worth really thinking about whether to go down this route of adding DirectX's IL. It's more to maintain. This should be fixed upstream in Wine/Proton if possible
@raffclar on GitHub · 2026-11-24 01:31 UTC · original
I'd refactor this into its own little garden so as Wine/Proton support increases, it can be pruned
@xstraok on GitHub · 2026-11-24 08:32 UTC · original
Tested on Linux under Proton, where the clamp is the only thing between the world and dropping every indirect execution.
Setup
58fed37(main) with this PR'sffa1310merged on top, diag build (--profile diag --features diagnostics), cross-built forx86_64-pc-windows-gnuwith Rust 1.92.0Without this PR (main
8d23f07, same setup): Wine'sD3DCompile(vkd3d-shader) refuses the clamp:argument clamp: clamp:19:27: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'.so every indirect execution is dropped. World: 93–1,279 draws/frame.
With this PR: no clamp warning; world 1,151–3,005 draws/frame (last 8 stats lines), 1.4–3.2 s/frame, no device removal, no amdgpu page fault in the kernel log. The picture is still mostly black (shaders that do not translate), with some geometry and the post-processing (blur, chromatic aberration) visible.
Not tested: Windows; NVIDIA; release build;
cargo testunder Wine.Report written with Claude Code (Claude Opus 5.5) from runs on my machine.
@Exorion1er on GitHub · 2026-11-24 08:35 UTC · original
Tested in the title on Linux: RX 9070 XT (RDNA4), Fedora 44, kernel 7.3.5, Mesa 26.2.7 RADV. GE-Proton11-12's Wine with Proton Experimental's vkd3d-proton 3.2.0 (
d3d12,d3d12core,dxgi=n,b), nodxcompiler.dllanywhere. Diagnostics builds, Series X files, menus driven byVICTORY_KEYS,VICTORY_NO_WATCHDOG=1.mainf67c50cf67c50c+ #190 #454 #493 #579 #896db02ea+ #190 #454 #493 #579,VICTORY_SHADER_LOOP_LIMIT=32E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'→no argument clamp: indirect execution droppedWhat's still dropped on the stacked builds is
prepare failed (compute false, mesh false), not the clamp.With the stack, the scene reaches the G-buffer. At frame 1600 of the third run, the 2560×1440 depth target is about 92% covered and the richest
f28target about 85%, with the buildings and street correctly placed. The lighting targets (f26) are empty and the presented frame is black, like the Windows reports on #71. One run per column, so treat the numbers loosely, but the clamp result was the same in all three.So on RADV, #190 (at
ffa1310) does in the title what DaviTostes's test showed, without needing DXC.Counts only, no game data. AI-assisted (Claude Code).
@MichaelSmithAI on GitHub · 2026-11-24 10:55 UTC · original
For the open validator question: Microsoft’s Windows
dxil.dllaccepted the 3,012-byte production argument-clamp shader through VIctory’sIDxcValidatorwrapper under Wine. Microsoft’s Linuxdxvalso accepted it. The shader emitted atffa1310and after merging it ontoffe310ewas byte-identical, SHA-2569aeebc09369dab28bafc2182724063778e241ee7f065a4262f2e42cba5aef67e.This verifies the emitted container with the Microsoft validator. Native Windows pipeline creation remains a separate check.
@0xKaji on GitHub · 2026-11-24 14:46 UTC · original
Tested this PR (
ffa1310) under Wine +vkd3d-proton 3.2.0on an RTX 3060 8GB (driver620.73.04, CachyOS Linux7.3.5-2), both in the unit tests and in the live title through Stage (e) world rendering (timeout 120s, stacked onffe310e+ #177 + #347,VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains).Unit Tests (Windows
x86_64-pc-windows-msvcunder Wine11.22)victory-shader(emit::clamp): 2 passed, 0 failed (records_are_clamped_in_placeandrecords_past_the_budget_run_emptyboth pass on hardware).victory-gpufull suite (--test-threads=1): 50 passed, 0 failed, 1 ignored —indirect::tests::argument_clamp_buildsflips from failing onmain(d3dcompiler_47E5005) to passing.Live Title Result (
run3without #190 vsrun4with #190 + #347)victory_gpu::indirectfailed once withclamp:19:27: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'->no argument clamp: indirect execution dropped (0x80004005). World frames capped at767draws/frame, dropping2,589–5,080indirect executions per frame.argument clampDXIL compute shader compiled and ran cleanly (0clamp failures,0crashes,0NVIDIAXids). Live rendering in Stage (e) jumped >10× to7,823draws/frame (222mesh pipelines +113VS/PS +177compute built cleanly;frame-256.pnggrew from14 KBto2.2 MiB), with buffer copies reaching795.3 MB/1500.8 msGPU time. The >10× jump in draws/frame is the combined effect of this PR unlocking the indirect path plus #347 eliminating compile stalls; the clamp-specific change is 0 clamp failures andExecuteIndirectgoing from fully dropped to active.3,509indirect drops still seen in the last frame occurred only downstream (prepare failed/ scene pipeline still being compiled + 5 first-time indirect signatures such asstride=16/args=[0, ...]), not from the argument clamp itself.@rouges78 on GitHub · 2026-11-24 15:23 UTC · original · edited 2026-11-24 15:26 UTC
Native Windows run on NVIDIA, as asked for in the PR body. Synthetic crate tests only: no game data, no title run.
Host: Windows 11 Pro (build 26300), RTX 4080, NVIDIA driver 621.14 (32.0.16.2114),
D3D12Core.dll10.0.26100.9818, Rust 1.98.1, nativex86_64-pc-windows-msvc. The machine also has a Radeon iGPU, so I checked by adapter LUID thatD3D12CreateDevice(None)is the 4080 and that the WARP runs are the Microsoft Basic Render Driver.Tested:
ffa1310merged ontomain@ffe310e(clean merge), compared withffe310e.victory-shaderemit::clamp::tests::records_are_clamped_in_placevictory-shaderemit::clamp::tests::records_past_the_budget_run_emptyvictory-gpuindirect::tests::argument_clamp_builds(--features diagnostics)Run with
--nocapture --test-threads=1; none took the "no SM 6.6 device; skipped" path.argument_clamp_buildsreturns silently without a host, so I also ran a local probe (not part of the PR) that fails instead:make()returnedOkon both adapters. So the NVIDIA driver takes the hand-written DXIL: the root signature and the compute pipeline are created, and the two readback tests get the expected buffers and budget.Full suites, passed / failed / ignored:
main@ffe310ecargo test -p victory-shader, WARP (VICTORY_WARP=1)cargo test -p victory-shader, RTX 4080cargo test -p victory-gpu --features diagnostics, WARP (VICTORY_D3D12_WARP=1)cargo test -p victory-gpu, RTX 4080Notes:
dxil.dll: the native validator from SDK 10.0.26100 (1.8.2502.11) accepts the module and leaves our digest unchanged. 3,012 bytes, SHA-2569aeebc09369dab28bafc2182724063778e241ee7f065a4262f2e42cba5aef67e, the same hash MichaelSmithAI reported above.D3D12GetDebugInterfacereturnsDXGI_ERROR_SDK_COMPONENT_MISSING), so no info-queue messages were captured.diff_teststhat return early here ("no console compiler; skipped"). They are not the clamp tests.frame::tests::waits_end_on_ticks_and_count_frames(frame.rsis identical in both trees) failed in some runs of both trees with skipped ticks, e.g.[4, 5, 7, 8]atframe.rs:221, and in 0 of 60 later runs per tree. That is the late wake-up #985 already addresses. Thevictory-gpurows above are the runs without it.main's plain atomic add). Not run in the title; I don't have it.AI-assisted (Claude Code), from runs on my machine.
@hh-ze on GitHub · 2026-11-24 15:28 UTC · original
Verified #190 on an RTX 5060 Ti with NVIDIA driver 595.99.02. All three targeted GPU tests passed, and a Story Mode run got past the Wine
D3DCompilefailure that previously prevented the indirect-argument clamp from running.Setup
7.0.0-43-generic, Ryzen 5 760011.0 (Staging), vkd3d-proton buildcae8353ed7959c4, DXVKf90f1bf180f41351.98.1forx86_64-pc-windows-gnu, using--profile diag --features diagnosticsand a 16 MiB default thread stack234f049with #177 and #439. Cherry-picked this PR’sffa1310as local commit501c44e.VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains.GPU verification
victory-gpu·indirect::tests::argument_clamp_buildsvictory-shader·emit::clamp::tests::records_are_clamped_in_placevictory-shader·emit::clamp::tests::records_past_the_budget_run_emptyThe first test created the clamp pipeline. The two readback tests dispatched the shader on the RTX 5060 Ti and checked the resulting argument records and budget handling.
Story Mode verification
I ran the local Series X
1.0.2.1build. The baseline reproduced the failure from #170 when it reached world rendering:With
ffa1310applied, the run passed that point with the clamp active. These are samples from the last world-rendering intervals before each run exited:234f049ffa1310These were diagnostic runs with separate caches and different skip lists. The baseline skipped three confirmed crashing compute shaders. The patched run also skipped
a3d1a26ad0c8c2cd, which reproduced the crash in a standalone pipeline-creation test. The numbers describe those runs and should be read as diagnostic samples.The patched run still exited with
vkCreateComputePipelines Exception 0xc0000005 in Unix callafter reaching roughly 0.2–0.3 fps in the world. The GPU and desktop stayed responsive, and the kernel logged no NVIDIA Xid during the tests. The clamp fix worked on this setup. Playable world rendering remains blocked by the compute-pipeline crash and substantial remaining rendering drops.AI-assisted testing and log analysis. Log excerpts and test results only.
@x3ero0 on GitHub · 2026-11-24 18:35 UTC · original
One more NVIDIA data point, on a card not yet in this thread.
Setup: RTX 5080, driver 620.70, CachyOS (kernel 7.3.5), GE-Proton11-6's Wine with its bundled vkd3d-proton,
ffa1310cherry-picked ontomainffe310e(applies cleanly), cross-built withcargo xwinforx86_64-pc-windows-msvc.ffe310effe310e+ this PRindirect::tests::argument_clamp_buildsE5005: Method 'Load' is not defined on type 'RWByteAddressBuffer')emit::clamp::tests::records_are_clamped_in_placeemit::clamp::tests::records_past_the_budget_run_emptySynthetic tests only; I did not run the title on this tree.
For what it is worth as a cross-check of the design: I had written the same thing independently before finding this PR (#1470, now closed as a duplicate). That version gave the same buffers as the HLSL clamp compiled by DXC on 5,461 random records, on a native Linux build of vkd3d-proton, and Microsoft's
libdxil.so(DXC v1.9.2609) accepted its container.@ -0,0 +32,4 @@/// The clamp as a DXIL container. Its user data is four dwords: the kind/// of record (0 and 1 draws, 2 dispatches, else mesh dispatches), the/// records' stride in bytes, their count, and one unused.pub fn argument_clamp() -> Vec<u8> {@raffclar on GitHub · 2026-11-24 01:25 UTC · original
The DirectX IL matches op for op with the old HLSL. Same limits, branches etc so it's fine
@Marvisak on GitHub · 2026-11-25 00:20 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-shader/src/emit/host.rs,crates/victory-shader/src/emit/mod.rs,crates/victory-shader/src/emit/shader.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
Pull request closed