GPU: copy compatible multisampled texture aliases directly #2314

Open
github-bot wants to merge 2 commits from github-bot/gh-2314 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 10:27 UTC · original
andrewpozdnakov7-jpg:fix/msaa-texture-alias-copy → main · +132 −7 · 2 files · 2 commits · open

A multisampled alias could go through the linear-buffer path in alias_copy. D3D12 requires matching sample counts for the copy. The multisampled path now uses CopyResource when the actual host dimensions, mip counts, sample descriptions and format families match. It keeps the current main's deferred host writes. D3D12 copy rules

The same WARP test clears a synthetic 4x MSAA D32_FLOAT texture to 0.375 and its R32_FLOAT alias to -0.5. On main at 67e8ae1401, closing the list after the alias copy returns E_INVALIDARG. With 8c8cfb4, the list closes and all 16 resolved pixels read 0.375. Serial victory-gpu on WARP passed with 199 passed and 1 ignored in both debug flag settings. Strict GPU Clippy in both modes and repository policy passed. In five parallel runs per arm, the existing submission-copy test failed twice on main and three times on the patch. The descriptor rewrite test also failed once on the patch.

Coordination claim

Please preserve the Git author when reapplying the change. If you fold the code or test into another commit, please add this trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic tests only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 10:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/2314) `andrewpozdnakov7-jpg:fix/msaa-texture-alias-copy` → `main` · +132 −7 · 2 files · 2 commits · open A multisampled alias could go through the linear-buffer path in alias_copy. D3D12 requires matching sample counts for the copy. The multisampled path now uses CopyResource when the actual host dimensions, mip counts, sample descriptions and format families match. It keeps the current main's deferred host writes. [D3D12 copy rules](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copyresource) The same WARP test clears a synthetic 4x MSAA D32_FLOAT texture to 0.375 and its R32_FLOAT alias to -0.5. On main at 67e8ae1401df112248aed36d0024483181b718b7, closing the list after the alias copy returns E_INVALIDARG. With 8c8cfb4, the list closes and all 16 resolved pixels read 0.375. Serial victory-gpu on WARP passed with 199 passed and 1 ignored in both debug flag settings. Strict GPU Clippy in both modes and repository policy passed. In five parallel runs per arm, the existing submission-copy test failed twice on main and three times on the patch. The descriptor rewrite test also failed once on the patch. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) Please preserve the Git author when reapplying the change. If you fold the code or test into another commit, please add this trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic tests only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:00 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 11:02 UTC · original

I checked the overlap with #2275 at b6a9ebe. Git reports a conflict beside the start of alias_copy. The tested combination dac5b2b keeps the direct MSAA path first and checks the array mip count before the single-sample footprint path. It preserves both original histories and includes both WARP readback tests.

Both regressions passed together. Full forced-WARP GPU suite gave 149 passed, 2 ignored. GPU Clippy in both feature modes and repository policy passed. #2274 at 8a88297 merges cleanly with this PR individually (textual merge checked).

If you fold our changes or tests into another commit, please keep:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic tests only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 11:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2314#issuecomment-7160500987) I checked the overlap with #2275 at `b6a9ebe`. Git reports a conflict beside the start of `alias_copy`. The [tested combination `dac5b2b`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/dac5b2baa2b87d9702f7c415cd2bc13277e29ab6) keeps the direct MSAA path first and checks the array mip count before the single-sample footprint path. It preserves both original histories and includes both WARP readback tests. Both regressions passed together. Full forced-WARP GPU suite gave 149 passed, 2 ignored. GPU Clippy in both feature modes and repository policy passed. #2274 at `8a88297` merges cleanly with this PR individually (textual merge checked). If you fold our changes or tests into another commit, please keep: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic tests only.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:26 UTC · original · edited 2026-11-25 16:47 UTC

Automated triage for the maintainers.

Merge candidate.

On main, texture::alias_copy sends multisampled aliases through the single-sample buffer-footprint path, which gives an invalid list (E_INVALIDARG at Close). This PR copies them with CopyResource when the sample description, dimensions, mip and array counts and format family (resource::family) match. Otherwise it logs once and skips the copy. The checks match D3D12's CopyResource rules, and the existing host-write and state transitions are kept through prepare. The WARP test multisampled_aliases_copy_all_samples clears a 4x D32 depth texture and its R32 alias to different values, copies, resolves and checks every pixel, so it tests what is correct rather than what the code does.

This overlaps alias_copy in #2275. Whichever merges second will need a small rebase; the author has posted a tested combination.

CI (check): passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2314#issuecomment-7166845746) · edited 2026-11-25 16:47 UTC <!-- victory-triage v1 head=8c8cfb4f8559bb43ea08fa0d4d3a922db868ab19 verdict=merge-candidate at=2026-11-25T16:42:19Z --> Automated triage for the maintainers. **Merge candidate.** On main, `texture::alias_copy` sends multisampled aliases through the single-sample buffer-footprint path, which gives an invalid list (`E_INVALIDARG` at `Close`). This PR copies them with `CopyResource` when the sample description, dimensions, mip and array counts and format family (`resource::family`) match. Otherwise it logs once and skips the copy. The checks match D3D12's `CopyResource` rules, and the existing host-write and state transitions are kept through `prepare`. The WARP test `multisampled_aliases_copy_all_samples` clears a 4x D32 depth texture and its R32 alias to different values, copies, resolves and checks every pixel, so it tests what is correct rather than what the code does. This overlaps `alias_copy` in #2275. Whichever merges second will need a small rebase; the author has posted a tested combination. CI (`check`): passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 16:28 UTC · original

Updated the branch for current main at 67e8ae1401. The same WARP test fails at native command list Close with E_INVALIDARG on main and resolves all 16 pixels to 0.375 with the patch. Serial GPU tests passed in both debug flag settings (199 passed, 1 ignored). The existing submission-copy test was intermittent in parallel on both revisions. The descriptor rewrite test failed once in the patched parallel runs. Strict GPU Clippy and repository policy passed.

Updated branch commit

If you fold the change or test into another commit, please preserve the Git author or add this trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 16:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2314#issuecomment-7168047977) Updated the branch for current main at 67e8ae1401df112248aed36d0024483181b718b7. The same WARP test fails at native command list Close with E_INVALIDARG on main and resolves all 16 pixels to 0.375 with the patch. Serial GPU tests passed in both debug flag settings (199 passed, 1 ignored). The existing submission-copy test was intermittent in parallel on both revisions. The descriptor rewrite test failed once in the patched parallel runs. Strict GPU Clippy and repository policy passed. [Updated branch commit](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/8c8cfb4f8559bb43ea08fa0d4d3a922db868ab19) If you fold the change or test into another commit, please preserve the Git author or add this trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 10:43 UTC · original · approved these changes

Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Allowing compatible multisampled texture aliases to copy directly via CopyResource cleanly preserves all samples without going through a staging buffer.
  • cargo test -p victory-gpu resource::tests: 11/11 passed on RTX 5090 (including multisampled_aliases_copy_all_samples).
  • cargo test -p victory-gpu texture::tests: 2/2 passed on RTX 5090, 2/2 passed on WARP.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 10:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2314#pullrequestreview-6056070806) · **approved these changes** Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Allowing compatible multisampled texture aliases to copy directly via `CopyResource` cleanly preserves all samples without going through a staging buffer. - `cargo test -p victory-gpu resource::tests`: 11/11 passed on RTX 5090 (including `multisampled_aliases_copy_all_samples`). - `cargo test -p victory-gpu texture::tests`: 2/2 passed on RTX 5090, 2/2 passed on WARP. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 10:54 UTC · original · reviewed

Copy-compatible multisampled texture aliases copy all samples directly (+104 host-GPU test). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

**@⁠catminou4** on GitHub · 2026-11-25 10:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2314#pullrequestreview-6056243249) · **reviewed** Copy-compatible multisampled texture aliases copy all samples directly (+104 host-GPU test). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 19:00 UTC · original · approved these changes

Reviewed 8c8cfb4f8559 merged cleanly onto 63bcca43.

The direct multisampled copy path in crates/victory-gpu/src/texture.rs:252-290 handles MSAA texture aliases cleanly:

  • Guards CopyResource behind exact agreement on SampleDesc, (Dimension, Width, Height, DepthOrArraySize, MipLevels), and resource::family(Format) (texture.rs:274-284), falling back to a logged skip for incompatible multisampled aliases instead of routing them through a single-sample linear staging buffer.
  • Shares the prepare helper (texture.rs:268-272) so host_writes(list, to) and COPY_SOURCE/COPY_DEST transitions stay consistent with the single-sample path.

Hardware & D3D12 Debug Layer verification (RTX 5090 + Microsoft WARP, VICTORY_D3D12_DEBUG=1):

  • cargo xtask policy and cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) pass cleanly.
  • resource::tests::multisampled_aliases_copy_all_samples passes on both RTX 5090 and WARP under VICTORY_D3D12_DEBUG=1.
  • Verified an additional Debug Layer probe exercising 4 incompatible MSAA pairs (4x->1x, 4x->2x, 4x4->8x8, and R32_TYPELESS->R8G8B8A8_UNORM 4x) and 2 compatible 4x MSAA pairs (D32_FLOAT->R32_FLOAT and D16_UNORM->R16_UNORM): all 4 incompatible cases skipped without incrementing ALIAS_COPIES, both compatible cases copied directly via CopyResource, GetDeviceRemovedReason().is_ok(), and host.log_messages() == None on both RTX 5090 and WARP.
  • Also verified a clean 3-way co-merge with #2319 and #2358 on 63bcca43 with all three GPU tests passing under VICTORY_D3D12_DEBUG=1 on both adapters.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2314#pullrequestreview-6079267630) · **approved these changes** Reviewed `8c8cfb4f8559` merged cleanly onto `63bcca43`. The direct multisampled copy path in `crates/victory-gpu/src/texture.rs:252-290` handles MSAA texture aliases cleanly: - Guards `CopyResource` behind exact agreement on `SampleDesc`, `(Dimension, Width, Height, DepthOrArraySize, MipLevels)`, and `resource::family(Format)` (`texture.rs:274-284`), falling back to a logged skip for incompatible multisampled aliases instead of routing them through a single-sample linear staging buffer. - Shares the `prepare` helper (`texture.rs:268-272`) so `host_writes(list, to)` and `COPY_SOURCE`/`COPY_DEST` transitions stay consistent with the single-sample path. **Hardware & D3D12 Debug Layer verification** (RTX 5090 + Microsoft WARP, `VICTORY_D3D12_DEBUG=1`): - `cargo xtask policy` and `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) pass cleanly. - `resource::tests::multisampled_aliases_copy_all_samples` passes on both RTX 5090 and WARP under `VICTORY_D3D12_DEBUG=1`. - Verified an additional Debug Layer probe exercising 4 incompatible MSAA pairs (`4x->1x`, `4x->2x`, `4x4->8x8`, and `R32_TYPELESS->R8G8B8A8_UNORM` 4x) and 2 compatible 4x MSAA pairs (`D32_FLOAT->R32_FLOAT` and `D16_UNORM->R16_UNORM`): all 4 incompatible cases skipped without incrementing `ALIAS_COPIES`, both compatible cases copied directly via `CopyResource`, `GetDeviceRemovedReason().is_ok()`, and `host.log_messages() == None` on both RTX 5090 and WARP. - Also verified a clean 3-way co-merge with `#2319` and `#2358` on `63bcca43` with all three GPU tests passing under `VICTORY_D3D12_DEBUG=1` on both adapters. LGTM.
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/2314/head:github-bot/gh-2314'
git switch 'github-bot/gh-2314'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2314'
git switch 'github-bot/gh-2314'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2314'
git switch 'github-bot/gh-2314'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2314'
git switch 'main'
git merge --squash 'github-bot/gh-2314'
git switch 'main'
git merge --ff-only 'github-bot/gh-2314'
git switch 'main'
git merge 'github-bot/gh-2314'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!2314
No description provided.