Reject multisampled linear texture layouts #629

Merged
AlanQiang0418 merged 1 commit from upstream-pr/629 into main 2026-11-25 00:20:35 +00:00
AlanQiang0418 commented 2026-11-24 05:55:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AlanQiang0418 on 2026-11-24T05:55:09Z.


Layout::new accepted a 256 × 256 linear RGBA8 surface at 2× MSAA and returned an addressable 262,144-byte layout, the same size as at 1×. The linear path calculates row sizes and offsets for a single sample. AMD’s GFX10 address library rejects this combination during swizzle validation. AMD reference implementation

This change rejects the descriptor with Error::Invalid before constructing the layout. The regression test covers 2×, 4× and 8×, checks that the 1× linear texture stays addressable, and checks the allocation size for each sample count with SW_64KB_R_X.

The regression test failed on d2a4bae and passed with the fix. cargo test --locked -p victory-formats on Windows passed 21 tests. The three tests that require external data were skipped. The staged asset-policy check passed. Testing used synthetic descriptors.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575622715 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/629). Originally posted by [AlanQiang0418](https://github.com/AlanQiang0418) on 2026-11-24T05:55:09Z. --- `Layout::new` accepted a 256 × 256 linear RGBA8 surface at 2× MSAA and returned an addressable 262,144-byte layout, the same size as at 1×. The linear path calculates row sizes and offsets for a single sample. AMD’s GFX10 address library rejects this combination during swizzle validation. [AMD reference implementation](https://github.com/GPUOpen-Drivers/pal/blob/dev/src/core/imported/addrlib/src/gfx10/gfx10addrlib.cpp#L2593-L2601) This change rejects the descriptor with `Error::Invalid` before constructing the layout. The regression test covers 2×, 4× and 8×, checks that the 1× linear texture stays addressable, and checks the allocation size for each sample count with `SW_64KB_R_X`. The regression test failed on `d2a4bae` and passed with the fix. `cargo test --locked -p victory-formats` on Windows passed 21 tests. The three tests that require external data were skipped. The staged asset-policy check passed. Testing used synthetic descriptors.
LAKSHYA-cmd-tech commented 2026-11-24 06:54:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T05:56:58Z.

Review: APPROVED


Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).

  • cargo test -p victory-formats: all 21 synthetic tests passed cleanly, including the new linear_layouts_require_one_sample test.
  • cargo xtask policy: passed (151 files ok).
  • Verified GFX10 swizzle validation compatibility where multisampled linear layouts are invalid.
<!-- greyfinch-sync:Marvisak/VIctory:review:6034391603 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/629#pullrequestreview-6034391603). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T05:56:58Z. **Review:** APPROVED --- Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc). - cargo test -p victory-formats: all 21 synthetic tests passed cleanly, including the new linear_layouts_require_one_sample test. - cargo xtask policy: passed (151 files ok). - Verified GFX10 swizzle validation compatibility where multisampled linear layouts are invalid.
geiyiliyabumo commented 2026-11-24 11:04:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T10:52:58Z.


Independent verification & code review on Windows 11 Pro (build 26100, Rust 1.98.1), cleanly merged onto main (ffe310e):

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-formats --all-targets --locked -- -D warnings: PASS
  • cargo test -p victory-formats --locked: 24 passed, 0 failed, 4 ignored (including new texture::tests::linear_layouts_require_one_sample)

Diff review (crates/victory-formats/src/texture.rs): minimal, exact, and well-tested — rejecting d.samples > 1 for Swizzle::LINEAR prevents under-sized linear layouts while preserving tiled MSAA (SW_64KB_R_X etc.).

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129369699 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/629#issuecomment-7129369699). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T10:52:58Z. --- Independent verification & code review on Windows 11 Pro (build 26100, Rust `1.98.1`), cleanly merged onto `main` (`ffe310e`): - `cargo xtask policy`: PASS (`154 files ok`) - `cargo clippy -p victory-formats --all-targets --locked -- -D warnings`: PASS - `cargo test -p victory-formats --locked`: **24 passed, 0 failed, 4 ignored** (including new `texture::tests::linear_layouts_require_one_sample`) Diff review (`crates/victory-formats/src/texture.rs`): minimal, exact, and well-tested — rejecting `d.samples > 1` for `Swizzle::LINEAR` prevents under-sized linear layouts while preserving tiled MSAA (`SW_64KB_R_X` etc.). *AI-assisted; synthetic tests only, no game files.*
mercuryVM commented 2026-11-24 12:04:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:15:58Z.

Review: APPROVED


Tested 350f91c on Windows 11, RTX 5070, MSVC: cargo test -p victory-formats 21 passed, including linear_layouts_require_one_sample. cargo clippy -p victory-formats --all-targets is clean.

  • The linear path sizes rows for one sample, so returning a 1× layout for a 2×/4×/8× linear surface was silently wrong. Rejecting it with Error::Invalid matches addrlib's swizzle validation, and the test confirms the tiled MSAA path still scales by sample count.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6038225778 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/629#pullrequestreview-6038225778). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T11:15:58Z. **Review:** APPROVED --- Tested 350f91c on Windows 11, RTX 5070, MSVC: `cargo test -p victory-formats` 21 passed, including `linear_layouts_require_one_sample`. `cargo clippy -p victory-formats --all-targets` is clean. - The linear path sizes rows for one sample, so returning a 1× layout for a 2×/4×/8× linear surface was silently wrong. Rejecting it with `Error::Invalid` matches addrlib's swizzle validation, and the test confirms the tiled MSAA path still scales by sample count. AI-assisted (Claude Code).
catminou4 commented 2026-11-24 12:04:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T11:24:04Z.

Review: APPROVED


Correct and conservative: multisampled textures now require a tiled swizzle (d.swizzle != Swizzle::LINEAR added to the samples > 1 clause), since linear layouts can't express per-sample tiles. Single-sample linear textures are untouched (samples == 1 short-circuits), and tiled MSAA still passes with size == single * samples.

The new test pins both directions: LINEAR + {2,4,8} samples → Err(Error::Invalid), tiled + samples → accepted with the expected size. Verified locally: test-merge with current main (ffe310e) clean; cargo test -p victory-formats --locked (macOS arm64, rustc 1.98.1) → 24 passed / 0 failed / 4 ignored (includes the new test).

<!-- greyfinch-sync:Marvisak/VIctory:review:6038329467 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/629#pullrequestreview-6038329467). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T11:24:04Z. **Review:** APPROVED --- Correct and conservative: multisampled textures now require a tiled swizzle (`d.swizzle != Swizzle::LINEAR` added to the `samples > 1` clause), since linear layouts can't express per-sample tiles. Single-sample linear textures are untouched (`samples == 1` short-circuits), and tiled MSAA still passes with `size == single * samples`. The new test pins both directions: LINEAR + {2,4,8} samples → `Err(Error::Invalid)`, tiled + samples → accepted with the expected size. Verified locally: test-merge with current main (`ffe310e`) clean; `cargo test -p victory-formats --locked` (macOS arm64, rustc 1.98.1) → **24 passed / 0 failed / 4 ignored** (includes the new test).
molodayamama commented 2026-11-24 15:03:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by molodayamama on 2026-11-24T14:08:38Z.


Independent Windows check of 350f91c23a9402b2a556a84c208a80030910ae3f (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).

  • cargo test --locked -p victory-formats --lib linear_layouts_require_one_sample -- --nocapture: 1 passed.

The new fixture passed for rejecting multisampled linear layouts. This checks the texture descriptor validation before allocation or GPU work.

Only source-built synthetic fixtures were used. AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133907433 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/629#issuecomment-7133907433). Originally posted by [molodayamama](https://github.com/molodayamama) on 2026-11-24T14:08:38Z. --- Independent Windows check of `350f91c23a9402b2a556a84c208a80030910ae3f` (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64). - `cargo test --locked -p victory-formats --lib linear_layouts_require_one_sample -- --nocapture`: 1 passed. The new fixture passed for rejecting multisampled linear layouts. This checks the texture descriptor validation before allocation or GPU work. Only source-built synthetic fixtures were used. AI-assisted verification.
upstream-sync closed this pull request 2026-11-25 01:04:33 +00:00
Yoshi-233 commented 2026-11-25 03:03:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yoshi-233 on 2026-11-25T02:47:22Z.


I checked the backport on native x86-64 Linux (Ubuntu 24.04.5, Rust 1.98.1). On Zettrox/ztrx@90b529f, the new test failed before the fix: a 256×256 RGBA8 linear descriptor returned 262,144 bytes at 1×, 2×, 4× and 8×. Your patch applied unchanged. Afterwards only 1× succeeded for linear; the tiled SW_64KB_R_X control still returned 262,144 / 524,288 / 1,048,576 / 2,097,152 bytes. All eight outcomes matched upstream 940d32f.

The downstream victory-formats library suite passed 25 tests after the backport, with four repository-marked tests ignored. This was a CPU-only descriptor check with synthetic inputs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151189202 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/629#issuecomment-7151189202). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-25T02:47:22Z. --- I checked the backport on native x86-64 Linux (Ubuntu 24.04.5, Rust 1.98.1). On `Zettrox/ztrx@90b529f`, the new test failed before the fix: a 256×256 RGBA8 linear descriptor returned 262,144 bytes at 1×, 2×, 4× and 8×. Your patch applied unchanged. Afterwards only 1× succeeded for linear; the tiled `SW_64KB_R_X` control still returned 262,144 / 524,288 / 1,048,576 / 2,097,152 bytes. All eight outcomes matched upstream `940d32f`. The downstream `victory-formats` library suite passed 25 tests after the backport, with four repository-marked tests ignored. This was a CPU-only descriptor check with synthetic inputs.
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!629
No description provided.