GPU: track mip states for 2D color targets #559
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!559
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-24 04:55 UTC · original
fuzeofficlal:fix/texture2d-mip-states→main· +754 −83 · 8 files · 1 commits · openReproduction
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.
@fromthemoonx on GitHub · 2026-11-24 09:14 UTC · original
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.
@fuzeofficlal on GitHub · 2026-11-24 16:39 UTC · original
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.@Marvisak on GitHub · 2026-11-25 00:25 UTC · original · edited 2026-11-26 01:23 UTC
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
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.