Shaders: expand synthetic unit tests for emit/sampler.rs #1018

Closed
opened 2026-11-26 04:17:17 +00:00 by github-bot · 5 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 15:06 UTC · original

Summary

Audits crates/victory-shader/src/emit/sampler.rs and expands deterministic synthetic unit tests from 1 to 6 passing tests covering every SQ_IMG_SAMP_WORD0-3 bitfield and boundary mapping. Production code is unchanged.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/shader-sampler
  • Commit: geiyiliyabumo/VIctory@ed1d9c7 (based on main ffe310e)

Tests Added (crates/victory-shader/src/emit/sampler.rs)

  • address_modes_map_all_eight_hardware_encodings
  • anisotropy_clamps_above_sixteen_and_comparison_covers_all_eight
  • mip_lod_bias_decodes_signed_14bit_fixed_point_extremes
  • no_mip_filter_forces_zero_lod_range_and_non_zero_preserves_it
  • filters_reductions_and_border_colours_decode_cleanly

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check crates/victory-shader/src/emit/sampler.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: PASS (0 warnings)
  • cargo test -p victory-shader --locked -- emit::sampler::: 6 passed, 0 failed

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 15:06 UTC · [original](https://github.com/Marvisak/VIctory/issues/1018) ### Summary Audits `crates/victory-shader/src/emit/sampler.rs` and expands deterministic synthetic unit tests from 1 to **6 passing tests** covering every `SQ_IMG_SAMP_WORD0-3` bitfield and boundary mapping. Production code is unchanged. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/shader-sampler` - **Commit**: `geiyiliyabumo/VIctory@ed1d9c7` (based on `main` `ffe310e`) ### Tests Added (`crates/victory-shader/src/emit/sampler.rs`) - `address_modes_map_all_eight_hardware_encodings` - `anisotropy_clamps_above_sixteen_and_comparison_covers_all_eight` - `mip_lod_bias_decodes_signed_14bit_fixed_point_extremes` - `no_mip_filter_forces_zero_lod_range_and_non_zero_preserves_it` - `filters_reductions_and_border_colours_decode_cleanly` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check crates/victory-shader/src/emit/sampler.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: **PASS** (0 warnings) - `cargo test -p victory-shader --locked -- emit::sampler::`: **6 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:17:17 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-24 15:10 UTC · original

I exercised the decoded LOD biases from ed1d9c7 through the D3D12 static-sampler root-signature path. On native Windows, both RTX 4070 Ti and WARP accepted -16.0 and 15.98828125 and created the compute PSO. The next representable values outside the D3D12 range, -16.00390625 and 15.9921875, were rejected at the root-signature step. The decoder’s extremes, -32.0 and 31.99609375, were rejected there too.

The bitfield test can keep asserting the original decoded value. This is a separate case for how the host handles biases it cannot accept. Synthetic test only. I haven’t checked whether the title uses those values.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-24 15:10 UTC · [original](https://github.com/Marvisak/VIctory/issues/1018#issuecomment-7135574645) I exercised the decoded LOD biases from `ed1d9c7` through the D3D12 static-sampler root-signature path. On native Windows, both RTX 4070 Ti and WARP accepted `-16.0` and `15.98828125` and created the compute PSO. The next representable values outside the D3D12 range, `-16.00390625` and `15.9921875`, were rejected at the root-signature step. The decoder’s extremes, `-32.0` and `31.99609375`, were rejected there too. The bitfield test can keep asserting the original decoded value. This is a separate case for how the host handles biases it cannot accept. Synthetic test only. I haven’t checked whether the title uses those values. *AI-assisted with Codex.*
Author
Owner

@⁠heromike405-arch on GitHub · 2026-11-24 15:17 UTC · original

Cross-check on Windows 11 (build 26100) with an RTX 5060 Laptop GPU and Radeon 610M. I used a synthetic static sampler with D3D12SerializeVersionedRootSignature, root-signature version 1.1, and the same flags as emit/host.rs.

  • The raw biases from 0x2000 (-32) and 0x1FFF (31.99609375) returned E_INVALIDARG at serialization.
  • The exact values used by #326 (-16.0 and 15.99) serialized successfully and passed CreateRootSignature on both hardware adapters.

The two extreme-value assertions in mip_lod_bias_decodes_signed_14bit_fixed_point_extremes currently call StaticSampler::from_words directly. #326 clamps in that same function, so those assertions would fail if both changes landed as written. If the clamp stays there, updating the two expectations would cover the value sent to D3D12. Testing raw sign extension would then require a separate raw decode step.

Standalone D3D12 probe, synthetic input. AI-assisted with Codex.

**@⁠heromike405-arch** on GitHub · 2026-11-24 15:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/1018#issuecomment-7135782192) Cross-check on Windows 11 (build 26100) with an RTX 5060 Laptop GPU and Radeon 610M. I used a synthetic static sampler with `D3D12SerializeVersionedRootSignature`, root-signature version 1.1, and the same flags as `emit/host.rs`. - The raw biases from `0x2000` (`-32`) and `0x1FFF` (`31.99609375`) returned `E_INVALIDARG` at serialization. - The exact values used by #326 (`-16.0` and `15.99`) serialized successfully and passed `CreateRootSignature` on both hardware adapters. The two extreme-value assertions in `mip_lod_bias_decodes_signed_14bit_fixed_point_extremes` currently call `StaticSampler::from_words` directly. #326 clamps in that same function, so those assertions would fail if both changes landed as written. If the clamp stays there, updating the two expectations would cover the value sent to D3D12. Testing raw sign extension would then require a separate raw decode step. *Standalone D3D12 probe, synthetic input. AI-assisted with Codex.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 07:00 UTC · original · edited 2026-11-25 09:57 UTC

Automated triage for the maintainers.

These are test-only additions for crates/victory-shader/src/emit/sampler.rs; the branch is open as PR #1195. Note from the comments: two of its assertions expect the raw decoded LOD bias extremes (-32 and ~32), which D3D12 rejects at root-signature serialization; if a clamp to the D3D12 range lands in StaticSampler::from_words, those expectations need updating. Review continues on #1195.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 07:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/1018#issuecomment-7155386047) · edited 2026-11-25 09:57 UTC <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T09:37:57Z at=2026-11-25T09:50:38Z --> Automated triage for the maintainers. These are test-only additions for `crates/victory-shader/src/emit/sampler.rs`; the branch is open as PR #1195. Note from the comments: two of its assertions expect the raw decoded LOD bias extremes (-32 and ~32), which D3D12 rejects at root-signature serialization; if a clamp to the D3D12 range lands in `StaticSampler::from_words`, those expectations need updating. Review continues on #1195. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:36 UTC · original

Validated the fork branch on Windows 11 Pro 26200 (Intel Core i5-14600K, RTX 5060 Ti, driver 621.24, Rust 1.98.1 MSVC), commit a711eb3: cargo test -p victory-shader --locked --no-fail-fast -> 246 passed, 3 failed, 3 ignored. Failed: test emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride ... FAILED | test emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros ... FAILED | test emit::synthetic_tests::gathers_at_a_level_match_the_hardware ... FAILED Synthetic tests only, no game files.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:36 UTC · [original](https://github.com/Marvisak/VIctory/issues/1018#issuecomment-7158565389) Validated the fork branch on Windows 11 Pro 26200 (Intel Core i5-14600K, RTX 5060 Ti, driver 621.24, Rust 1.98.1 MSVC), commit `a711eb3`: `cargo test -p victory-shader --locked --no-fail-fast` -> **246 passed, 3 failed, 3 ignored**. Failed: test emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride ... FAILED | test emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros ... FAILED | test emit::synthetic_tests::gathers_at_a_level_match_the_hardware ... FAILED Synthetic tests only, no game files.
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:37 UTC · original

Addendum: the 3 failures (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware) are the pre-existing NVIDIA 1M-view-heap-cap failures that also fail on current main; nothing introduced by this patch fails.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:37 UTC · [original](https://github.com/Marvisak/VIctory/issues/1018#issuecomment-7158592621) Addendum: the 3 failures (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware`) are the pre-existing NVIDIA 1M-view-heap-cap failures that also fail on current main; nothing introduced by this patch fails.
This discussion has been locked. Commenting is limited to contributors.
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#1018
No description provided.