Repository navigation
D3D12.X: translate list #146 enhanced barrier groups into legacy texture transitions - #3287
Conversation
…cy texture transitions Port barrier_groups.rs from amd-dev (a68f609 + fdd1ac2, raylitebull) onto main: - Translates command list xcl-dev#146 Barrier(groups) texture barriers into legacy D3D12_RESOURCE_BARRIER transitions routed through list_x::resource_barrier_x, including DEPTH_READ (0x20) on depth-read layouts and independent depth/stencil plane tracking. - Tracks legacy ResourceBarrier state updates via note_legacy_state and clears per-resource state on resource release (real.rs). - Exposes depth_uav::kept for depth-twin PARK state coordination. - Opt-out via XCL_BARRIER_GROUPS=0 (the global UAV barrier remains).
|
Two exact CPU translation controls on 2b75212 show distinct ways a legal partial range can affect an independent mip. I compiled the production transitions_of, state_of, range and plane functions with a fixed shape callback and the same per-plane state representation. The resource was a two-mip, 66-slice, single-plane texture (132 subresources).
These checks inspected the emitted barrier words without submitting inconsistent transitions to a driver. No device fault, title test or frame-performance claim. OpenAI Codex wrote and ran the bounded harness and drafted this comment. |
|
The small range-only patch below passed six production transitions_of CPU controls on 2b75212: 64 and 65 even indices, 66 odd indices, 128 consecutive interior indices, one final index, and a genuine full range. Each assertion compared the entire index sequence in order. Expanding a partial range costs one 32-byte legacy record per selected subresource plus the temporary 4-byte index; the complete range stays one record. For bounded peak memory across very large groups, stream exact batches to the caller instead of broadening the barrier. There is a separate integration constraint on the proposed per-subresource state fix: transitions_of currently calls moved before transitions filters/refines states in out.retain_mut. Moving to sparse state storage alone would still cache an after-state for a transition later refused or rewritten. A small isolated default-state-plus-overrides model passed mixed siblings, adjacent ranges, unknown prior state, return-to-default, and full-reset controls. I'd wire updates to accepted effective transitions, preserve unknown when no transition can be established, and account for split barriers and reset/discarded recordings before treating that model as authoritative. The diff here fixes range widening only. --- a/crates/xcl/src/hle/d3d12x/barrier_groups.rs
+++ b/crates/xcl/src/hle/d3d12x/barrier_groups.rs
@@ -47,9 +47,6 @@
/// D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY, END_ONLY
const BEGIN_ONLY: u32 = 1;
const END_ONLY: u32 = 2;
-/// subresources of one barrier's range named one by one at most (more: all of the texture)
-const RANGE_MOST: usize = 64;
-
/// Whether the title's barrier groups become transitions (`XCL_BARRIER_GROUPS`, on unless "0").
pub(super) fn enabled() -> bool {
static ON: OnceLock<bool> = OnceLock::new();
@@ -103,7 +100,7 @@
let s = first_slice.min(array)..first_slice.saturating_add(n_slices.max(1)).min(array);
let p = first_plane.min(planes)..first_plane.saturating_add(n_planes.max(1)).min(planes);
let count = m.len() * s.len() * p.len();
- if count == (mips * array * planes) as usize || count > RANGE_MOST {
+ if count == (mips * array * planes) as usize {
return None;
}
let mut out = Vec::with_capacity(count);
@@ -522,7 +519,7 @@
// past the texture: what there is of it
assert_eq!(subresources([2, 8, 0, 1, 0, 1], 4, 1, 1), Some(vec![2, 3]));
// more than are named one by one: all
- assert_eq!(subresources([0, 1, 0, 100, 0, 1], 2, 100, 1), None);
+ assert_eq!(subresources([0, 1, 0, 100, 0, 1], 2, 100, 1), Some((0..200).step_by(2).collect()));
}
fn t(res: usize, layout: (u32, u32), access: (u32, u32)) -> Texture {OpenAI Codex prepared and tested the range change and state model. CPU translation controls only. |
…to ALL_SUBRESOURCES
|
Good catch, thank you! Applied the exact-index range fix in �d5ee498 (removed RANGE_MOST = 64 so partial ranges never widen to ALL_SUBRESOURCES, and added unit assertions for 65- and 100-slice partial ranges alongside the full-range case; cargo test -p xcl --lib barrier_groups 8/8 passing). Agreed on keeping per-subresource post-filter state tracking (wired after out.retain_mut with split-barrier and command-list reset semantics) as a separate follow-up. |
|
Note: my #3299 is a port of the same amd-dev commit (#146 barrier groups), opened about 2 hours after this one; I missed this PR when I checked for duplicates. The two are nearly identical. Differences (from
Only one of the two should be merged; the maintainer can pick. If this one goes in, the alignment check from #3299 would be worth adding here, and I'll close #3299. (Written with Claude Code, Claude Opus 5.5.) |
What is in it
Ports
crates/xcl/src/hle/d3d12x/barrier_groups.rsfromamd-dev(a68f609f+fdd1ac2d,raylitebull) ontomain, translating command list slot#146(Barrier(groups)) texture enhanced barriers into legacyD3D12_RESOURCE_BARRIERtransitions routed throughlist_x::resource_barrier_x:D3D12_BARRIER_LAYOUT_*+D3D12_BARRIER_ACCESS_*to PCD3D12_RESOURCE_STATES(includingDEPTH_READ0x20on depth-read layouts and independent depth/stencil plane state tracking).Close()(E_INVALIDARG), handles splitBEGIN_ONLY/END_ONLYbarriers, keeps partial subresource ranges exact instead of widening large ranges toALL_SUBRESOURCES, and tracksUNDEFINEDlayout transitions from the last known state.list_x::resource_barrier_xto keep legacy barrier state in sync viabarrier_groups::note_legacy_state, clears per-resource state on release inreal.rs, and exposesdepth_uav::keptfor depth-twinPARKcoordination.XCL_BARRIER_GROUPS=0(keeps the global UAV barrier).Tested
cargo test -p xcl --lib barrier_groupspassed (8 passed; 0 failed).xcl-smokeregression run below on NVIDIA GeForce RTX 5070 Ti (XCL_PREPARE=0,0device removals,0crashes,0E_INVALIDARG/Closefailures; live log confirmed8192+title texture barriers translated into7250+legacy transitions).Regression run
Baseline (
mainancestorf0e8fdd5c3942ddd399d5ee11384c8595c5aacff):PR branch (
bd5ee498d4805c3263b264d497ddfc482f704bfe):Not tested
amd-devcommits were tested on RX 9070 XT).ea3b5e4d.AI use
Ported from
amd-dev(a68f609f+fdd1ac2d), wired ontomain, and verified with an AI coding agent; reviewed by hand against unit tests, 150 s smoke logs, andlist_x::resource_barrier_x/depth_uavintegration.