Indirect: the argument clamp in a form Wine's HLSL compiler builds too #1011

Closed
github-bot wants to merge 1 commit from gh-pr/1011/head into gh-pr/1011/base
Owner

@⁠cmt8 on GitHub · 2026-11-25 15:58 UTC · original
up/wine-clamp → main · +256 −38 · 2 files · 1 commits · closed without merging

What breaks today

Under Wine and Proton, D3DCompile is Wine's d3dcompiler_47, whose HLSL compiler is vkd3d-shader's. It refuses the clamp in indirect.rs (no Load/Interlocked* methods on RWByteAddressBuffer, [allow_uav_condition] not implemented) and ignores [RootSignature]. So the clamp is never made and every indirect execution is dropped ("no argument clamp: indirect execution dropped"). The title's indirect draws and dispatches are then lost on Linux unless a DXC fallback (#20, #174) is in use; we have not counted how many that is on main. The window check's compare shader and the tests' WORKER_CS fail the same way.

The change

The three shaders are rewritten so that Microsoft's compiler and the vkd3d-shader 2.1 compiler in Wine 11.22 and in Proton Experimental (experimental-11.0-20261112) build them. Older Wine is not covered: per avt0m4t48's check below, Debian's Wine 10.0 builds neither main's shaders nor these (it lacks GroupMemoryBarrierWithGroupSync, the InterlockedAdd function and stores to RWStructuredBuffer<uint>). The rules stay as they are: MOST_DRAW, the gathered records of 465b94f5, one budget charge per group of 64 in lane order, the 2^27 budget, the window rules.

  • 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 root UAV can be either kind of buffer, and strides, offsets and addresses that are not multiples of 4 are already refused (validate_layout, record_clamp_as), so the same bytes are written. The read-only source and count stay ByteAddressBuffer, because Load on those builds.
  • Interlocked* are called as functions on the word.
  • [allow_uav_condition] is removed. Microsoft's compiler builds the loop without it.
  • The root signatures are serialized in code (host::root_signature, root_constants, root_view). They are version 1.1 with the same parameters as the old RS strings, and the strings' default flags (root SRVs static while set, root UAVs volatile).
  • One new test, clamped_records_land_word_for_word_on_the_host, checks the clamp's output on the host GPU word for word. The WARP value tests skip where there is no WARP adapter, as under Wine, so without this test nothing under Wine checks what the clamp writes.

Evidence

Windows test binaries cross-built on Linux and run under Wine 11.22 with Proton Experimental's vkd3d-proton (RX 7900 XTX, RADV, Mesa 26.3). The run uses the wine-test xtask from Marvisak/VIctory #1218, which is not part of this PR.

  • victory-gpu: 176 passed, 3 failed. On 465b94f5 it is 170 passed, 8 failed. Fixed: indirect::tests::argument_clamp_builds, host_list_budget_starts_empty_at_each_submission, host_list_reuses_and_grows_scratch_across_submissions, host_list_window_check_finds_a_record_written_under_its_window, host_list_window_executions_need_no_barrier_of_their_own. No test that passed before fails. The 3 left fail on main under Wine for other reasons: drvwatch (Wine's EvtSubscribe is a stub), pipeline::library, resource::..._twin_....
  • indirect:: (16 tests) passes with three compilers: Wine 11.22's builtin, Proton Experimental's own (d3dcompiler_47 with its libvkd3d-shader-1.dll), and Microsoft's d3dcompiler_47 10.0.26100.3916 loaded natively.
  • For one run only, the WARP harness was pointed at the RX 7900 XTX so the WARP value tests would actually run. They pass on this branch with Wine's compiler, the gathered-records test (warp_gathered_records_come_out_as_if_clamped_one_by_one) included; main's clamp does not build there. Two exceptions: the two warp_card_* tests need CARD_COMPARE/CARD_FETCH, which this PR does not convert, and warp_budget_saturates_without_wraparound_and_preserves_draw_fields fails now and then on a real card on this branch and on main alike, with Microsoft's compiler too (the second group of 64 can charge the budget first, which WARP never does). The harness change is not part of this PR.

Not verified

  • Not run on Windows: we have no Windows machine. On Windows the shaders and root signatures differ in form only. The bytes read and written and the root parameters are the same, and the value tests above pass with Microsoft's compiler on a real GPU (under Wine and vkd3d-proton). CI's WARP run would be the first true Windows check.
  • The game has not been run with exactly this branch. Our Linux branch carries a form of this clamp with extra diagnostics, and indirect work runs under Proton there with no "no argument clamp" warnings.
  • Marvisak/VIctory #1279 (Mumogg), "an argument clamp Wine's compiler builds too": the same idea for upstream's simpler clamp, and where ours comes from. It does not apply here, because this fork's clamp has source and destination buffers, a count buffer, the compare-exchange budget, the group charge and the window check.
  • #127 (BitWuehler) did the same for this fork's clamp before the group charge and the window check landed. It now conflicts with main. It also converts CARD_COMPARE and the depth-plane twin (PlanePass), which this PR does not touch. If #127 is rebased, the two overlap only in indirect.rs, and either can take the other's form.
  • #20 and #174 take another route: a DXC fallback for the same shaders.

Rebased onto 465b94f5 (the gather commit): the one conflict was in the clamp, where the new gather branch is kept as it is and reads through count_buf, a read-only ByteAddressBuffer.

AI-assisted (Claude Code); no game data.

**@⁠cmt8** on GitHub · 2026-11-25 15:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/1011) `up/wine-clamp` → `main` · +256 −38 · 2 files · 1 commits · closed without merging ## What breaks today Under Wine and Proton, `D3DCompile` is Wine's `d3dcompiler_47`, whose HLSL compiler is vkd3d-shader's. It refuses the clamp in `indirect.rs` (no `Load`/`Interlocked*` methods on `RWByteAddressBuffer`, `[allow_uav_condition]` not implemented) and ignores `[RootSignature]`. So the clamp is never made and every indirect execution is dropped ("no argument clamp: indirect execution dropped"). The title's indirect draws and dispatches are then lost on Linux unless a DXC fallback (#20, #174) is in use; we have not counted how many that is on `main`. The window check's compare shader and the tests' `WORKER_CS` fail the same way. ## The change The three shaders are rewritten so that Microsoft's compiler and the vkd3d-shader 2.1 compiler in Wine 11.22 and in Proton Experimental (experimental-11.0-20261112) build them. **Older Wine is not covered:** per avt0m4t48's check below, Debian's Wine 10.0 builds neither `main`'s shaders nor these (it lacks `GroupMemoryBarrierWithGroupSync`, the `InterlockedAdd` function and stores to `RWStructuredBuffer<uint>`). The rules stay as they are: `MOST_DRAW`, the gathered records of 465b94f5, one budget charge per group of 64 in lane order, the 2^27 budget, the window rules. - 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 root UAV can be either kind of buffer, and strides, offsets and addresses that are not multiples of 4 are already refused (`validate_layout`, `record_clamp_as`), so the same bytes are written. The read-only source and count stay `ByteAddressBuffer`, because `Load` on those builds. - `Interlocked*` are called as functions on the word. - `[allow_uav_condition]` is removed. Microsoft's compiler builds the loop without it. - The root signatures are serialized in code (`host::root_signature`, `root_constants`, `root_view`). They are version 1.1 with the same parameters as the old RS strings, and the strings' default flags (root SRVs static while set, root UAVs volatile). - One new test, `clamped_records_land_word_for_word_on_the_host`, checks the clamp's output on the host GPU word for word. The WARP value tests skip where there is no WARP adapter, as under Wine, so without this test nothing under Wine checks what the clamp writes. ## Evidence Windows test binaries cross-built on Linux and run under Wine 11.22 with Proton Experimental's vkd3d-proton (RX 7900 XTX, RADV, Mesa 26.3). The run uses the `wine-test` xtask from Marvisak/VIctory #1218, which is not part of this PR. - victory-gpu: 176 passed, 3 failed. On `465b94f5` it is 170 passed, 8 failed. Fixed: `indirect::tests::argument_clamp_builds`, `host_list_budget_starts_empty_at_each_submission`, `host_list_reuses_and_grows_scratch_across_submissions`, `host_list_window_check_finds_a_record_written_under_its_window`, `host_list_window_executions_need_no_barrier_of_their_own`. No test that passed before fails. The 3 left fail on `main` under Wine for other reasons: `drvwatch` (Wine's `EvtSubscribe` is a stub), `pipeline::library`, `resource::..._twin_...`. - `indirect::` (16 tests) passes with three compilers: Wine 11.22's builtin, Proton Experimental's own (`d3dcompiler_47` with its `libvkd3d-shader-1.dll`), and Microsoft's `d3dcompiler_47` 10.0.26100.3916 loaded natively. - For one run only, the WARP harness was pointed at the RX 7900 XTX so the WARP value tests would actually run. They pass on this branch with Wine's compiler, the gathered-records test (`warp_gathered_records_come_out_as_if_clamped_one_by_one`) included; `main`'s clamp does not build there. Two exceptions: the two `warp_card_*` tests need `CARD_COMPARE`/`CARD_FETCH`, which this PR does not convert, and `warp_budget_saturates_without_wraparound_and_preserves_draw_fields` fails now and then on a real card on this branch and on `main` alike, with Microsoft's compiler too (the second group of 64 can charge the budget first, which WARP never does). The harness change is not part of this PR. ## Not verified - Not run on Windows: we have no Windows machine. On Windows the shaders and root signatures differ in form only. The bytes read and written and the root parameters are the same, and the value tests above pass with Microsoft's compiler on a real GPU (under Wine and vkd3d-proton). CI's WARP run would be the first true Windows check. - The game has not been run with exactly this branch. Our Linux branch carries a form of this clamp with extra diagnostics, and indirect work runs under Proton there with no "no argument clamp" warnings. ## Related - Marvisak/VIctory #1279 (Mumogg), "an argument clamp Wine's compiler builds too": the same idea for upstream's simpler clamp, and where ours comes from. It does not apply here, because this fork's clamp has source and destination buffers, a count buffer, the compare-exchange budget, the group charge and the window check. - #127 (BitWuehler) did the same for this fork's clamp before the group charge and the window check landed. It now conflicts with `main`. It also converts `CARD_COMPARE` and the depth-plane twin (`PlanePass`), which this PR does not touch. If #127 is rebased, the two overlap only in `indirect.rs`, and either can take the other's form. - #20 and #174 take another route: a DXC fallback for the same shaders. Rebased onto 465b94f5 (the gather commit): the one conflict was in the clamp, where the new gather branch is kept as it is and reads through `count_buf`, a read-only `ByteAddressBuffer`. AI-assisted (Claude Code); no game data.
Under Wine and Proton, D3DCompile is Wine's d3dcompiler_47, whose HLSL
compiler is vkd3d-shader's. It refuses the clamp (E5005: no Load or
Interlocked* methods on RWByteAddressBuffer; [allow_uav_condition] is
"not yet implemented") and ignores [RootSignature], so the clamp is never
made and every indirect execution is dropped ("no argument clamp:
indirect execution dropped"). The window check's compare shader and the
tests' WORKER_CS fail the same way.

The three shaders are rewritten with what both compilers take; the rules
are unchanged (MOST_DRAW, one budget charge per group of 64 in lane order,
the 2^27 budget, the window rules, the gathered records):

- The buffers a shader writes are RWStructuredBuffer<uint> indexed in
  words: the destination record at id.x * (stride / 4), copied words at
  + off / 4; the budget's words 0, 1, 2 (bytes 0, 4, 8 as before); the
  window check's results at words 0, 1, 2.., 10... A root UAV can be
  either kind, and stride, offsets and addresses are already refused
  unless multiples of 4 (validate_layout, record_clamp_as, gatherable,
  record_gather_as), so the same bytes are written. The read-only source
  and count stay ByteAddressBuffer: Load on those builds. Gathered
  records (bit 2) read their offsets from the table behind count_buf as
  before and land in slot id.x, in words like the rest.
- Interlocked* are called as functions on the buffer's word.
- [allow_uav_condition] is dropped: Microsoft's d3dcompiler_47 builds the
  loop without it.
- The root signatures are serialized in code (host::root_signature,
  root_constants, root_view; version 1.1, the same parameters as the RS
  strings, root SRVs static while set and root UAVs volatile, the
  defaults of the strings) and passed to the pipeline. The gather pass
  binds the same five parameters; its table is upload memory written
  before the list is submitted, which a root SRV static while set allows.

A test checks the clamp's output on the host GPU word by word (offsets
into the source, a count at an offset, strides past the smallest, every
kind): the WARP value tests skip where there is no WARP adapter, as under
Wine.

The form descends from Marvisak/VIctory PR #1279 (Mumogg), written for
upstream's simpler clamp; fork PR #127 (BitWuehler) did the same for this
fork's clamp before the group charge and the window check came in.

Tested: cargo xwin build --release -p victory; cargo xtask policy (180
files ok). Windows tests under Wine 11.22 (Arch wine 11.22-1; its
d3dcompiler_47 is vkd3d-shader 2.1, Wine bundled) with the vkd3d-proton
of Proton Experimental (experimental-11.0-20261112) on an RX 7900 XTX
(RADV, Mesa 26.3.1): victory-gpu 176 passed, 3 failed (was 170 passed,
8 failed on this commit's parent); fixed:
indirect::tests::argument_clamp_builds,
host_list_budget_starts_empty_at_each_submission,
host_list_reuses_and_grows_scratch_across_submissions,
host_list_window_check_finds_a_record_written_under_its_window,
host_list_window_executions_need_no_barrier_of_their_own; no new
failure. indirect:: passes (16 of 16) also with Proton Experimental's own
d3dcompiler_47 (vkd3d-shader 2.1) and with Microsoft's d3dcompiler_47
10.0.26100.3916 loaded natively (the parent: 10 of 15 with Proton's,
15 of 15 with Microsoft's). With the WARP harness pointed at the RX 7900
XTX for the run only, the WARP value tests, the gathered records' one
included, pass under Wine's compiler (the parent's clamp does not build
there); warp_budget_saturates_without_wraparound_and_preserves_draw_fields
then fails now and then on this commit and on its parent alike, under
Microsoft's compiler too (on a real card the second group can charge
first). Not run on Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:52 +00:00
github-bot closed this pull request 2026-11-26 03:55:52 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 16:22 UTC · original · edited 2026-11-25 16:58 UTC

Rebase follow-up (November 25). The rebase resolved the conflict against the tested base. I checked base 465b94f54e2f31abd3624cf336697a57a2d6a083 and GitHub test merge 6f08132ebf822d0f4d6bf66da6da41dbea8c2e77, whose source tree matches rebased PR head d9e68ebb9a58f2abf35def0cf2b5a3ab714068c5.

  • Both revisions passed cargo check --offline --locked --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --features diagnostics,blake3/pure on Linux with Rust 1.98.1 and separate target directories. Both emitted the existing test-only depth_written warning.
  • I reran all three exact HLSL strings with Debian Wine 10.0's built-in d3dcompiler_47 at cs_5_1 and cs_5_0. The clamp, including the gathered-records branch in this revision, still fails on the missing group barrier. The window check and worker still fail on the missing byte-address atomic method on main and the missing global atomic function on the PR. The synthetic smoke shader compiled at both profiles.
  • The rebased CI run reports action_required with zero jobs. This follow-up covers Windows-target type checking and Wine 10.0 compilation. Wine 11.22, Proton, native Windows linking and execution, and GPU readback remain outside this independent check. No game files were used.

At publication, the advertised main had advanced to ca8829ff551d2a8558daae74f8aa48d0b1ff7d70. These findings apply to the base, head and test merge listed above. Integration with the newer main is unverified.

Earlier verification (before the rebase).

I checked the three changed HLSL strings from main 39731795d2d5117e6f90939273ee130428d28137 and the GitHub test merge a11622e931a867e08239d6aa2f987b515a931ef8 (PR head f98471783bea4715b5eceb3bf76db0bb3732429b). The merge and head have byte-identical indirect.rs. I called Debian Wine 10.0's built-in d3dcompiler_47!D3DCompile directly with entry main, profile cs_5_1 and flags 0, matching the repository calls.

  • The clamp failed on both revisions because Wine 10.0 lacks GroupMemoryBarrierWithGroupSync.
  • The window comparison and test worker failed on both. Main reports the missing RWByteAddressBuffer.InterlockedAdd method. The PR reports the missing global InterlockedAdd function.
  • A minimal compute shader compiled. Separate synthetic shaders confirmed the missing barrier and atomic function and independently found that a plain RWStructuredBuffer<uint> store reports “Structured buffers store is not implemented.” Running the matrix with cs_5_0 produced the same outcomes.

This establishes a compatibility limit for Wine 10.0. If the PR description names the tested compiler versions next to the compatibility claim, readers on older Wine versions will know what to expect. The Wine 11.22 and Proton compiler results in the description are outside this check.

Main and the test merge each passed cargo check --offline --locked --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --features diagnostics,blake3/pure from Linux with Rust 1.98.1 and separate target directories. Both emitted the existing test-only depth_written warning. I exercised shader compilation only. GPU execution and native Windows linking and execution remain unverified by this check. No game files were used. Fork CI run reported action_required with zero jobs.

While I ran the checks, main advanced to 465b94f54e2f31abd3624cf336697a57a2d6a083. GitHub reports that the PR now conflicts, and git merge-tree --write-tree independently reports a content conflict in crates/victory-gpu/src/indirect.rs. Wine 10.0 also rejected all three shader strings on the new main. The clamp changed and still fails on the missing group barrier. The other two strings are byte-identical to the previously tested main. The cross-target check above applies to the earlier test merge.

**@⁠avt0m4t48** on GitHub · 2026-11-25 16:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/1011#issuecomment-7167866668) · edited 2026-11-25 16:58 UTC **Rebase follow-up (November 25).** The rebase resolved the conflict against the tested base. I checked base `465b94f54e2f31abd3624cf336697a57a2d6a083` and GitHub test merge `6f08132ebf822d0f4d6bf66da6da41dbea8c2e77`, whose source tree matches rebased PR head `d9e68ebb9a58f2abf35def0cf2b5a3ab714068c5`. - Both revisions passed `cargo check --offline --locked --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --features diagnostics,blake3/pure` on Linux with Rust 1.98.1 and separate target directories. Both emitted the existing test-only `depth_written` warning. - I reran all three exact HLSL strings with Debian Wine 10.0's built-in `d3dcompiler_47` at `cs_5_1` and `cs_5_0`. The clamp, including the gathered-records branch in this revision, still fails on the missing group barrier. The window check and worker still fail on the missing byte-address atomic method on main and the missing global atomic function on the PR. The synthetic smoke shader compiled at both profiles. - The [rebased CI run](https://github.com/fxceless/victory-fork/actions/runs/45655278518) reports `action_required` with zero jobs. This follow-up covers Windows-target type checking and Wine 10.0 compilation. Wine 11.22, Proton, native Windows linking and execution, and GPU readback remain outside this independent check. No game files were used. At publication, the advertised `main` had advanced to `ca8829ff551d2a8558daae74f8aa48d0b1ff7d70`. These findings apply to the base, head and test merge listed above. Integration with the newer main is unverified. **Earlier verification (before the rebase).** I checked the three changed HLSL strings from main `39731795d2d5117e6f90939273ee130428d28137` and the GitHub test merge `a11622e931a867e08239d6aa2f987b515a931ef8` (PR head `f98471783bea4715b5eceb3bf76db0bb3732429b`). The merge and head have byte-identical `indirect.rs`. I called Debian Wine 10.0's built-in `d3dcompiler_47!D3DCompile` directly with entry `main`, profile `cs_5_1` and flags `0`, matching the repository calls. - The clamp failed on both revisions because Wine 10.0 lacks `GroupMemoryBarrierWithGroupSync`. - The window comparison and test worker failed on both. Main reports the missing `RWByteAddressBuffer.InterlockedAdd` method. The PR reports the missing global `InterlockedAdd` function. - A minimal compute shader compiled. Separate synthetic shaders confirmed the missing barrier and atomic function and independently found that a plain `RWStructuredBuffer<uint>` store reports “Structured buffers store is not implemented.” Running the matrix with `cs_5_0` produced the same outcomes. This establishes a compatibility limit for Wine 10.0. If the PR description names the tested compiler versions next to the compatibility claim, readers on older Wine versions will know what to expect. The Wine 11.22 and Proton compiler results in the description are outside this check. Main and the test merge each passed `cargo check --offline --locked --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --features diagnostics,blake3/pure` from Linux with Rust 1.98.1 and separate target directories. Both emitted the existing test-only `depth_written` warning. I exercised shader compilation only. GPU execution and native Windows linking and execution remain unverified by this check. No game files were used. [Fork CI run](https://github.com/fxceless/victory-fork/actions/runs/45650047989) reported `action_required` with zero jobs. While I ran the checks, main advanced to `465b94f54e2f31abd3624cf336697a57a2d6a083`. GitHub reports that the PR now conflicts, and `git merge-tree --write-tree` independently reports a content conflict in `crates/victory-gpu/src/indirect.rs`. Wine 10.0 also rejected all three shader strings on the new main. The clamp changed and still fails on the missing group barrier. The other two strings are byte-identical to the previously tested main. The cross-target check above applies to the earlier test merge.
Author
Owner

@⁠cmt8 on GitHub · 2026-11-25 17:01 UTC · original

Thanks for checking this against Wine 10.0, and for rechecking after the rebase. We only tested vkd3d-shader 2.1 (Wine 11.22 and Proton Experimental experimental-11.0-20261112) and Microsoft's compiler. The description now names those and notes that Wine 10.0 builds neither main's shaders nor these. The rebase conflict was the new gather branch in the clamp, kept as it is; updated test counts are in the description.

AI-assisted (Claude Code).

**@⁠cmt8** on GitHub · 2026-11-25 17:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/1011#issuecomment-7168898005) Thanks for checking this against Wine 10.0, and for rechecking after the rebase. We only tested vkd3d-shader 2.1 (Wine 11.22 and Proton Experimental experimental-11.0-20261112) and Microsoft's compiler. The description now names those and notes that Wine 10.0 builds neither main's shaders nor these. The rebase conflict was the new gather branch in the clamp, kept as it is; updated test counts are in the description. AI-assisted (Claude Code).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.