GPU: an argument clamp Wine's compiler builds too #1279
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!1279
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1279"
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?
@Mumogg on GitHub · 2026-11-24 17:04 UTC · original
Mumogg:gpu/indirect-clamp-wine→main· +131 −17 · 1 files · 2 commits · openProblem
Under Wine, every indirect execution is dropped. The clamp of indirect arguments (
crates/victory-gpu/src/indirect.rs) is HLSL compiled at run time withD3DCompile, and Wine'sd3dcompiler_47(vkd3d-shader's HLSL compiler) refuses it:indirect::boundthen returns false for every record andexecute_indirectreportsnot bounded (no clamp, or arguments not 4-byte aligned). In the world that is most of the frame: in one run here, per world frame on average, 1,449 mesh dispatches (kind 10), 776 dispatches (kind 2), 285 draws (kind 0) and 79 indexed draws (kind 1) were dropped for that reason alone. Filed first as #909 (PRs from outside contributors were closed at the time); anyone testing under Wine or Proton with the builtin compiler has it.Wine's compiler has a second gap that the first one hides: it ignores the
RootSignatureattribute (W5302: Ignoring unknown attribute "RootSignature"), so the compiled blob has noRTS0part andCreateRootSignaturefrom the shader bytes would fail next.Change
One file, the clamp only:
argsandbudgetareRWStructuredBuffer<uint>instead ofRWByteAddressBuffer, indexed in words.boundalready refuses addresses and strides that are not multiples of 4, so the same words are read and written. A root descriptor can be a structured buffer.D3D12SerializeVersionedRootSignaturebeside the shader, aspipeline/host.rsdoes for its own, instead of being read from the shader blob.InterlockedAddon it are unchanged.Testing
RTX 5070 Ti, driver 615.78.08, Nobara 44, Wine 11.21 Staging, vkd3d-proton and DXVK
dxgi.dllfrom GE-Proton11-14, diag build cross-compiled on Linux, Series X 1.0.2.1, network off.D3DCompile(cs_5_1) from both Wine's builtind3dcompiler_47and Microsoft's (a small test program, run under Wine with and without the native DLL). The old source compiles only with Microsoft's.ffe310e+ #454 #177 #259 #233 #646 #578 + the #783 fallback), one 450 s run each:d3dcompiler_47.dllbeside the exeargument clampwarningnot boundeddropsWith the clamp in place the next reasons for dropped indirect work are pipelines still being made, wave64 mesh programs refused by #578 on this 32-lane host, and shaders that do not translate.
cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings(targetx86_64-pc-windows-msvc) is clean.Verified by others in #909 (on this same commit,
f2a71ac):Not tested: native Windows on a hardware GPU, AMD, and
cargo teston my side (the existingargument_clamp_buildstest covers this path on a machine with a GPU).A workaround without this change: put Microsoft's
d3dcompiler_47.dllnext tovictory.exeand addd3dcompiler_47=ntoWINEDLLOVERRIDES.AI-assisted (Claude Code): it found the cause from the logs, wrote the change and this text, and ran the tests on the machine above. No game data attached.
Closes #909.
🤖 Generated with Claude Code
The clamp of indirect arguments is HLSL compiled at run time by the system's compiler. Under Wine that is vkd3d-shader's, which has no methods on byte address buffers and ignores the RootSignature attribute: argument clamp: clamp:19:27: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'. Without the clamp every indirect execution is dropped ("not bounded"), which is most of the world's draws and dispatches. The buffers become structured buffers of uint, indexed in words (the caller already refuses addresses and strides that are not multiples of 4), and the root signature is serialized beside the shader instead of read from it. The bounds and the budget are unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]>@muhammed-aksoy on GitHub · 2026-11-24 17:55 UTC · original
I independently tested
4dd4cfcagainst mainffe310eon Windows. The GPU diagnostics suite passed 54 tests with one ignored. In a local batch with #1283, #1307, #1309, and #1311, the all-features workspace suite passed 360 tests with six ignored and zero failures. WARP was selected, and Clippy and asset policy passed at local batch commit 1409f9c. These runs used synthetic fixtures. AI-assisted.@Mumogg on GitHub · 2026-11-24 17:10 UTC · original · edited 2026-11-24 19:08 UTC
Added MichaelSmithAI's readback test from #909 to this branch (
4dd4cfc, test-only, 36 lines inindirect.rs's test module): it runs the clamp over draw, indexed draw, mesh and compute records sharing one budget and compares every word, padding included.Run here on
4dd4cfc, RTX 5070 Ti (driver 615.78.08), Wine 11.22 Staging, vkd3d-proton from GE-Proton11-14, Wine's builtind3dcompiler_47:argument_clamp_buildsandclamp_preserves_record_offsets_and_shared_budgetboth pass.cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warningsis clean.One thing for anyone repeating it under Wine: run the test binary with its own wineserver. Started against a wineserver that lives in another user namespace,
WriteProcessMemoryon the current process returns access denied, the copy back is silently skipped and the comparison fails although the GPU wrote the right words.(AI-assisted, Claude Code.)
Edit: the Wine version was 11.22 Staging, not 11.21 (the system had updated before these runs).
@wwwwwwww3333333 on GitHub · 2026-11-24 19:16 UTC · original
Native Windows run on AMD: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head
4dd4cfcon mainffe310e(clean merge).cargo test -p victory-gpu --lib -- --test-threads=1: 51 passed, 0 failed, 1 ignored (main alone: 50).indirect::tests::clamp_preserves_record_offsets_and_shared_budgetpasses on this machine, and so does the existingargument_clamp_buildspath. That adds an AMD hardware GPU to the RTX 5070 Ti and WARP results already here.Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
@Marvisak on GitHub · 2026-11-25 01:20 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-gpu/src/indirect.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
@ntgata1-dotcom on GitHub · 2026-11-25 13:39 UTC · original
Rebased onto
main(940d32f); the clamp now passes all its tests under Wine's own compilerThe branch needed a rebase across
4ab20fc("GPU: the indirect budget is charged in record order and no longer wraps"), which rewrote the clamp's budget onmain. In case it saves you time, I did it and kept both commits with their authors (yours and swarm's): https://github.com/ntgata1-dotcom/VIctory/tree/rebase-1279 (9113f41,93dfd4e).The conflict resolution:
main's algorithm: one group walks the records in tiles of 64 and charges them in order, withDispatch(records.min(1), 1, 1)as onmain. It's written with this PR'sRWStructuredBuffer<uint>in words:budget[0],args[at] = 0,at = record * (stride / 4).main's with word indexing. There's noLoad/Storeand no[RootSignature(RS)]left, because the root signature is made beside the shader as in this PR.gpu_writes's newmarkedargument. I passedfalse, asmain's own callers do for writes that don't mark pages.Tested on Arch Linux, RX 9070 XT (RADV), system Wine 11.22, with vkd3d-proton
v3.1-83-gcae8353edand DXVKdxgifrom GE-Proton11-14.cargo xwin test --locked --no-fail-fast -p victory-gpu, runnerwine:victory-gpuindirect::testsmain940d32f, Wine'sd3dcompiler_47d3dcompiler_47d3dcompiler_47(indirect::only)No other test changes against
main.cargo xwin clippy -p victory-gpu --all-targets --locked -- -D warnings, default and--all-features, is clean. Not run: Windows itself.If you'd rather rebase it yourself, ignore this. To take it:
git fetch https://github.com/ntgata1-dotcom/VIctory rebase-1279 && git reset --hard FETCH_HEAD && git push --force-with-lease.AI-assisted (Claude Code); numbers from my own runs.
@ntgata1-dotcom on GitHub · 2026-11-25 16:44 UTC · original · edited 2026-11-25 16:51 UTC
The rebased branch makes the world draw under stock Wine (RX 9070 XT, RADV)
A world run of the rebased branch (
940d32f+9113f41+93dfd4e, nothing else), againstmain940d32fon the same machine. Setup: Arch Linux, RX 9070 XT (RDNA4), RADV / Mesa 26.3.1, system Wine 11.22 with its built-ind3dcompiler_47, and vkd3d-protonv3.1-83-gcae8353edand DXVKdxgifrom GE-Proton11-14. Release builds, the first mission's opening cutscene. The numbers are over the frames after the mission's data loaded, leaving out the loading screen.mainno argument clamp)argument clampwarningE5005: Method 'Load' is not defined on type 'RWByteAddressBuffer')At least 5 minutes in the world with no crash, no exception and no amdgpu message in the kernel log.
The run then stopped about 7½ minutes into the world, on the title's own
0x80000003, 7 times at once, at the same place as a build with five more PRs on top. That's the stop #698 reports on Windows, where the clamp already builds, so it doesn't look like it comes from this PR.So under Wine's own compiler, this PR is what turns the black world into a drawn one here.
AI-assisted (Claude Code); numbers from my own runs.
@arogan178 on GitHub · 2026-11-25 23:52 UTC · original
Carried onto current
mainin #2913, as the triage on #2744 invited.mainnow charges records in tile order and clamps into a separate destination buffer, so the shader was ported, not cherry-picked. Your root-signature code is kept, and you're credited as co-author. With Wine's built-in compiler under Proton, the clamp tests go from 0 of 6 to 7 of 7.@neonbyte1 on GitHub · 2026-11-26 01:48 UTC · original
mainrewrote the argument clamp since this PR, so I ported your approach onto it in #2969: structured buffers indexed in words, and the root signature built in Rust beside the shader. I extended it to the depth twin's 16-bit conversion, which fails under Wine the same way. Your PR is credited there. Tested in game on an RTX 5090 under Wine: thenot boundedindirect drops (about 5,300 a frame) are gone. If you'd rather update this PR instead, I'm happy to close mine.AI-assisted (Claude).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.