Skip to content

Shaders: check the constant-colour container's layout and hash on every host - #262

Closed
SkippySteve wants to merge 2 commits into
Marvisak:mainfrom
SkippySteve:SkippySteve/shader-container-test-linux
Closed

SkippySteve wants to merge 2 commits into
Marvisak:mainfrom
SkippySteve:SkippySteve/shader-container-test-linux

Conversation

@SkippySteve

@SkippySteve SkippySteve commented Nov 24, 2026 •

Copy link
Copy Markdown

constant_color() in victory-shader's emit tests builds a pixel shader container but was only called by the two #[cfg(windows)] tests (stub_pipeline_is_created, constant_color_validates). Off Windows it was dead code, so cargo test/cargo clippy --all-targets -p victory-shader on Linux warned:

warning: function `constant_color` is never used
   --> crates/victory-shader/src/emit/mod.rs:450:8

This PR combines two fixes for that warning (it supersedes #258):

  1. Keep the helper on every host and use it there. Gating constant_color() with #[cfg(windows)] (Shaders: build the constant-colour test shader only on Windows, where its tests run #258's approach) would have hidden the warning, but left the container untested off Windows. Instead, a new test runs on every host: constant_color_is_a_well_formed_container. It checks what D3D12 and the validator look at before they read the bitcode:

    • the container parses with dxbc::Container, and its size field equals its length
    • the parts are the ones a pixel shader carries, in order: SFI0 ISG1 OSG1 PSV0 HASH DXIL
    • the DXIL part starts with the program header
    • the digest is container::hash of the bytes after it

    It needs neither D3D12 nor dxil.dll.

  2. Import hygiene from Shaders: build the constant-colour test shader only on Windows, where its tests run #258. bitcode::Attr and shader::Shader are used only by constant_color(), so their imports move from the test module into the helper.

The change is tests only: no runtime code changes.

Testing (Linux)

  • cargo test -p victory-shader: 57 passed (was 56)
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean (it failed before because of the warning)
  • cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean
  • cargo fmt -p victory-shader --check, cargo xtask policy: clean

SkippySteve added 2 commits November 23, 2026 20:53
…ry host

constant_color() was used only by the two Windows-gated tests, so off Windows
it was dead code and victory-shader's tests built with a warning. A new test
parses the container it builds, checks the size field, the pixel-shader parts
in order, the DXIL program header and that the digest is container::hash of
the bytes after it. It needs neither D3D12 nor dxil.dll, so it runs on Linux.
Only constant_color uses them, so they live inside it (from #258). The
helper itself stays on every host for the hermetic container test.
@SkippySteve

Copy link
Copy Markdown
Author

Folded into #326 to keep the PR count down. The commits are unchanged there.

Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 27, 2026
The forms of a console wave64 program for 32-lane hosts that leave out
skips (`ir::without_skips`, and the wave-wide form built on its deep
variant) let a host wave with no lane left into the skipped region. For
a loop whose way out waits for some lane (a lane compare that is empty
then) that way never comes, and every lane walks the loop to the
iteration limit, with whatever barriers the form put in it each time
round. A skip, and an early-out to the program's end, is now kept when
the code it would leave running with no lane left holds a loop that
neither ends at once on an empty mask (EXEC, a lane compare, a
waterfall over either) nor counts its way out on scalars the lanes do
not make.

`ir::without_early_outs`, a form of its own, is not guarded.

From DexNom/VIctory pull request Marvisak#71 (after fxceless/victory-fork pull
request Marvisak#262 by xADEL), taken as it is with its tests; there it kept
the two particle light-atlas programs from losing the card under the
wave-wide form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Steenax6 added a commit to Steenax6/VIctory-NVID that referenced this pull request Nov 27, 2026
…t of translator takes

A 1D sample reads the middle of its texture's one row, not its upper
edge, where a linear sampler with border or wrap addressing mixed the
edge in (AlanQiang0418/VIctory b73d735 after Marvisak/VIctory pull
request Marvisak#1727; 11,625 programs sample 1D textures). A skip and an
early-out stay before a loop that may not end with no lane left, where
the forms without them let a wave with an empty mask run the loop to its
limit (DexNom's fork, pull request Marvisak#71, after fxceless/victory-fork
Marvisak#262; 30 compute programs were exposed). A shared-memory atomic is a
read and a write where the two host waves of a console wave meet
(realblastex/flamingo 89e5d6c3d). `ds_inc`, `ds_dec`, `ds_rsub` and
`ds_mskor` translate, with and without a returned value, and a
subtraction of a constant is an add (fxceless/victory-fork Marvisak#1281,
Marvisak/VIctory Marvisak#3142). An opaque 64-lane mask is read by both dwords
of the pair (after Marvisak/VIctory Marvisak#2816). A DPP row mask counts
console rows where a console wave is two host waves: thread 33 read
row 0 where the console reads row 2 (the card test failed before).
Typed buffer views of 32-bit integer formats are made in the float
format of the same bits, which is what the translated loads declare
(fxceless/victory-fork Marvisak#684, Xeltax/VIcky 33eba00).

Looked at and not needed here: integer wave prefix operations other
than a sum and pixel programs ordered by primitive with a root view (no
program of the title reaches either refusal).

The translation counts are unchanged (14,247 vertex and pixel, 2,681 of
2,682 compute, 8,765 mesh); 11,656 programs' code changed, so the shader
cache is new with this merge: warm it up once. Runs of 2026-11-26 on an
RTX 4070 Ti with driver 621.40, pipelines rebuilt: first room 66.2 ms a
frame against 65.9 on the tree before, back to back; pictures right in
the prologue and at the open world's entry, no device loss.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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