Shaders: preserve mip point filtering in anisotropic static samplers #1337

Merged
mgunes1311-lab merged 3 commits from upstream-pr/1337 into main 2026-11-25 00:22:12 +00:00
mgunes1311-lab commented 2026-11-24 17:33:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-24T17:33:00Z.


Preserve the mip filter when decoding anisotropic immediate static samplers. Previously StaticSampler::from_words always emitted 0x55 | reduction << 7, forcing linear mip filtering.

Changes

  • Decode anisotropic mip-point as 0x54 | reduction << 7, and linear mip as 0x55 | reduction << 7. The existing mip == 0 MinLOD/MaxLOD lock at zero is preserved.
  • Query D3D12_OPTIONS19.AnisoFilterWithPointMipSupported in both the shader host and production GPU pipeline. If unsupported, or the query fails on an older runtime, filter_for_host retains the previous linear-mip approximation. Comparison/minimum/maximum reduction bits and LOD bounds remain unchanged.
  • Add regression tests for decoding, supported/unsupported host capabilities, all four reduction modes, and unrelated filters.

The capability check is required by the DirectX specification. This change does not make the optional feature a new device requirement.

Verification

  • Sampler tests: 4 passed.
  • cargo test -p victory-shader --target x86_64-pc-windows-msvc --all-features --locked: 123 passed, 0 failed, 1 benchmark ignored.
  • Shader and GPU Clippy with all targets, all features, and -D warnings: passed.
  • Asset policy: 154 files passed; git diff --check: clean.

No in-game result or supported-versus-unsupported hardware image comparison is claimed. Devices without the feature continue to use the previous approximation.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587694949 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1337). Originally posted by [mgunes1311-lab](https://github.com/mgunes1311-lab) on 2026-11-24T17:33:00Z. --- Preserve the mip filter when decoding anisotropic immediate static samplers. Previously `StaticSampler::from_words` always emitted `0x55 | reduction << 7`, forcing linear mip filtering. ### Changes - Decode anisotropic mip-point as `0x54 | reduction << 7`, and linear mip as `0x55 | reduction << 7`. The existing `mip == 0` MinLOD/MaxLOD lock at zero is preserved. - Query `D3D12_OPTIONS19.AnisoFilterWithPointMipSupported` in both the shader host and production GPU pipeline. If unsupported, or the query fails on an older runtime, `filter_for_host` retains the previous linear-mip approximation. Comparison/minimum/maximum reduction bits and LOD bounds remain unchanged. - Add regression tests for decoding, supported/unsupported host capabilities, all four reduction modes, and unrelated filters. The capability check is required by the [DirectX specification](https://microsoft.github.io/DirectX-Specs/d3d/VulkanOn12.html#anisotropic-sampler-with-mip-point). This change does not make the optional feature a new device requirement. ### Verification - Sampler tests: 4 passed. - `cargo test -p victory-shader --target x86_64-pc-windows-msvc --all-features --locked`: 123 passed, 0 failed, 1 benchmark ignored. - Shader and GPU Clippy with all targets, all features, and `-D warnings`: passed. - Asset policy: 154 files passed; `git diff --check`: clean. No in-game result or supported-versus-unsupported hardware image comparison is claimed. Devices without the feature continue to use the previous approximation.
catminou4 commented 2026-11-24 21:02:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:09:51Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 99 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests.

Preserves mip point filtering in anisotropic static samplers: StaticSampler.filter now keeps the mip==2 (point) bit instead of forcing linear-mip (0x54 vs 0x55), and both host.rs call sites query D3D12_OPTIONS19 AnisoFilterWithPointMipSupported with a fallback to the old approximation on older runtimes. sampler.rs unit tests run on macOS; the D3D12 feature-query parts are Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6046557952 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1337#pullrequestreview-6046557952). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:09:51Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 99 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests. Preserves mip point filtering in anisotropic static samplers: StaticSampler.filter now keeps the mip==2 (point) bit instead of forcing linear-mip (0x54 vs 0x55), and both host.rs call sites query D3D12_OPTIONS19 AnisoFilterWithPointMipSupported with a fallback to the old approximation on older runtimes. sampler.rs unit tests run on macOS; the D3D12 feature-query parts are Windows-only.
upstream-sync closed this pull request 2026-11-25 01:06:16 +00:00
sinan-cmyk commented 2026-11-25 02:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T01:49:02Z.


Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 7dfa86f onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 123, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149990098 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1337#issuecomment-7149990098). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T01:49:02Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 7dfa86f onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 123, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1337
No description provided.