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

Open
github-bot wants to merge 1 commit from github-bot/gh-386 into main AGit
Owner

@⁠Damokles2 on GitHub · 2026-11-27 21:46 UTC · original
Damokles2:fix-texture-bc-msaa-validation → main · +75 −1 · 1 files · 1 commits · open

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.

**@⁠Damokles2** on GitHub · 2026-11-27 21:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/386) `Damokles2:fix-texture-bc-msaa-validation` → `main` · +75 −1 · 1 files · 1 commits · open ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:47:05 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/386/head:github-bot/gh-386'
git switch 'github-bot/gh-386'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-386'
git switch 'github-bot/gh-386'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-386'
git switch 'github-bot/gh-386'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-386'
git switch 'main'
git merge --squash 'github-bot/gh-386'
git switch 'main'
git merge --ff-only 'github-bot/gh-386'
git switch 'main'
git merge 'github-bot/gh-386'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.