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

Closed
github-bot wants to merge 2 commits from gh-pr/262/head into gh-pr/262/base
Owner

@⁠SkippySteve on GitHub · 2026-11-24 01:53 UTC · original
SkippySteve/shader-container-test-linux → main · +25 −3 · 1 files · 2 commits · closed without merging

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)] (#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 #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** on GitHub · 2026-11-24 01:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/262) `SkippySteve/shader-container-test-linux` → `main` · +25 −3 · 1 files · 2 commits · closed without merging `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)]` (#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 #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
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:57:06 +00:00
github-bot closed this pull request 2026-11-26 03:57:06 +00:00
Author
Owner

@⁠SkippySteve on GitHub · 2026-11-24 02:32 UTC · original

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

**@⁠SkippySteve** on GitHub · 2026-11-24 02:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/262#issuecomment-7120247858) Folded into #326 to keep the PR count down. The commits are unchanged there.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!262
No description provided.