Skip to content

GPU: an argument clamp Wine's compiler builds too - #1279

Open
Mumogg wants to merge 2 commits into
Marvisak:mainfrom
Mumogg:gpu/indirect-clamp-wine
Open

Mumogg wants to merge 2 commits into
Marvisak:mainfrom
Mumogg:gpu/indirect-clamp-wine

Conversation

@Mumogg

@Mumogg Mumogg commented Nov 24, 2026

Copy link
Copy Markdown

Problem

Under Wine, every indirect execution is dropped. The clamp of indirect arguments (crates/victory-gpu/src/indirect.rs) is HLSL compiled at run time with D3DCompile, and Wine's d3dcompiler_47 (vkd3d-shader's HLSL compiler) refuses it:

WARN victory_gpu::indirect: argument clamp: clamp:19:27: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'.

indirect::bound then returns false for every record and execute_indirect reports not 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 RootSignature attribute (W5302: Ignoring unknown attribute "RootSignature"), so the compiled blob has no RTS0 part and CreateRootSignature from the shader bytes would fail next.

Change

One file, the clamp only:

  • args and budget are RWStructuredBuffer<uint> instead of RWByteAddressBuffer, indexed in words. bound already 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.
  • The root signature (4 root constants at b0, root UAVs u0 and u1) is serialized with D3D12SerializeVersionedRootSignature beside the shader, as pipeline/host.rs does for its own, instead of being read from the shader blob.
  • The bounds, the budget and the InterlockedAdd on it are unchanged.

Testing

RTX 5070 Ti, driver 615.78.08, Nobara 44, Wine 11.21 Staging, vkd3d-proton and DXVK dxgi.dll from GE-Proton11-14, diag build cross-compiled on Linux, Series X 1.0.2.1, network off.

old clamp, Wine's compiler old clamp, Microsoft's d3dcompiler_47.dll beside the exe this change, Wine's compiler
argument clamp warning yes no no
not bounded drops every indirect record none none
host pipelines created in the run 618 1,063 782

With 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 (target x86_64-pc-windows-msvc) is clean.

Verified by others in #909 (on this same commit, f2a71ac):

  • MichaelSmithAI, RTX 4090 under Wine: a numeric comparison of the clamp's output (draw, indexed draw, mesh, accepted and rejected compute records, padding at a 32-byte stride, and the budget consumed by earlier records) gave the expected words with both Wine's builtin compiler and Microsoft's, and the same buffer as a port of GPU: build the indirect-argument clamp with our own writer (no shader compiler at run time) #190's precompiled DXIL.
  • andrewpozdnakov7-jpg, native Windows 10 (WARP): the pipeline is created.

Not tested: native Windows on a hardware GPU, AMD, and cargo test on my side (the existing argument_clamp_builds test covers this path on a machine with a GPU).

A workaround without this change: put Microsoft's d3dcompiler_47.dll next to victory.exe and add d3dcompiler_47=n to WINEDLLOVERRIDES.

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

Mumogg and others added 2 commits November 24, 2026 07:54
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 <noreply@anthropic.com>
@Mumogg

Mumogg commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

Added MichaelSmithAI's readback test from #909 to this branch (4dd4cfc, test-only, 36 lines in indirect.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 builtin d3dcompiler_47: argument_clamp_builds and clamp_preserves_record_offsets_and_shared_budget both pass. cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings is 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, WriteProcessMemory on 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).

@muhammed-aksoy

Copy link
Copy Markdown

I independently tested 4dd4cfc against main ffe310e on 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.

yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
…ied together

Merges Marvisak#72 Marvisak#347 Marvisak#1000 Marvisak#358 Marvisak#352 Marvisak#626 Marvisak#1152 Marvisak#1129 Marvisak#1203 Marvisak#24 Marvisak#642 Marvisak#427 Marvisak#485
Marvisak#550 Marvisak#174 Marvisak#1279 onto main (ffe310e), each head unchanged, no conflicts.

One change of mine: three of the PRs each add a `mod tests` at the end of
pipeline/host.rs, so the merge defines `tests` three times (E0428). The
second and third are named `library_tests` and `blend_tests`; nothing else
changes.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(367 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
draw.rs keeps both the breadcrumb user-data arm (Marvisak#1081) and the past-host-heap drop (Marvisak#550). indirect.rs takes the bundle's Wine-compiler clamp (Marvisak#1279), the same fix Marvisak#994 carried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
indirect.rs is the bundle's file: Marvisak#994 and Marvisak#1279 carry the same Wine-compiler clamp, and both root_signature functions had landed. The bundle's frame-wait test uses budget(), the function main made of BUDGET for VICTORY_PIPELINE_WAIT_MS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…ame wait bundle

Taken from the bundle: 64 MB stacks for pipeline workers (#1129), no
blending on integer render targets (#1152), root signature flag fallback
(#626), read-only depth read states (#485, on our stored rtvs/dsv and
bind_targets), enhanced texture barrier translation (#642, on our
recording_list so continuation segments get it), indirect mesh dispatch
(#24), the frame wait taking its tick before it sleeps (#174), and the
make.rs unit tests (#1203).

Kept from our side:
- pipeline/make.rs: early() starts every compute pipeline at creation
  (b4e8419); the per-pipeline wake pair, per-frame budget, wait_compute
  and copystat counters. The bundle's the_wait_budget_is_spent_once_per_frame
  test is dropped (written for its fixed BUDGET; our FrameBudget tests
  cover it); a_pipeline_is_made_once now holds the tests' serial lock.
- indirect.rs: our whole file (#40's overflow-safe clamp, DXC fallback for
  Wine, rectangle pass). #1279's structured-buffer clamp and its readback
  test (written for the old bound/done API) are left out.
- draw.rs: NOT_MADE counter, user_dword, typed table nulls
  (table_view_props, mirror_for_draw); the depth test calls readable()
  directly since our tables() needs a host pipeline.
- frame.rs: our `_tick` (the diagnostics log already names it).
- list.rs: execute_indirect's DISPATCH_SINGLE mapping in one place; our
  tests beside the bundle's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wwwwwwww3333333

Copy link
Copy Markdown
Contributor

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 4dd4cfc on main ffe310e (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_budget passes on this machine, and so does the existing argument_clamp_builds path. 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).

KainanP added a commit to KainanP/VIctory that referenced this pull request Nov 24, 2026
…shader writes and reads) onto integ/next

Conflicts:
1. crates/victory-gpu/src/draw.rs, `State::bind`: the stack (Marvisak#1439's depth
   sampling) resets `self.depth_sampled`, Marvisak#334 starts a buffer-state command
   (`list.begin_command()`). Independent; both kept, reset first.
2. crates/victory-gpu/src/host.rs tests: the stack adds
   `warp_device_creation_and_caps_probe`, Marvisak#334 adds
   `buffer_states_transition_between_writes_and_reads`,
   `buffer_states_keep_a_command_writing` and
   `debug_layer_accepts_buffers_written_then_read_as_vertices` (with its
   helpers) at the same place. The shared text holds the `#[test]` before
   and the closing brace after, so neither side's body closes inside the
   hunk: the stack's test is closed and Marvisak#334's follow as separate items
   (not nested).

Non-textual fixes:
- draw.rs `root_srv_table` (Marvisak#493, bounded root SRVs as one-view tables)
  reads a host copy without going through `root_view`, so it never asked
  Marvisak#334's tracker for the read state. It now calls
  `list.buffer_state(&s.buffer, BUFFER_READ)` after its refresh, on cache
  hits too, as Marvisak#334's author and Hiiva noted on Marvisak#334
  (Marvisak#334 (comment),
  Marvisak#334 (comment)).
- indirect.rs test `clamp_preserves_record_offsets_and_shared_budget`
  (Marvisak#1279, via Marvisak#1439) called `indirect::done`, which Marvisak#334 removes (the clamp
  now asks the tracker for the write state and `close` returns the copy to
  COMMON). The call is dropped; the next `bound` asks for the write state
  again, so no transition is missing.

Copy link
Copy Markdown
Owner

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 current main.


Generated by Claude Code

@ntgata1-dotcom

Copy link
Copy Markdown

Rebased onto main (940d32f); the clamp now passes all its tests under Wine's own compiler

The 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 on main. 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:

  • It keeps main's algorithm: one group walks the records in tiles of 64 and charges them in order, with Dispatch(records.min(1), 1, 1) as on main. It's written with this PR's RWStructuredBuffer<uint> in words: budget[0], args[at] = 0, at = record * (stride / 4).
  • The clamp body is main's with word indexing. There's no Load/Store and no [RootSignature(RS)] left, because the root signature is made beside the shader as in this PR.
  • The readback test needed gpu_writes's new marked argument. I passed false, as main'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-gcae8353ed and DXVK dxgi from GE-Proton11-14. cargo xwin test --locked --no-fail-fast -p victory-gpu, runner wine:

victory-gpu passed failed indirect::tests
main 940d32f, Wine's d3dcompiler_47 130 13 5 of 5 fail (no clamp)
rebased, Wine's d3dcompiler_47 136 8 6 of 6 pass
rebased, Microsoft's d3dcompiler_47 (indirect:: only) 6 0 6 of 6 pass

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.

cmt8 added a commit to cmt8/VIctory that referenced this pull request Nov 25, 2026
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 Marvisak#1279 (Mumogg), written for
upstream's simpler clamp; fork PR Marvisak#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 <noreply@anthropic.com>
@ntgata1-dotcom

ntgata1-dotcom commented Nov 25, 2026 •

Copy link
Copy Markdown

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), against main 940d32f on the same machine. Setup: Arch Linux, RX 9070 XT (RDNA4), RADV / Mesa 26.3.1, system Wine 11.22 with its built-in d3dcompiler_47, and vkd3d-proton v3.1-83-gcae8353ed and DXVK dxgi from 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.

main this branch
On screen black, apart from the credits text the scene: buildings, streets, lights, characters and a car. Unlit, with the broken character geometry the README describes on Windows
Draws per frame 541 on average, up to 1,755 2,954 on average, up to 8,548
Indirect executions dropped per frame 3,400 on average, up to 9,556 (no argument clamp) 9 on average, up to 26
argument clamp warning yes (E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer') none
Time per frame 2.6 s on average 3.1 s on average (it draws far more)

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

Copy link
Copy Markdown

Note

🤖 Claude Opus 5.5 responding on behalf of @arogan178

Carried onto current main in #2913, as the triage on #2744 invited. main now 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

Copy link
Copy Markdown

main rewrote 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: the not bounded indirect 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wine: the indirect argument clamp does not compile with Wine's HLSL compiler, so every indirect execution is dropped (fix on a branch)

7 participants