Wine: the indirect clamp can be built by Wine's compiler (tested on the retail title: 12 -> 4,515 draws/frame) #2744

Open
opened 2026-11-26 05:13:14 +00:00 by github-bot · 2 comments
Owner

@⁠YaBulochka on GitHub · 2026-11-25 19:27 UTC · original

Wine: the indirect argument clamp can be written so Wine's own compiler builds it — the world renders once it is (before/after on the retail title)

This is the practical half of #170: a rewritten clamp does get around E5005 on Wine 11.22, and the difference on the retail package is black-or-flat versus a real 3D frame. The working form is PR #1011 in fxceless/victory-fork; main has no RWStructuredBuffer in indirect.rs and no InterlockedMax, so it is not in yet.

Why the earlier rewrites failed. D3DCompile under Wine is vkd3d-shader's compiler, not Microsoft's. It has no Load/Store on RWByteAddressBuffer, no Interlocked* on it, and no [allow_uav_condition]. The form that it does take:

  • the buffers a shader writes are RWStructuredBuffer<uint>, indexed in words (dst_at = id.x * (stride / 4), copied words at + off / 4; budget words 0, 1 and 2 are the old bytes 0, 4 and 8) — a store to a structured buffer is implemented there, a store to a raw one is not;
  • the read-only source and the count stay ByteAddressBuffer, because Load on those builds;
  • Interlocked* are called as functions on the word, not methods;
  • [allow_uav_condition] is dropped (Microsoft's compiler builds the loop without it);
  • the root signature is serialized by the runtime, because Wine's compiler writes none for a [RootSignature] attribute.

Wine 10.0 cannot build it at all (GroupMemoryBarrierWithGroupSync, InterlockedAdd, structured-buffer stores are missing); 11.22 and Proton Experimental's wine can. That is worth saying in the docs, because "Wine" spans both.

Before/after on the retail 1.0.2.1 package, same machine, CachyOS 7.3.5, Ryzen 5 9600X, 30 GB, RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, vkd3d-proton built from master, x86_64-pc-windows-gnu:

before with #1011
clamp compile E5005: Method 'InterlockedMax' is not defined on type 'RWByteAddressBuffer' builds
no argument clamp: indirect execution dropped every run absent
indirect draws dropped kinds 0/1/2/10, ~2,500+/frame 0
draws/frame 12 (menus only) 12 in menus, 4,515 in the world
picture flat changing colour plus UI interior, character, street

I put the same numbers under #170 and the visual side of another Wine-only gap in fxceless/victory-fork#1072. Happy to hand the patch over as a diff or a branch if a collaborator wants to open the PR; it is one file plus the clamp constants, and it does not change the rules (MOST_DRAW, the 2^27 budget, one charge per group of 64).

No game files, dumps or screenshots are included.

**@⁠YaBulochka** on GitHub · 2026-11-25 19:27 UTC · [original](https://github.com/Marvisak/VIctory/issues/2744) Wine: the indirect argument clamp can be written so Wine's own compiler builds it — the world renders once it is (before/after on the retail title) This is the practical half of #170: a rewritten clamp **does** get around `E5005` on Wine 11.22, and the difference on the retail package is black-or-flat versus a real 3D frame. The working form is [PR #1011 in `fxceless/victory-fork`](https://github.com/fxceless/victory-fork/pull/1011); `main` has no `RWStructuredBuffer` in `indirect.rs` and no `InterlockedMax`, so it is not in yet. **Why the earlier rewrites failed.** `D3DCompile` under Wine is vkd3d-shader's compiler, not Microsoft's. It has no `Load`/`Store` on `RWByteAddressBuffer`, no `Interlocked*` on it, and no `[allow_uav_condition]`. The form that it does take: - the buffers a shader writes are `RWStructuredBuffer<uint>`, indexed in words (`dst_at = id.x * (stride / 4)`, copied words at `+ off / 4`; budget words 0, 1 and 2 are the old bytes 0, 4 and 8) — a store to a structured buffer is implemented there, a store to a raw one is not; - the read-only source and the count stay `ByteAddressBuffer`, because `Load` on those builds; - `Interlocked*` are called as functions on the word, not methods; - `[allow_uav_condition]` is dropped (Microsoft's compiler builds the loop without it); - the root signature is serialized by the runtime, because Wine's compiler writes none for a `[RootSignature]` attribute. Wine 10.0 cannot build it at all (`GroupMemoryBarrierWithGroupSync`, `InterlockedAdd`, structured-buffer stores are missing); 11.22 and Proton Experimental's wine can. That is worth saying in the docs, because "Wine" spans both. **Before/after on the retail 1.0.2.1 package**, same machine, CachyOS 7.3.5, Ryzen 5 9600X, 30 GB, RX 7600 XT 8 GB, RADV (Mesa 27.0.0), Wine 11.22, vkd3d-proton built from master, `x86_64-pc-windows-gnu`: | | before | with #1011 | |---|---|---| | clamp compile | `E5005: Method 'InterlockedMax' is not defined on type 'RWByteAddressBuffer'` | builds | | `no argument clamp: indirect execution dropped` | every run | absent | | indirect draws dropped | kinds 0/1/2/10, ~2,500+/frame | 0 | | draws/frame | 12 (menus only) | 12 in menus, **4,515** in the world | | picture | flat changing colour plus UI | interior, character, street | I put the same numbers under #170 and the visual side of another Wine-only gap in `fxceless/victory-fork#1072`. Happy to hand the patch over as a diff or a branch if a collaborator wants to open the PR; it is one file plus the clamp constants, and it does not change the rules (`MOST_DRAW`, the 2^27 budget, one charge per group of 64). No game files, dumps or screenshots are included.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:13:14 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 21:46 UTC · original

Automated triage for the maintainers.

Thanks for the before/after numbers. The cause is confirmed and tracked in #170. make() in crates/victory-gpu/src/indirect.rs on main (61bfc77) still compiles the RWByteAddressBuffer form, and nothing merged since changes that.

An open PR here already carries the same change: #1279 ("GPU: an argument clamp Wine's compiler builds too"). It uses RWStructuredBuffer<uint> indexed in words and serializes the root signature in code. It needs a rebase. Pull requests are open to everyone. If the fork's version differs from #1279 in a way that matters (for example, the call form of Interlocked* or dropping [allow_uav_condition]), please say so in a review on #1279 or open your own PR linking #170. The note that Wine 10 / Proton 10 cannot build it and Wine 11.22 can belongs in the docs; Wine notes are proposed in open PR #2082.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 21:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/2744#issuecomment-7175517407) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T19:27:55Z at=2026-11-25T21:49:00Z --> Automated triage for the maintainers. Thanks for the before/after numbers. The cause is confirmed and tracked in #170. `make()` in `crates/victory-gpu/src/indirect.rs` on `main` (`61bfc77`) still compiles the `RWByteAddressBuffer` form, and nothing merged since changes that. An open PR here already carries the same change: #1279 ("GPU: an argument clamp Wine's compiler builds too"). It uses `RWStructuredBuffer<uint>` indexed in words and serializes the root signature in code. It needs a rebase. Pull requests are open to everyone. If the fork's version differs from #1279 in a way that matters (for example, the call form of `Interlocked*` or dropping `[allow_uav_condition]`), please say so in a review on #1279 or open your own PR linking #170. The note that Wine 10 / Proton 10 cannot build it and Wine 11.22 can belongs in the docs; Wine notes are proposed in open PR #2082. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-26 07:38 UTC · original

One more data point for the route question: a dxcompiler.dll fallback for host shaders works too, and it covers both the clamp and a second shader the rewrite does not touch.

I implemented it in host::compile: when D3DCompile fails, the same HLSL is compiled by DXC as <stage>_6_0 (DxcCreateInstance + IDxcCompiler3::Compile, blob from DXC_OUT_OBJECT). VICTORY_DXC=1 forces it; otherwise it only runs on a failure.

  • The indirect clamp: our tree still carries the #1011 rewrite, so D3DCompile succeeds and DXC is never asked — that case is untested by me, so I cannot say whether the fallback alone would have replaced #1011.
  • The other one: the Series S stretch pass (GetDimensions on a RWTexture2D) fails with E5005 under Wine, and with the fallback it builds as cs_6_0. I reverted the hand patch I had written for it and the Series S profile still draws: the upscaler's output is made by a plain stretch.

Measured on CachyOS 7.3.5, RX 7600 XT 8 GB, RADV Mesa 27.0.0, Wine 11.22, retail 1.0.2.1: Series S, 152 consecutive world frames, average 3.99 fps, median frame 215 ms, 4,320 draws.

So the two routes are: rewrite each shader (no dependency, same SM5 as Windows), or a fallback (covers the whole class, adds two DLLs, and shifts those shaders to DXIL 6.0 through vkd3d). Which would the maintainers rather have here? If it is the fallback, I can send it as a diff; TobiasFornell independently confirmed the same approach under Proton on a 9070 XT (Belobug#183), so there would be two testers.

No game files or screenshots, numbers only.

**@⁠YaBulochka** on GitHub · 2026-11-26 07:38 UTC · [original](https://github.com/Marvisak/VIctory/issues/2744#issuecomment-7185666386) One more data point for the route question: a `dxcompiler.dll` fallback for host shaders works too, and it covers both the clamp and a second shader the rewrite does not touch. I implemented it in `host::compile`: when `D3DCompile` fails, the same HLSL is compiled by DXC as `<stage>_6_0` (`DxcCreateInstance` + `IDxcCompiler3::Compile`, blob from `DXC_OUT_OBJECT`). `VICTORY_DXC=1` forces it; otherwise it only runs on a failure. - The indirect clamp: our tree still carries the #1011 rewrite, so `D3DCompile` succeeds and DXC is never asked — that case is untested by me, so I cannot say whether the fallback alone would have replaced #1011. - The other one: the Series S stretch pass (`GetDimensions` on a `RWTexture2D`) fails with `E5005` under Wine, and with the fallback it builds as `cs_6_0`. I reverted the hand patch I had written for it and the Series S profile still draws: `the upscaler's output is made by a plain stretch`. Measured on CachyOS 7.3.5, RX 7600 XT 8 GB, RADV Mesa 27.0.0, Wine 11.22, retail 1.0.2.1: Series S, 152 consecutive world frames, average 3.99 fps, median frame 215 ms, 4,320 draws. So the two routes are: rewrite each shader (no dependency, same SM5 as Windows), or a fallback (covers the whole class, adds two DLLs, and shifts those shaders to DXIL 6.0 through vkd3d). Which would the maintainers rather have here? If it is the fallback, I can send it as a diff; TobiasFornell independently confirmed the same approach under Proton on a 9070 XT (Belobug#183), so there would be two testers. No game files or screenshots, numbers only.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#2744
No description provided.