fix(formats): reject multisampled block-compressed textures #386

Closed
Damokles2 wants to merge 1 commit from upstream-pr/386 into main
Damokles2 commented 2026-11-27 21:46:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Damokles2 on 2026-11-27T21:46:12Z.


Problem and fix

Layout::new() accepts multisampled block-compressed textures if the dimension, mip count, and swizzle pass validation. In a standalone CPU reproduction, a 4×4 BC1_UNORM texture with one mip, four samples, and SW_64KB_R_X returned a 65,536-byte allocation. With the guard it returns Error::Invalid.

The change adds d.block == 1 to the multisample branch. That keeps the existing dimension, mip, and swizzle rules and leaves footprint calculations and GPU fallback behavior untouched. The current format table uses block == 4 only for BC1–BC7.

Microsoft limits multisampled textures to render-target or depth-stencil resources, and the BC format tables give them neither capability. AMD PAL also validates format and tiling support for MSAA during image creation. D3D12 resource description · Microsoft BC1 format support · AMD PAL image validation · AMD GFX10 AddrLib swizzle validation

Regression coverage

  • All 21 BC format entries accept single-sample layouts and reject 2×, 4×, and 8× MSAA with SW_64KB_R_X.
  • Positive tiled 4× controls cover RGBA8, R10G10B10A2_UNORM, and D32_FLOAT. The existing rejection of linear 4× RGBA8 is also covered.

Validation

  • Local Windows texture tests with the regression tests in place went from 20 passed, 1 expected failure before the guard to 21 passed after it. The standalone BC1 reproduction passed after the guard, with its single-sample BC1 and 4× RGBA8 controls retaining their original footprint sizes. Affected-crate cargo check, library-only strict Clippy, and git diff --check passed.
  • Hosted Windows locked workspace compilation and repository policy passed on both runs. The asset-independent CPU suite went from 80 to 83 passed, with zero failures and three ignored tests in each run.
  • Both hosted strict Clippy configurations reproduced the same existing victory-loader transmute annotation failures. All-features Clippy also reproduced the existing victory-formats precedence diagnostic. rustfmt --check still reports upstream formatting drift, with 3,522 baseline hunks and 3,521 candidate hunks.
Run Tested source Validation commit
Baseline 0f0ada19095979e2192d1b5a98bb5297cf4d53ea 095065e9753f69ae84fa9bdb7481445e5144f5b4
Candidate 31db25eb94da78ca245d92ae89167ca7aa0879dc 806b0fba6c2c5addcfdf0b5c7df32375684aef80

Fixes #356.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5533487171 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/386). Originally posted by [Damokles2](https://github.com/Damokles2) on 2026-11-27T21:46:12Z. --- ## Problem and fix `Layout::new()` accepts multisampled block-compressed textures if the dimension, mip count, and swizzle pass validation. In a standalone CPU reproduction, a 4×4 `BC1_UNORM` texture with one mip, four samples, and `SW_64KB_R_X` returned a 65,536-byte allocation. With the guard it returns `Error::Invalid`. The change adds `d.block == 1` to the multisample branch. That keeps the existing dimension, mip, and swizzle rules and leaves footprint calculations and GPU fallback behavior untouched. The current format table uses `block == 4` only for BC1–BC7. Microsoft limits multisampled textures to render-target or depth-stencil resources, and the BC format tables give them neither capability. AMD PAL also validates format and tiling support for MSAA during image creation. [D3D12 resource description](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_resource_desc#sampledesc) · [Microsoft BC1 format support](https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-1-formats#dxgi_format_bc1_unorm-fcc-71) · [AMD PAL image validation](https://github.com/GPUOpen-Drivers/pal/blob/dev/src/core/image.cpp#L278-L305) · [AMD GFX10 AddrLib swizzle validation](https://github.com/GPUOpen-Drivers/pal/blob/dev/src/core/imported/addrlib/src/gfx10/gfx10addrlib.cpp#L2593-L2649) ## Regression coverage - All 21 BC format entries accept single-sample layouts and reject 2×, 4×, and 8× MSAA with `SW_64KB_R_X`. - Positive tiled 4× controls cover RGBA8, `R10G10B10A2_UNORM`, and `D32_FLOAT`. The existing rejection of linear 4× RGBA8 is also covered. ## Validation - Local Windows texture tests with the regression tests in place went from **20 passed, 1 expected failure** before the guard to **21 passed** after it. The standalone BC1 reproduction passed after the guard, with its single-sample BC1 and 4× RGBA8 controls retaining their original footprint sizes. Affected-crate `cargo check`, library-only strict Clippy, and `git diff --check` passed. - Hosted Windows locked workspace compilation and repository policy passed on both runs. The asset-independent CPU suite went from **80 to 83 passed**, with zero failures and three ignored tests in each run. - Both hosted strict Clippy configurations reproduced the same existing `victory-loader` transmute annotation failures. All-features Clippy also reproduced the existing `victory-formats` precedence diagnostic. `rustfmt --check` still reports upstream formatting drift, with 3,522 baseline hunks and 3,521 candidate hunks. | Run | Tested source | Validation commit | | --- | --- | --- | | [Baseline](https://github.com/Damokles2/VIctory-NVIDIA/actions/runs/46071382488) | `0f0ada19095979e2192d1b5a98bb5297cf4d53ea` | `095065e9753f69ae84fa9bdb7481445e5144f5b4` | | [Candidate](https://github.com/Damokles2/VIctory-NVIDIA/actions/runs/46071383040) | `31db25eb94da78ca245d92ae89167ca7aa0879dc` | `806b0fba6c2c5addcfdf0b5c7df32375684aef80` | Fixes #356. AI-assisted with OpenAI Codex.
trustno1-coder commented 2026-11-28 02:49:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T02:49:50Z.


Merged into main (8fc2254) and shipped in v2026.11.27.10. The commit keeps you as its author, so it counts toward the contributors list. GitHub shows this as closed rather than merged only because the commits were applied on top of the newest main (new commit IDs). Thank you!

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7232620846 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/386#issuecomment-7232620846). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T02:49:50Z. --- Merged into main (8fc2254) and shipped in [v2026.11.27.10](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/tag/v2026.11.27.10). The commit keeps you as its author, so it counts toward the contributors list. GitHub shows this as closed rather than merged only because the commits were applied on top of the newest main (new commit IDs). Thank you!

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!386
No description provided.