GPU: the indirect argument clamp is built by our emitter, not from HLSL #1469

Closed
x3ero0 wants to merge 1 commit from upstream-pr/1470 into main
x3ero0 commented 2026-11-24 18:17:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by x3ero0 on 2026-11-24T18:17:29Z.


Problem

The compute shader that bounds indirect arguments is HLSL, compiled at start-up with D3DCompile. Under Wine the built-in compiler refuses it:

clamp:19:27: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'.

So there is no clamp, and every indirect draw and dispatch is dropped. indirect::tests::argument_clamp_builds fails on current main (ffe310e) under GE-Proton11-6 for this reason.

Change

The clamp becomes a module of ours, built with the same builder the translations and the stub shaders use. No host needs an HLSL compiler.

  • Shader gains root UAVs (raw buffers, u<root parameter> in the root descriptor space), in the resource metadata and PSV0.
  • New emit::clamp: argument_clamp(&Limits) builds the shader; clamped is the same arithmetic in Rust, for tests and readers. The limits stay in victory-gpu.
  • victory-gpu makes the clamp's root signature with the helper the pipelines use (the shader no longer carries one) and drops the Fxc bindings.

The arithmetic is unchanged, with one difference: where the HLSL relied on && to skip a division by a zero group count, the divisor is made 1.

Testing

Linux only (RTX 5080, driver 620.70). Not run on Windows, so the native D3D12 runtime has not seen this shader; CI will cover the build and the tests that need no GPU.

  • Under GE-Proton11-6: the two new GPU tests pass. They run every record kind and the budget through the real pipeline and compare with clamped. They replace argument_clamp_builds, which fails there before this change. The other nine failures of cargo test --workspace in that environment are the same before and after (repository-path checks, WSAConnectByList, the pipeline library, the container-digest check).
  • Microsoft's validator (libdxil.so from DXC v1.9.2609) accepts the container.
  • A one-off comparison, not in the tree, on a native vkd3d-proton build of this module: 5,461 random records gave the same buffers from this shader and from the HLSL clamp compiled by DXC. The only differences were which records a spent budget emptied, which depends on thread order in both.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, for x86_64-pc-windows-msvc. cargo xtask policy passes.

I could not check the effect in the world under Wine: the title does not get that far there with this Proton's vkd3d-proton.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588476911 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1470). Originally posted by [x3ero0](https://github.com/x3ero0) on 2026-11-24T18:17:29Z. --- ## Problem The compute shader that bounds indirect arguments is HLSL, compiled at start-up with `D3DCompile`. Under Wine the built-in compiler refuses it: ``` clamp:19:27: E5005: Method 'Load' is not defined on type 'RWByteAddressBuffer'. ``` So there is no clamp, and every indirect draw and dispatch is dropped. `indirect::tests::argument_clamp_builds` fails on current main (`ffe310e`) under GE-Proton11-6 for this reason. ## Change The clamp becomes a module of ours, built with the same builder the translations and the stub shaders use. No host needs an HLSL compiler. - `Shader` gains root UAVs (raw buffers, `u<root parameter>` in the root descriptor space), in the resource metadata and `PSV0`. - New `emit::clamp`: `argument_clamp(&Limits)` builds the shader; `clamped` is the same arithmetic in Rust, for tests and readers. The limits stay in `victory-gpu`. - `victory-gpu` makes the clamp's root signature with the helper the pipelines use (the shader no longer carries one) and drops the `Fxc` bindings. The arithmetic is unchanged, with one difference: where the HLSL relied on `&&` to skip a division by a zero group count, the divisor is made 1. ## Testing Linux only (RTX 5080, driver 620.70). **Not run on Windows**, so the native D3D12 runtime has not seen this shader; CI will cover the build and the tests that need no GPU. - Under GE-Proton11-6: the two new GPU tests pass. They run every record kind and the budget through the real pipeline and compare with `clamped`. They replace `argument_clamp_builds`, which fails there before this change. The other nine failures of `cargo test --workspace` in that environment are the same before and after (repository-path checks, `WSAConnectByList`, the pipeline library, the container-digest check). - Microsoft's validator (`libdxil.so` from DXC v1.9.2609) accepts the container. - A one-off comparison, not in the tree, on a native vkd3d-proton build of this module: 5,461 random records gave the same buffers from this shader and from the HLSL clamp compiled by DXC. The only differences were which records a spent budget emptied, which depends on thread order in both. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`, for `x86_64-pc-windows-msvc`. `cargo xtask policy` passes. I could not check the effect in the world under Wine: the title does not get that far there with this Proton's vkd3d-proton. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 19:03:29 +00:00
x3ero0 commented 2026-11-24 19:04:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by x3ero0 on 2026-11-24T18:34:31Z.


Closing as a duplicate of #190, which builds the clamp the same way and was opened first; I missed it. I'll test #190 on this machine (RTX 5080, Linux, Proton and native vkd3d-proton) and post the results there.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140835671 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1470#issuecomment-7140835671). Originally posted by [x3ero0](https://github.com/x3ero0) on 2026-11-24T18:34:31Z. --- Closing as a duplicate of #190, which builds the clamp the same way and was opened first; I missed it. I'll test #190 on this machine (RTX 5080, Linux, Proton and native vkd3d-proton) and post the results there.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1469
No description provided.