GPU: report allocated mips from GetDesc #933
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/933"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by enzoduarte1 on 2026-11-24T14:18:56Z.
What
CreateCommittedResourcewithMipLevels = 0allocates a full mip chain, but the guestGetDesc(slot0x50) returned the description verbatim, so titles saw zero levels. Native D3D12 reports the allocated count. This patch reuses the existingmip_counthelper when filling the output description, leaving explicit mip counts untouched.Fixes #773.
Tested
x86_64-pc-windows-gnu(no MSVC linker on this machine).cargo test -p victory-gpu --lib -- --test-threads=1: 51 passed, 1 ignored (existing benchmark).get_desc_reports_the_allocated_mip_chaincovers a 4x4 automatic chain (3 levels), an explicit 2-level texture and a buffer (1 level).git diff --checkclean;rustfmt --edition 2024 --checkshows only a pre-existing formatting diff atresource.rs:867, untouched by this change.cargo xtask policy: 154 files ok. No game files or data taken from them were added.Checklist
cargo fmt --all --checkandcargo test --workspacepass — this workspace has pre-existing formatting diffs and the loader fixture needs MSVC/DELAYLOAD, which MinGW rejects here; the changed crate is clean.cargo xtask policypasses. The change adds no game files or data taken from them (docs/asset-policy.md).Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T14:23:48Z.
Review: APPROVED
Tested
9914ea4on Windows 11, RTX 5070, MSVC:cargo test -p victory-gpu -- --test-threads=151 passed, includingget_desc_reports_the_allocated_mip_chain. Clippy's 1 warning is the existingundocumented_unsafe_blocksin host.rs.mip_levelsonly when the title asked for 0 matches nativeGetDesc, which reports what was allocated, and leaves explicit counts and buffers alone. Reusingmip_countkeeps it consistent with whatcreate_committedactually made.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:24:12Z.
Review: COMMENTED
Tested merged cleanly onto
main(ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):cargo test -p victory-gpu(RTX 5090): 51 passed, 0 failed, 1 ignored (includingresource::tests::get_desc_reports_the_allocated_mip_chain)VICTORY_D3D12_WARP=1 cargo test -p victory-gpu(WARP): 51 passed, 0 failed, 1 ignoredcargo xtask policy: okcargo clippy -p victory-gpu --all-targets: 1clippy::undocumented_unsafe_blockswarning (which will fail CI's-D warnings):crates/victory-gpu/src/resource.rs:1250:if let Some(out) = unsafe { out.as_mut() }is missing a preceding// SAFETY:comment.Tests and runtime behavior look good — adding the
// SAFETY:comment onresource.rs:1250will make clippy/CI clean.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T14:22:16Z.
The author’s GetDesc test passed on exact
9914ea4under RTX 4090 Wine/GE 3.2. An additional guest-vtable test checked committed 4×2 textures with nine array slices or volume depth nine. Guest and host both reported three automatic levels for the array and four for the volume. Both reported two for an explicit request of two.I submitted a follow-up that uses a raw write into the caller’s potentially uninitialized output storage and includes the additional test. Both GetDesc tests passed on that head.
Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T14:28:37Z.
Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build.
main@ffe310ebaseline on this box: 342 passed, 0 failed, 6 ignored.One more than the baseline; reporting allocated mips from
GetDescis covered and green.Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran
cargo test --workspace, reverted it.Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:53Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
9914ea4:cargo test -p victory-gpupasses, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:24:28Z.
Verified the
GetDescexpanded mip-count fix on NVIDIA GeForce RTX 5090 (D3D12 Debug Layer) and D3D12 WARP (D3D12 Debug Layer) (0debug errors), includingMaybeUninit<ResourceDesc>out-pointer calls across 1D / 2D / 2D Array / 3DMipLevels == 0textures and per-mip RTV clear + readback across all expanded levels:fuzeofficlal/VIctory@519f91e.Confirming the two items blocking CI / soundness in
9914ea4:if !out.is_null()+// SAFETY:+unsafe { out.write(desc) };rather thanunsafe { out.as_mut() }: callers ofID3D12Resource::GetDescpass an uninitialized stack slot for the C++ out-return struct, so materializing&mut ResourceDescviaas_mut()is immediate UB in Rust, and omitting// SAFETY:fails-D clippy::undocumented_unsafe_blocksin CI.if desc.dimension != BUFFER && desc.mip_levels == 0 { desc.mip_levels = mip_count(&desc) as u16; }beforeout.write(desc)is 4 lines and passes Clippy cleanly.upstream-sync referenced this pull request2026-11-24 19:03:41 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:25:23Z.
Automated triage for the maintainers.
Needs work. The change is right, but CI is red because of how it is written.
resource_desc(guestGetDesc, slot0x50, incrates/victory-gpu/src/resource.rs) now fills inMipLevels = 0withmip_count(&desc), the chaincreate_committedactually allocates. Explicit counts are left as they are. This matches what native D3D12 reports. Testers in the thread confirmed it on NVIDIA, AMD and Wine.What it needs:
unsafe block missing a safety commentatresource.rs:1250.as_mut()here. The title passes the C++ out-return slot, which can be uninitialized, and turning it into&mut ResourceDescis unsound. Keepmain'sif !out.is_null()with the// SAFETY:comment andunsafe { out.write(desc) }, and adjustdescbefore the write.dimension == BUFFER, so a buffer described withMipLevels = 0does not get a chain computed from its width.With those changes this is a merge candidate.
CI:
checkfails (the clippy error above).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T07:53:32Z.
I addressed the two review points in 625ed94, directly on
9914ea4be88aaad665e26e43eaec768f3a3a77dd. It retains main's checked pointer write and computes an automatic count only for textures.The same guest
GetDesctest returned 9 for a 256-byte buffer whose stored count was zero before the change, and returns the stored zero afterward. The automatic 4×4 texture still reports 3, the explicit 2-mip texture reports 2, and the normal buffer reports 1. The WARP GPU suite went from 53 passed / 1 failed / 1 ignored to 54 passed / 0 failed / 1 ignored. Strict GPU Clippy reproduced the existing missing safety comment failure before and passed afterward with and without diagnostics. A local merge into940d32f69b22265690a0b5a15d6ded572ba33bafwas clean and passed 147 GPU tests on WARP, with 2 ignored.Thanks to @fuzeofficlal for the verification and review. If you include the follow-up, please preserve its Git author. If you fold it into your commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.