Repository navigation
GPU: build the indirect-argument clamp with our own writer (no shader compiler at run time) - #190
LaunchDoesntCode wants to merge 1 commit into
Conversation
The clamp was HLSL compiled at run time by the system's D3DCompile. Wine's d3dcompiler_47 rejects it (no Load on RWByteAddressBuffer, no store to a structured buffer, and the RootSignature attribute is ignored), so under Wine and Proton clamp() failed and every indirect execution was dropped. The same shader is now emitted as DXIL by the shader crate (emit::clamp::argument_clamp) and its root signature is made from a description, so no shader compiler is needed on any host. For that the shader builder learns root UAVs (raw buffers), beside root CBVs and SRVs. Two GPU tests run the clamp over records of each kind and compare with the bounds written out in Rust, and check that records past the list's budget run empty. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Reviewing |
| /// 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> { |
There was a problem hiding this comment.
The DirectX IL matches op for op with the old HLSL. Same limits, branches etc so it's fine
|
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 Build:
The failures left on this branch are the same ones that fail on Against #178: |
|
Tested
No game data used. |
|
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 |
|
I'd refactor this into its own little garden so as Wine/Proton support increases, it can be pruned |
|
Tested on Linux under Proton, where the clamp is the only thing between the world and dropping every indirect execution. Setup
Without this PR (main 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; Report written with Claude Code (Claude Opus 5.5) from runs on my machine. |
|
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 (
What's still dropped on the stacked builds is 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 So on RADV, #190 (at Counts only, no game data. AI-assisted (Claude Code). |
|
For the open validator question: Microsoft’s Windows This verifies the emitted container with the Microsoft validator. Native Windows pipeline creation remains a separate check. |
|
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), Tested:
Run with Full suites, passed / failed / ignored:
Notes:
AI-assisted (Claude Code), from runs on my machine. |
|
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 Setup
GPU verification
The 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 verificationI ran the local Series X With
These were diagnostic runs with separate caches and different skip lists. The baseline skipped three confirmed crashing compute shaders. The patched run also skipped The patched run still exited with AI-assisted testing and log analysis. Log excerpts and test results only. |
|
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,
Synthetic 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 |
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
Closes #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 Wine/vkd3d: deferred uploads are skipped because VirtualQuery() reports mapped memory as MEM_FREE #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