GPU: report allocated mips from GetDesc #933
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!933
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@enzoduarte1 on GitHub · 2026-11-24 14:18 UTC · original
enzoduarte1:gpu/getdesc-automatic-mips→main· +50 −3 · 1 files · 1 commits · openWhat
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).@MichaelSmithAI on GitHub · 2026-11-24 14:22 UTC · original
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.
@dcastell1 on GitHub · 2026-11-24 14:28 UTC · original
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.@Zipettte on GitHub · 2026-11-24 15:40 UTC · original
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).
@fuzeofficlal on GitHub · 2026-11-24 17:24 UTC · original
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.@Marvisak on GitHub · 2026-11-25 01:25 UTC · original
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
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 07:53 UTC · original
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.