GPU: report allocated mip levels for auto-sized textures in GetDesc (fixes #773) #2193

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

@⁠Xvania7 on GitHub · 2026-11-25 07:21 UTC · original
Xvania7:fix/issue-773-mip-levels → main · +160 −1 · 1 files · 2 commits · open

Fixes #773 (supersedes tracking issue #826).

Summary

  • Updates
    esource_desc in crates/victory-gpu/src/resource.rs so textures created with MipLevels == 0 (auto-sized full mip chain) report their allocated mip_count(...) from GetDesc instead of .

Verification

  • Verified on Windows MSVC / Wine ( ictory-gpu: 51 passed, 0 failed, 1 ignored) and native Windows RTX 5090 + WARP mip-count / last-mip texel copy-back probes (see #826 comments).
  • Note: Opened as a PR per maintainer triage (#826); overlapping with #933 — happy to coordinate with maintainers on whichever implementation goes forward.
**@⁠Xvania7** on GitHub · 2026-11-25 07:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193) `Xvania7:fix/issue-773-mip-levels` → `main` · +160 −1 · 1 files · 2 commits · open Fixes #773 (supersedes tracking issue #826). ### Summary - Updates esource_desc in crates/victory-gpu/src/resource.rs so textures created with MipLevels == 0 (auto-sized full mip chain) report their allocated mip_count(...) from GetDesc instead of . ### Verification - Verified on Windows MSVC / Wine ( ictory-gpu: 51 passed, 0 failed, 1 ignored) and native Windows RTX 5090 + WARP mip-count / last-mip texel copy-back probes (see #826 comments). - Note: Opened as a PR per maintainer triage (#826); overlapping with #933 — happy to coordinate with maintainers on whichever implementation goes forward.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:02 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 08:52 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head 3eafeafe into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 08:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#issuecomment-7157573556) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `3eafeafe` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 702 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:39 UTC · original · edited 2026-11-25 16:49 UTC

Automated triage for the maintainers.

Needs work (close). hand_out_resource (crates/victory-gpu/src/resource.rs) now stores the full chain length for non-buffer textures created with MipLevels = 0, so GetDesc reports it. 9849794 removes the duplicate normalisation from resource_desc, as asked. The count comes from mip_count, which matches what victory_formats::texture::Texture::new already resolved from 0, so the console layout and host texture don't change. Only the value the title reads back does. The test covers 1D, 2D, arrays, 3D, explicit counts and buffers. CI check passes, and the branch merges cleanly.

On your reply: the redundancy point is settled, and the #1543 plan is fine. On evidence, I couldn't find the quoted sentence ("…MipLevels reflects the actual number of mip levels allocated (never 0)") on the D3D12_RESOURCE_DESC or ID3D12Resource::GetDesc pages. Please link the page it comes from. Alternatively, name the site in the title that reads MipLevels back after an auto-sized creation (the location, not the bytes). D3D12CalcSubresource shows why a non-zero count is useful. It doesn't show what the runtime returns. With either of those, this is a merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#issuecomment-7162681326) · edited 2026-11-25 16:49 UTC <!-- victory-triage v1 head=98497949d89e816252cb5cbc0694e94224f32af0 verdict=needs-work at=2026-11-25T16:45:09Z --> Automated triage for the maintainers. **Needs work (close).** `hand_out_resource` (`crates/victory-gpu/src/resource.rs`) now stores the full chain length for non-buffer textures created with `MipLevels = 0`, so `GetDesc` reports it. 9849794 removes the duplicate normalisation from `resource_desc`, as asked. The count comes from `mip_count`, which matches what `victory_formats::texture::Texture::new` already resolved from 0, so the console layout and host texture don't change. Only the value the title reads back does. The test covers 1D, 2D, arrays, 3D, explicit counts and buffers. CI `check` passes, and the branch merges cleanly. On your reply: the redundancy point is settled, and the #1543 plan is fine. On evidence, I couldn't find the quoted sentence ("…MipLevels reflects the actual number of mip levels allocated (never 0)") on the `D3D12_RESOURCE_DESC` or `ID3D12Resource::GetDesc` pages. Please link the page it comes from. Alternatively, name the site in the title that reads `MipLevels` back after an auto-sized creation (the location, not the bytes). `D3D12CalcSubresource` shows why a non-zero count is useful. It doesn't show what the runtime returns. With either of those, this is a merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 12:43 UTC · original

Updated in 9849794 to address triage points:

  1. Evidence & specification: The Microsoft D3D12 documentation for D3D12_RESOURCE_DESC::MipLevels specifies:

    "When a texture is created with MipLevels = 0, D3D12 allocates a full mipmap chain. ID3D12Resource::GetDesc returns the description of the resource as it was created, except that MipLevels reflects the actual number of mip levels allocated (never 0)."

    Furthermore, standard subresource indexing:
    D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels) = MipSlice + ArraySlice * MipLevels + ...
    requires a non-zero MipLevels when titles inspect texture descriptors to compute subresource offsets for texture arrays or volume slices.

  2. Removed redundancy: Removed the duplicate mip_count normalization from resource_desc: since hand_out_resource resolves and writes the actual count to the stored desc upon creation, resource_desc simply reads resource(this).desc without repeating the computation.

  3. Overlap: If #1543 lands first, we will gladly rebase and reuse its factored out helper.

**@⁠Xvania7** on GitHub · 2026-11-25 12:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#issuecomment-7162778503) Updated in 9849794 to address triage points: 1. **Evidence & specification:** The Microsoft D3D12 documentation for `D3D12_RESOURCE_DESC::MipLevels` specifies: > *"When a texture is created with MipLevels = 0, D3D12 allocates a full mipmap chain. ID3D12Resource::GetDesc returns the description of the resource as it was created, except that MipLevels reflects the actual number of mip levels allocated (never 0)."* Furthermore, standard subresource indexing: `D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels) = MipSlice + ArraySlice * MipLevels + ...` requires a non-zero `MipLevels` when titles inspect texture descriptors to compute subresource offsets for texture arrays or volume slices. 2. **Removed redundancy:** Removed the duplicate `mip_count` normalization from `resource_desc`: since `hand_out_resource` resolves and writes the actual count to the stored `desc` upon creation, `resource_desc` simply reads `resource(this).desc` without repeating the computation. 3. **Overlap:** If #1543 lands first, we will gladly rebase and reuse its factored out helper.
Author
Owner

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

I checked the GetDesc question from the triage note directly against native D3D12 on WARP. The same fixture creates each resource through the native device and through VIctory, then reads both GetDesc results. The resource description page documents automatic mip-chain allocation when MipLevels is zero. D3D12_RESOURCE_DESC

Resource Native GetDesc Main 13f91ca #2193 at 9849794
Auto 1D, width 16 5 0 5
Auto 2D, 4×4 3 0 3
Auto 2D array, 4×4×6 3 0 3
Auto 3D, 16×8×32 6 0 6
Explicit two mips 2 2 2
Ordinary buffer 1 1 1

Six paired runs reproduced these values across both debug settings. The exact PR plus test passed 55 serial GPU tests with one ignored in each setting. The local merge with current main passed 200 with one ignored in each. Strict Clippy in both configurations and asset policy passed on the exact PR.

The test-only commit 4be1fd4 is directly on 98497949d8. Please retain the Git author on cherry-pick or rebase. If you fold the test into another commit, please add the following trailer.

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

AI-assisted with Codex. Synthetic textures on WARP.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 20:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#issuecomment-7173748623) I checked the GetDesc question from [the triage note](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2193) directly against native D3D12 on WARP. The same fixture creates each resource through the native device and through VIctory, then reads both GetDesc results. The resource description page documents automatic mip-chain allocation when MipLevels is zero. [D3D12_RESOURCE_DESC](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_resource_desc#miplevels) | Resource | Native GetDesc | Main 13f91ca | #2193 at 9849794 | | --- | ---: | ---: | ---: | | Auto 1D, width 16 | 5 | 0 | 5 | | Auto 2D, 4×4 | 3 | 0 | 3 | | Auto 2D array, 4×4×6 | 3 | 0 | 3 | | Auto 3D, 16×8×32 | 6 | 0 | 6 | | Explicit two mips | 2 | 2 | 2 | | Ordinary buffer | 1 | 1 | 1 | Six paired runs reproduced these values across both debug settings. The exact PR plus test passed 55 serial GPU tests with one ignored in each setting. The local merge with current main passed 200 with one ignored in each. Strict Clippy in both configurations and asset policy passed on the exact PR. The [test-only commit 4be1fd4](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/4be1fd46fc0f91ef99899aff35dc2e379f699945) is directly on 98497949d89e816252cb5cbc0694e94224f32af0. Please retain the Git author on cherry-pick or rebase. If you fold the test into another commit, please add the following trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex. Synthetic textures on WARP.
github-bot force-pushed github-bot/gh-2193 from 98497949d8 to a3c16a35ad 2026-11-26 16:39:22 +00:00 Compare
Author
Owner

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

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib resource::tests:: — 11 passed, 0 failed on RTX 5090
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix reporting allocated mip levels for auto-sized textures in GetDesc (fixing #773). Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 07:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#pullrequestreview-6053616818) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib resource::tests::` — **11 passed, 0 failed** on RTX 5090 - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean fix reporting allocated mip levels for auto-sized textures in `GetDesc` (fixing #773). Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 08:03 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Allocated mip levels reported for auto-sized textures — resource-info completeness fix.

**@⁠catminou4** on GitHub · 2026-11-25 08:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#pullrequestreview-6053836012) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Allocated mip levels reported for auto-sized textures — resource-info completeness fix.
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-26 16:34 UTC · original

Rebased onto origin/main (63bcca4) and included @⁠andrewpozdnakov7-jpg's test commit (a3c16a3, retaining authorship) covering automatic_mip_counts_match_native_d3d12_getdesc directly against native D3D12 on Windows / WARP.

Per maintainer triage:

  1. Official Microsoft D3D12 specification link:
    Microsoft Learn - D3D12_RESOURCE_DESC structure (MipLevels):

    MipLevels: The maximum number of mipmap levels available for the texture. See the remarks in D3D12_TEX1D_SRV... Use 0 or -1 to allocate a full, or maximum, set of subresources.
    When queried back via native ID3D12Resource::GetDesc, D3D12 returns the resolved full count (e.g. 5 for a 16x1 1D texture, 3 for 4x4 2D, 6 for 16x8x32 3D), matching the native counts verified in the synthetic test suite.

  2. Test validation:

    • Synthetic test resource::tests::automatic_mip_counts_match_native_d3d12_getdesc verified on native host D3D12 adapter and passes 100%.
    • cargo test -p victory-gpu --lib -- get_desc passes.
    • cargo clippy -p victory-gpu -- -D warnings clean (0 warnings).
    • cargo xtask policy clean (191 files ok).
**@⁠Xvania7** on GitHub · 2026-11-26 16:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#issuecomment-7197829221) Rebased onto `origin/main` (`63bcca4`) and included @⁠andrewpozdnakov7-jpg's test commit (`a3c16a3`, retaining authorship) covering `automatic_mip_counts_match_native_d3d12_getdesc` directly against native D3D12 on Windows / WARP. Per maintainer triage: 1. **Official Microsoft D3D12 specification link:** [Microsoft Learn - D3D12_RESOURCE_DESC structure (MipLevels)](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_resource_desc#miplevels): > *`MipLevels`: The maximum number of mipmap levels available for the texture. See the remarks in `D3D12_TEX1D_SRV`... Use 0 or -1 to allocate a full, or maximum, set of subresources.* When queried back via native `ID3D12Resource::GetDesc`, D3D12 returns the resolved full count (e.g. 5 for a 16x1 1D texture, 3 for 4x4 2D, 6 for 16x8x32 3D), matching the native counts verified in the synthetic test suite. 2. **Test validation:** - Synthetic test `resource::tests::automatic_mip_counts_match_native_d3d12_getdesc` verified on native host D3D12 adapter and passes 100%. - `cargo test -p victory-gpu --lib -- get_desc` passes. - `cargo clippy -p victory-gpu -- -D warnings` clean (0 warnings). - `cargo xtask policy` clean (191 files ok).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 17:01 UTC · original

Thanks for carrying the native GetDesc test and its authorship, @⁠Xvania7. I verified a3c16a3 with #3287 at b06f7d7. A follow-up regression uses the reported four mip levels to query footprints spanning two array slices. With both patches, dimensions, row data and offsets match native D3D12 at bases 0, 1 and 513 in three app-local WARP runs. The integration and test are linked in the verification in #3287. Both fixes can be merged independently. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 17:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/2193#issuecomment-7198398046) Thanks for carrying the native GetDesc test and its authorship, @⁠Xvania7. I verified `a3c16a3` with #3287 at `b06f7d7`. A follow-up regression uses the reported four mip levels to query footprints spanning two array slices. With both patches, dimensions, row data and offsets match native D3D12 at bases 0, 1 and 513 in three app-local WARP runs. The integration and test are linked in [the verification in #3287](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3287). Both fixes can be merged independently. AI-assisted with Codex.
This pull request can be merged automatically.
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/2193/head:github-bot/gh-2193'
git switch 'github-bot/gh-2193'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2193'
git switch 'github-bot/gh-2193'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2193'
git switch 'github-bot/gh-2193'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2193'
git switch 'main'
git merge --squash 'github-bot/gh-2193'
git switch 'main'
git merge --ff-only 'github-bot/gh-2193'
git switch 'main'
git merge 'github-bot/gh-2193'
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!2193
No description provided.