Skip to content

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

Closed
x3ero0 wants to merge 1 commit into
spidercraft:linux-native-runtimefrom
x3ero0:emitted-argument-clamp
Closed

x3ero0 wants to merge 1 commit into
spidercraft:linux-native-runtimefrom
x3ero0:emitted-argument-clamp

Conversation

@x3ero0

@x3ero0 x3ero0 commented Nov 24, 2026

Copy link
Copy Markdown

For the native Linux runtime in Marvisak#526, on top of d46727f. Independent of #1.

Problem

The compute shader that bounds indirect arguments is HLSL compiled at start-up. On Linux that needs DXC, which is opt-in through VICTORY_DXCOMPILER (Arch's package asserts, so nothing is loaded unasked). Without it every indirect draw and dispatch is dropped as "not bounded": several hundred per frame in the world on my machine. With it, DXC's LLVM replaces the fault handlers at its first compile and they have to be taken back.

Change

The clamp becomes a module of ours, built with the same builder the translations and the stub shaders use, so 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).
  • Removed: the HLSL source, hostlib::compile_hlsl and its library loader, signals::reclaim, the DXC compile at device creation, the Fxc bindings. docs/linux.md no longer asks for libdxcompiler.so.

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.

This also takes D3DCompile out of the Windows path. I could only type-check that side.

Testing

Linux x86-64, RTX 5080 (driver 620.70), vkd3d-proton 30b0eb9.

  • Microsoft's validator (libdxil.so from DXC v1.9.2609) accepts the container.
  • New GPU tests (VICTORY_VKD3D=... cargo test -p victory-gpu indirect) run every record kind and the budget through the real pipeline and compare with clamped.
  • A one-off comparison, not in the tree: 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.
  • A title run without DXC reaches the world with no "not bounded" drops. The drops that remain are the same kinds as in a run of d46727f with DXC.
  • cargo test --workspace: 418 passed, 0 failed. cargo xtask policy passes.
  • Windows: cargo xwin check is clean. Not run on Windows.

One unrelated observation: linux::vm::tests::physical_pages_map_alias_and_free failed once in a full workspace run (region size 65536, expected 196608) and passed in the next seven. I have not looked into it.

🤖 Generated with Claude Code

The clamp that bounds indirect arguments was HLSL compiled at start-up:
by D3DCompile on Windows, and on Linux by DXC, only if VICTORY_DXCOMPILER
named one. Without it every indirect draw and dispatch was dropped as
"not bounded" (several hundred a frame in the world), and with it DXC's
LLVM took our fault handlers at its first compile, which had to be taken
back.

The clamp is now a module of ours (emit::clamp), built with the builder
the translations use, so 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.
* emit::clamp::argument_clamp builds the shader from its Limits, which
  stay in victory-gpu; clamped is the same arithmetic in Rust.
* victory-gpu makes the root signature with the pipelines' helper.
* Gone: the HLSL source, hostlib::compile_hlsl and its library,
  signals::reclaim, the DXC compile at device creation, the Fxc
  bindings. docs/linux.md no longer asks for libdxcompiler.so.

The arithmetic is unchanged, with one difference: a divisor that the
HLSL left to the && (the group count in z) is made 1 when it is 0.

Tested on Linux x86-64, RTX 5080, vkd3d-proton 30b0eb9: Microsoft's
validator (libdxil.so 1.9.2609) takes the container; new GPU tests run
every record kind and the budget against clamped; 5,461 random records
gave the same buffers as the HLSL clamp compiled by DXC, but for which
records a spent budget emptied (thread order); a title run without DXC
reaches the world with no "not bounded" drops; cargo test --workspace
418 passed; Windows type-check clean (cargo xwin check); cargo xtask
policy. Not run on Windows.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@x3ero0

x3ero0 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Closing this to send the change to Marvisak/VIctory main instead, where the same HLSL clamp exists. I'll link the new pull request here.

@x3ero0 x3ero0 closed this Nov 24, 2026
@x3ero0

x3ero0 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Now at Marvisak#1470.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant