GPU: track mip states for 2D color targets #559
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/559"
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 fuzeofficlal on 2026-11-24T04:55:41Z.
Reproduction
Bind mip 0 of a two-mip RGBA8 Texture2D as an SRV, with only that mip visible to the shader, and bind mip 1 as the RTV. On
d2a4bae, draw setup transitions the entire texture to render-target state. The D3D12 debug layer then reports that mip 0 is inRENDER_TARGETwhen the shader needsPIXEL_SHADER_RESOURCE. The baseline check stopped at command recording.Change
Use the selected mip range for plane-zero SRVs and RTVs of non-array 2D color targets. Track only the mips that differ from the command list's uniform texture state. Restore those mips before a whole-resource transition and at list close, so the submission prelude can continue using one state per texture. The compact regression test checks the split states and the ordering of the reconciliation barriers.
Verified
On native D3D12 with RTX 5090 and WARP, the synthetic draw left all 64 pixels of mip 0 intact and changed all 16 pixels of mip 1 from the clear color to the sampled color. Both same-list readback and readback from a second command list passed, with zero D3D12 debug errors through submission.
cargo test --locked --workspace -- --test-threads=1— 265 passed, 0 failed, 4 ignored.cargo xtask policy --stagedandcargo xtask policy— passed.The pixel fixture uses a synthetic pipeline. Nearby changes in #469 and #485 touch the tracker and SRV preparation respectively, which may need a mechanical rebase if either lands first.
Imported from Marvisak/VIctory. Originally posted by fromthemoonx on 2026-11-24T09:14:26Z.
Tested
ca896f6merged onto currentmain(8e79c80; it merges cleanly, with auto-merges inhost.rsandlist.rs) on NVIDIA.Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1
x86_64-pc-windows-msvc.CI's commands, on the merge
cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --locked: 312 passed, 0 failed, 6 ignored (main: 311 / 0 / 6, plus the new test)What the regression test covers. I checked it by breaking the change locally:
transitions_keep_color_target_mips_independentHostList::transitionignores the mip range (mips.filter(|_| false))resource.rs:1626HostList::closedrops its reconciliation barriers (barriers.clear()beforeResourceBarrier)So the test guards the per-mip tracking and the order of the barriers before a whole-resource transition, but not the close-time reconciliation the description relies on ("Restore those mips before a whole-resource transition and at list close, so the submission prelude can continue using one state per texture"). If
closestopped restoring, the next submission's prelude would transition the texture from a whole-resource state that some of its mips aren't in, and no test would notice. One way to cover it: haveclosecollect its barriers through a function the test can call, the waytransitiontakes arecordcallback. Then assert that a list left with mip 0 inPIXEL_SHADER_RESOURCEemits(0, PIXEL_SHADER_RESOURCE → RENDER_TARGET)at close.Reading the change: the rest looks consistent to me. A texture's first use through a mip range sets only the uniform state, so the prelude still gets one state.
srv_mipsreturnsNonefor a view of all mips, so those keep the whole-resource path. A title split barrier is mapped per mip only for non-array 2D color targets (color_mip) and keepsALL_SUBRESOURCESotherwise.Not tested:
d3d12SDKLayers.dll). The debug layer didn't load, and a deliberately wrong before-state also went unreported, so that run proves nothing either way.AI-assisted (Claude Code) ran the checks and drafted this comment.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T16:39:21Z.
Thanks for catching the
close()mutation gap — rebased ontoffe310e, extractedHostList::close_transitionssotransitions_keep_color_target_mips_independentdirectly asserts close-time per-mip reconciliation (plus clearing onclose()), and included the synthetic two-mip sample-and-render readback test covering both single-list and cross-submission paths on RTX 5090 (VICTORY_D3D12_DEBUG=1) and WARP.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:25:30Z.
Automated triage for the maintainers.
Merge candidate (unchanged). The new head is one commit on current
mainand merges cleanly. Only non-array, multi-mip 2D render-target textures get per-mip tracking (host::color_mip_count). The mip ranges come from SRVs (descriptor::host::srv_mips), RTVs and clears (descriptor::rtv_mips,list::ensure_mips), and title barriers (list::color_mip).HostList::transitionstores the mips that differ from the uniform state inTrackedTexture::mips. A whole-resource transition, andclosethroughclose_transitions, first move those mips back, so the submission prelude still sees one state per texture.I checked that
move_texture/track, which don't unify mips, are only reached for twin planes, depth textures and first-use uploads, none of which have diverged mips at that point. The testtransitions_keep_color_target_mips_independentcovers divergence, reunification and close.CI: passing (
check).Generated by Claude Code
upstream-sync referenced this pull request2026-11-25 07:03:17 +00:00
upstream-sync referenced this pull request2026-11-25 20:06:13 +00:00
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T00:52:12Z.
Review: APPROVED
LGTM — verified on Windows (RTX 5090):
cargo test -p victory-gpu --libpassed (231/231, skipping the 2 pre-existingorigin/mainRTX 5090 failures)cargo clippy -p victory-gpu --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (191 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.