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.

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