GPU: translate enhanced texture barriers in ID3D12GraphicsCommandList7::Barrier #642
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!642
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-642"
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?
@nathanbzrr on GitHub · 2026-11-24 06:06 UTC · original
nathanbzrr:gpu/enhanced-texture-barriers→main· +1286 −19 · 1 files · 1 commits · openSummary
On Windows/D3D12.X titles using
ID3D12GraphicsCommandList7::Barrier(command list vtable slot 146 /0x490),barrier_groupsonmainignores thegroupspointer and emits only a single globalUAV_BARRIER. While legacyResourceBarriertranslates texture transitions throughHostList::transition, Enhanced Barriers currently drop all texture layout transitions, leaving host render targets, depth/Hi-Z buffers, and copy targets un-transitioned or compressed when read via SM 6.6ResourceDescriptorHeapdirect indexing, causing D3D12 debug layer errors and breaking cross-list state tracking inHostList::prelude.Changes (
crates/victory-gpu/src/list.rs)#[repr(C)]BarrierGroup(16 bytes) andTextureBarrier(64 bytes) matching D3D12D3D12_BARRIER_GROUPandD3D12_TEXTURE_BARRIER, guarded by compile-timesize_of!andoffset_of!assertions on Windows.enhanced_layout_state(layout: u32) -> Option<u32>mappingD3D12_BARRIER_LAYOUTvalues (common/present/queue-specific, generic read, render target, unordered access, depth-stencil write/read, shader resource, copy source/dest, resolve source/dest, shading rate source) to legacyD3D12_RESOURCE_STATES, returningNoneforUNDEFINED(u32::MAX) and unsupported layouts.barrier_groupsto:D3D12_BARRIER_TYPE_TEXTURE(kind == 1) barriers vialist.transition+crate::host::legal_stateinto legacyD3D12_RESOURCE_BARRIERtransitions.SyncAfter == D3D12_BARRIER_SYNC_SPLIT) and execute transitions on split-end.Barrier()call to avoidRESOURCE_BARRIER_DUPLICATE_SUBRESOURCE_TRANSITIONS.kind == 0 | 2) and UAV-access texture barriers.Verification
Isolated verification on branch
gpu/enhanced-texture-barriers(bf4ad1d):rustfmt --edition 2024 --config skip_children=true --check crates/victory-gpu/src/list.rs(passed)cargo test -p victory-gpu -- --test-threads=1(45 passed, 0 failed, 1 ignored; includesenhanced_layout_mapping_and_abiandenhanced_texture_barrier_transitions_and_propagates_across_lists)VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics -- --test-threads=1(47 passed, 0 failed, 1 ignored; zero D3D12 debug layer errors)cargo clippy -p victory-gpu --all-targets(0 warnings inlist.rs; 1 pre-existing warning athost.rs:267)cargo xtask policy(151 files ok)No game files. AI-assisted; reviewed and verified with the tests above.
@fuzeofficlal on GitHub · 2026-11-24 06:32 UTC · original
I added a synthetic two-mip texture to check the range passed to the normal enhanced-barrier path. At
bf4ad1d, an enhanced transition targeting flat subresource 1 puts mip 0 inCOPY_SOURCEas well. On both RTX 5090 and WARP, the debug layer rejected a subsequent mip 0 render-target clear during recording. The failing list was stopped before submission.I tried the change on a stack of this head and #594 (
3070871), using its existing per-subresource tracker. On both adapters, the flat index and a one-mip explicit range each let mip 1 read back its yellow value and mip 0 read back its independently cleared green value. The D3D12 debug layer reported zero errors, and the diagnostics suite passed 48 tests with one benchmark ignored per adapter. These readbacks cover a 2D single-plane texture.Incremental source change on the two-head stack
@nathanbzrr on GitHub · 2026-11-24 06:34 UTC · original
Thanks @LAKSHYA-cmd-tech for catching the
0.5 * 255.0 = 127.5float-to-UNORM rounding variance!Updated the clear values in
enhanced_texture_barrier_transitions_and_propagates_across_lists(commit6b98706) to exactn / 255.0UNORM values so the channel conversions land on exact integers across all GPU drivers.Re-verified on branch
gpu/enhanced-texture-barriers:cargo test -p victory-gpu -- --test-threads=1(45 passed, 0 failed, 1 ignored)VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics -- --test-threads=1(47 passed, 0 failed, 1 ignored)cargo clippy -p victory-gpu --all-targets(0 warnings inlist.rs)cargo xtask policy(151 files ok)@nathanbzrr on GitHub · 2026-11-24 06:49 UTC · original
Thanks @fuzeofficlal for testing the two-mip subresource case and verifying the
#594+#642stack on RTX 5090 and WARP!Confirmed:
#642intentionally targetsmain's whole-resourceHostList::transition(matching legacyhost_barrieratcrates/victory-gpu/src/list.rs:305) so it stays decoupled from and doesn't collide with#594's per-subresource tracker. Once#594lands, wiringb.subresources(flat subresource index and explicit mip/slice/plane ranges) onto#594's per-subresource tracker is the natural follow-up.Also note that commit
6b98706(already pushed togpu/enhanced-texture-barriers) updated the clear colors inenhanced_texture_barrier_transitions_and_propagates_across_liststo exactn / 255.0UNORM values to avoid0.5 * 255.0 = 127.5driver rounding variance.@DeerSilver on GitHub · 2026-11-24 10:36 UTC · original
Tested the current head
6b987062d(with the exactn / 255.0clear values) merged ontomainffe310e(clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1: pass. No game files: the test suite only.enhanced_layout_mapping_and_abienhanced_texture_barrier_transitions_and_propagates_across_listsenhanced_texture_barrier_transitions_and_propagates_across_listsreturns early without a host GPU. Here it ran on the RTX 5060 (DXGI adapter 0 on this laptop), so the cross-list transitions and the exact cleared channels hold on NVIDIA at this head.cargo test --workspace --locked: 344 passed, 0 failed, 6 ignored, against 342 / 6 onmainat the same commit.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.I didn't repeat @fuzeofficlal's two-mip subresource check: the D3D12 debug layer isn't installed here. This run covers the whole-resource path the PR targets.
AI-assisted (Claude Code).
@nathanbzrr on GitHub · 2026-11-24 22:10 UTC · original
Rebased onto
origin/main(70564ae, new headsc4ee0e6/bdef690):origin/main'sallocate_uploadUploadbacking (0f63757),with_state,clear_unordered_uint(0b35b7f), andHostList::transition/twin::routeintegration (13bbd6f).barrier_groups, enhanced texture barrier structs/ABI checks, exact UNORM clear values (bdef690), and cross-list transition tests intact.#1439currently reportsCONFLICTINGafterorigin/mainmoved to70564ae, so keeping this PR cleanly rebased ensures#1439can pick up the70564ae-compatible head cleanly.Verified on
bdef690(Windows MSVC):rustfmt --edition 2024 --check crates/victory-gpu/src/list.rs: all#642hunks clean (only pre-existingorigin/maindiffs inwith_state/allocate_upload).cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo test --workspace --locked:478 passed, 0 failed, 7 ignored(victory-gpu:80 passed, 0 failed, 1 ignored;xtask:4 passed).@Marvisak on GitHub · 2026-11-25 00:32 UTC · original · edited 2026-11-25 22:27 UTC
Automated triage for the maintainers.
Merge candidate, with one behaviour change to confirm. Reviewed at
4783e28, which merges cleanly intomain.barrier_groupsincrates/victory-gpu/src/list.rs(ID3D12GraphicsCommandList7::Barrier, already wired at slot 146 onmain) now reads the groups instead of ignoring them:layout_afteris mapped to a legacy state (enhanced_layout_state;UNDEFINEDand the video layouts give none) and goes throughlist.transitionandhost::legal_state. That keeps the cross-list tracker inHostList::preluderight for textures shaders read straight from the heap, whichdraw::State::binddoes not move itself. The new test shows that case onmain(render target, then a heap SRV read withoutensure_state).is_whole_resource_barrier).The
BarrierGroup/TextureBarrierlayouts are checked against thewindowscrate's D3D12 types at compile time; the layout values follow Microsoft's public enhanced-barrier documentation. main's diagnostics breadcrumb (note_op) is kept.The change to confirm:
mainemitted one global UAV barrier for everyBarriercall. Now a call made only of texture barriers, with no UAV access before or after, emits only the transitions and no global UAV barrier. By the D3D12 rules that is enough, but it changes ordering on title paths thatmaincovered with the blanket barrier.On your reply: the rebase keeps
main's breadcrumb and adapts to the ownedID3D12Resourcereturns, and the earlier four points (premise, partial ranges, layout evidence, formatting churn) are addressed. CI:checkpassing on this head.Generated by Claude Code
@nathanbzrr on GitHub · 2026-11-25 00:58 UTC · original
Rebased onto
origin/main(42363ab, new heads87c98ed/4d4da75):crates/victory-gpu/src/list.rs, keepingorigin/main'sresolve_queries_rejects_overflowing_offset(628b95d) and initial pipeline binding changes (e52777a/8d3a025) alongside#642's enhanced texture barrier translation and tests.Verified locally (Windows MSVC):
4118f33(cc71a22):cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --locked: 705 passed, 0 failed, 10 ignoredcargo xtask policy: 182 files ok42363ab(4d4da75):cargo test -p victory-gpu --locked -- --test-threads=1: 143 passed, 0 failed, 2 ignoredVICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked -- --test-threads=1: 146 passed, 0 failed, 2 ignored@nathanbzrr on GitHub · 2026-11-25 03:26 UTC · original
Updated onto
origin/main(940d32f, squashed head6264e86) addressing the four triage items:draw::State::binddoes not calllist::ensure_stateon textures referenced solely through a descriptor heap unlesstitle_written(texture)is true (false for GPU-written render targets), so those reads rely on the title's barrier to moveRENDER_TARGET -> SHADER_RESOURCE. Onmain(crates/victory-gpu/src/list.rs:1374),barrier_groupsignoreslayout_afterand leaves the resource tracked inRENDER_TARGET. Addedlist::tests::enhanced_texture_barrier_transitions_render_target_for_heap_srv_read(RTV clear ->barrier_groupsRENDER_TARGET -> SHADER_RESOURCE-> compute shader reading the SRV directly from a shader-visible view heap withoutensure_state, assertinghlist.transition(tex, 0x40 | 0x80).is_none(), readback[64, 128, 192, 255], and 0 D3D12 debug-layer errors).D3D12_BARRIER_SUBRESOURCE_RANGEandis_whole_resource_barrier, gatinglist.transitionon whole-resource barriers so partial ranges are skipped without disturbing sibling mips/slices/planes (while still honoring UAV ordering flags). Addedlist::tests::enhanced_texture_barrier_skips_partial_subresource_rangescovering @fuzeofficlal's two-mip case (mip-0 clear -> mip-1 flat index 1 and explicit mip-1 range barriers toCOPY_SOURCE-> subsequent mip-0 clear, assertingRENDER_TARGETis preserved and 0 D3D12 debug-layer errors occur).barrier_groups) is already wired onmaininNEWER_METHODS(crates/victory-gpu/src/list.rs:1514), and allBarrierGroup,TextureBarrier,D3D12_BARRIER_SUBRESOURCE_RANGE, andD3D12_BARRIER_LAYOUTlayouts/values match the Windows D3D12 headers at compile time and inenhanced_layout_mapping_and_abi. This environment has no local title binary/disassembly (per asset policy), so verifying slot-146 call sites directly from the title's own executable remains open for someone with a local binary.clear_dsv,allocate_upload,execute_indirect, andallocate_upload_is_aligned_and_below_40_bits). The diff now touches onlycrates/victory-gpu/src/list.rsin two hunks (barrier_groupsandmod tests).Verified on
6264e86(Windows MSVC):cargo run -p xtask -- policy --staged:asset policy: 1 files okcargo clippy --workspace --all-targets -- -D warnings&--all-features: cleancargo test -p victory-gpu --locked list: 13 passed, 0 failedVICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked list -- --test-threads=1: 13 passed, 0 failed (0 D3D12 debug-layer errors)cargo test --workspace --locked: 0 failures across all workspace crates@nathanbzrr on GitHub · 2026-11-25 21:54 UTC · original
Rebased onto
origin/main(61bfc77, new head4783e28):crates/victory-gpu/src/list.rsinsidebarrier_groups, keeping enhanced texture barrier translation and partial-subresource gating while preservingorigin/main's diagnostics breadcrumb (list.note_op(...)fromeed1670).host_resource/list.transition/host::legal_state/host::transition/host.rtvborrows fororigin/main's ownedID3D12Resourcereturn values (69d1e8e) and updatednew_newer_listinlist::testsforList::hosts/List::segment(9cc37c5).Verified on
4783e28(Windows MSVC):cargo run -p xtask -- policy:asset policy: 186 files okcargo clippy -p victory-gpu --all-targets --locked -- -D warnings&--all-features: cleancargo test -p victory-gpu --lib --locked -- list::tests --test-threads=1: 8 passed, 0 failedVICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- list::tests --test-threads=1: 8 passed, 0 failedView 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.