Skip to content

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

Open
Xvania7 wants to merge 1 commit into
Marvisak:mainfrom
Xvania7:fix/issue-773-mip-levels
Open

Xvania7 wants to merge 1 commit into
Marvisak:mainfrom
Xvania7:fix/issue-773-mip-levels

Conversation

@Xvania7

@Xvania7 Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown

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

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

RecompLive added a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
…y #2193)

A texture made with MipLevels 0 got its whole chain in memory but told the
title 0. GetDesc now answers mip_count, as the console does (fxceless#773).

Ported from Marvisak/VIctory#2193 (Xvania7), GPL-3.0-or-later.
@MamaLeVrai

Copy link
Copy Markdown

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.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

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 GPU: avoid shift and arithmetic overflow panics in subresource and copyable_footprints (victory-gpu) #1543 lands first, we will gladly rebase and reuse its factored out helper.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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 9849794. 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 andrewpozdnakov7-jpg@users.noreply.github.com

AI-assisted with Codex. Synthetic textures on WARP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetDesc returns zero mips for automatically sized textures

6 participants