Repository navigation
Conversation
|
Copied DSVs can remap the previous destination resource. At
I then explicitly remapped both resources using direct descriptors before any GPU write. A clear of A to 0.25 followed by a clear of the replaced destination to 0.75 gave fenced D16 readbacks of Both copy hooks already forward DSV changes to AI use: OpenAI Codex (GPT-6) prepared and ran the test-only fixture and wrote the report. |
|
RTVs are affected too at I repeated the DSV replacement control with two independent R32_FLOAT targets. After both were superseded and unmapped, recreating B's RTV at A's former handle and binding it through OMSetRenderTargets remapped B only. Replacing that same handle via CopyDescriptorsSimple or CopyDescriptors (one range, one descriptor) instead remapped A only; B remained unmapped. Before each GPU write I restored both targets through direct handles. A clear of A to 0.25 followed by a clear of the replaced destination to 0.75 gave 0.25 on A and 0.75 on B across all 262,144 texels of each, for all three replacement methods. Six fresh processes, zero skips. The copied native RTV thus points at B while the bind's resource lookup still selects A. Both RTV and DSV copy bookkeeping merit coverage when fixing the destination association. No title run or unmapped write. AI use: OpenAI Codex (GPT-6) prepared and ran the native controls and wrote this follow-up. |
|
Ran the superseded-target remapping tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used. |
|
A candidate fix for the copied-RTV/DSV remapping findings is included below. It applies to On Windows with an RTX 5070 12 GB, direct recreation, The 13 placement tests passed, including the added CPU regression with different source/destination range boundaries, two untracked sources and an untouched gap. The existing depth-twin descriptor-copy control also passed. Native ranged controls used a single range; the multi-range result is from the CPU test. Scope was synthetic descriptor copying and remapping. Full workspace and title runs were outside this check. Applyable four-file patch including regression test--- a/crates/xcl/src/hle/d3d12x/real.rs
+++ b/crates/xcl/src/hle/d3d12x/real.rs
@@ -2373,6 +2373,20 @@
}
}
+/// Native RTV/DSV copies change the resource named at the destination just like recreating the view.
+unsafe fn copy_target_views(ty: u32, n: u32, dst: u64, src: u64, inc: u64) {
+ if ty == D3D12_DESCRIPTOR_HEAP_TYPE_RTV.0 as u32 {
+ super::present::copy_rtvs(n, dst, src, inc);
+ } else {
+ super::placements::copy_dsvs(n, dst, src, inc);
+ super::depth_uav::copy_dsvs(n, dst, src, inc);
+ }
+}
+
+fn is_target_heap(ty: u32) -> bool {
+ ty == D3D12_DESCRIPTOR_HEAP_TYPE_RTV.0 as u32 || ty == D3D12_DESCRIPTOR_HEAP_TYPE_DSV.0 as u32
+}
+
/// #24 CopyDescriptorsSimple(n, dst, src, type)
unsafe extern "system" fn dev_copy_descriptors_simple_x(this: *mut c_void, n: u32, dst: u64, src: u64, ty: u32) {
let _t = crate::hle::api_cost::time_if(super::look_stats::deep(), crate::hle::api_cost::Call::ViewDescriptor);
@@ -2385,8 +2399,9 @@
note_mixed_copy();
return;
}
- if ty == D3D12_DESCRIPTOR_HEAP_TYPE_DSV.0 as u32 {
- super::depth_uav::dsvs_copied(this, n, dst, src);
+ if is_target_heap(ty) {
+ let inc = dev_increment_size_x(this, ty) as u64;
+ copy_target_views(ty, n, dst, src, inc);
}
let f: unsafe extern "system" fn(*mut c_void, u32, u64, u64, u32) = std::mem::transmute(orig_fn(this, 24));
f(this, n, dst, src, ty);
@@ -2405,8 +2420,14 @@
note_mixed_copy();
return;
}
- if ty == D3D12_DESCRIPTOR_HEAP_TYPE_DSV.0 as u32 {
- super::depth_uav::dsv_ranges_copied(this, nd, dsts, dsizes, ns, srcs, ssizes);
+ if is_target_heap(ty) && !dsts.is_null() && !srcs.is_null() {
+ let inc = dev_increment_size_x(this, ty) as u64;
+ let ranges = |starts: *const u64, sizes: *const u32, n: u32| -> Vec<(u64, u32)> {
+ (0..n as usize).map(|i| (*starts.add(i), if sizes.is_null() { 1 } else { *sizes.add(i) })).collect()
+ };
+ for (dst, src, n) in super::depth_uav::pieces(&ranges(dsts, dsizes, nd), &ranges(srcs, ssizes, ns), inc) {
+ copy_target_views(ty, n, dst, src, inc);
+ }
}
type F = unsafe extern "system" fn(*mut c_void, u32, *const u64, *const u32, u32, *const u64, *const u32, u32);
let f: F = std::mem::transmute(orig_fn(this, 23));
--- a/crates/xcl/src/hle/d3d12x/depth_uav.rs
+++ b/crates/xcl/src/hle/d3d12x/depth_uav.rs
@@ -851,45 +851,8 @@
}
}
-/// The DSV handle increment of `dev`, read once.
-unsafe fn dsv_increment(dev: *mut c_void) -> u64 {
- static INC: AtomicU32 = AtomicU32::new(0);
- let mut inc = INC.load(Ordering::Relaxed);
- if inc == 0 {
- let Some(d) = ID3D12Device::from_raw_borrowed(&dev) else { return 0 };
- inc = d.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
- INC.store(inc, Ordering::Relaxed);
- }
- inc as u64
-}
-
-/// CopyDescriptorsSimple of `n` DSVs from `src` to `dst`: each destination names what its source
-/// names, or nothing.
-pub(super) unsafe fn dsvs_copied(dev: *mut c_void, n: u32, dst: u64, src: u64) {
- if DSV_ENTRIES.load(Ordering::Relaxed) == 0 {
- return;
- }
- copy_dsvs(n, dst, src, dsv_increment(dev));
-}
-
-/// CopyDescriptors of DSVs: destination and source ranges (start, length; no lengths: 1 each)
-/// walked in step.
-#[allow(clippy::too_many_arguments)]
-pub(super) unsafe fn dsv_ranges_copied(dev: *mut c_void, nd: u32, dsts: *const u64, dsizes: *const u32, ns: u32, srcs: *const u64, ssizes: *const u32) {
- if DSV_ENTRIES.load(Ordering::Relaxed) == 0 || dsts.is_null() || srcs.is_null() {
- return;
- }
- let ranges = |starts: *const u64, sizes: *const u32, n: u32| -> Vec<(u64, u32)> {
- (0..n as usize).map(|r| (*starts.add(r), if sizes.is_null() { 1 } else { *sizes.add(r) })).collect()
- };
- let inc = dsv_increment(dev);
- for (dst, src, n) in pieces(&ranges(dsts, dsizes, nd), &ranges(srcs, ssizes, ns), inc) {
- copy_dsvs(n, dst, src, inc);
- }
-}
-
/// Destination and source ranges cut where either one ends: (dst, src, n) runs.
-fn pieces(dsts: &[(u64, u32)], srcs: &[(u64, u32)], inc: u64) -> Vec<(u64, u64, u32)> {
+pub(super) fn pieces(dsts: &[(u64, u32)], srcs: &[(u64, u32)], inc: u64) -> Vec<(u64, u64, u32)> {
let (mut out, mut d, mut s, mut dk, mut sk) = (Vec::new(), 0, 0, 0u32, 0u32);
while d < dsts.len() && s < srcs.len() {
let n = (dsts[d].1 - dk).min(srcs[s].1 - sk);
@@ -908,7 +871,8 @@
out
}
-fn copy_dsvs(n: u32, dst: u64, src: u64, inc: u64) {
+pub(super) fn copy_dsvs(n: u32, dst: u64, src: u64, inc: u64) {
+ if DSV_ENTRIES.load(Ordering::Relaxed) == 0 { return; }
for k in 0..n as u64 {
let (to, from) = ((dst + k * inc) as usize, (src + k * inc) as usize);
match DSVS.get(from) {
--- a/crates/xcl/src/hle/d3d12x/placements.rs
+++ b/crates/xcl/src/hle/d3d12x/placements.rs
@@ -587,6 +587,18 @@
}
}
+pub(super) fn copy_dsvs(n: u32, dst: u64, src: u64, inc: u64) {
+ let mut g = DSVS.lock().unwrap();
+ let Some(views) = g.as_mut() else { return };
+ for i in 0..u64::from(n) {
+ let to = (dst + i * inc) as usize;
+ match views.get(&((src + i * inc) as usize)).copied() {
+ Some(res) => { views.insert(to, res); }
+ None => { views.remove(&to); }
+ }
+ }
+}
+
/// The placed texture the DSV at `handle` names.
fn dsv_texture(handle: usize) -> Option<usize> {
DSVS.lock().unwrap().as_ref()?.get(&handle).copied()
@@ -632,6 +644,30 @@
r.remove(a);
r.remove(b);
}
+ #[test]
+ fn copied_dsv_ranges_replace_and_clear_only_their_destinations() {
+ let handles = [0u8; 16];
+ let src = handles.as_ptr() as usize;
+ let dst = src + 8;
+ {
+ let mut guard = DSVS.lock().unwrap();
+ let views = guard.get_or_insert_with(HashMap::new);
+ views.insert(src, 21);
+ views.insert(src + 4, 22);
+ for i in 0..5 { views.insert(dst + i, 19); }
+ }
+ let dsts = [(dst as u64, 2), ((dst + 3) as u64, 2)];
+ let srcs = [(src as u64, 1), ((src + 3) as u64, 3)];
+ for (to, from, n) in super::super::depth_uav::pieces(&dsts, &srcs, 1) {
+ copy_dsvs(n, to, from, 1);
+ }
+ let actual = (0..5).map(|i| dsv_texture(dst + i)).collect::<Vec<_>>();
+ let mut guard = DSVS.lock().unwrap();
+ let views = guard.as_mut().unwrap();
+ for i in 0..16 { views.remove(&(src + i)); }
+ assert_eq!(actual, [Some(21), None, Some(19), Some(22), None]);
+ }
+
const MIB: usize = 1 << 20;
/// A placement looked at, not retiring: (its sequence number, its cases).
--- a/crates/xcl/src/hle/d3d12x/present.rs
+++ b/crates/xcl/src/hle/d3d12x/present.rs
@@ -226,6 +226,27 @@
if let Some(o) = old {
release(o);
}
+}
+
+pub(super) unsafe fn copy_rtvs(n: u32, dst: u64, src: u64, inc: u64) {
+ let mut replaced = Vec::new();
+ {
+ let mut g = RTVS.lock().unwrap();
+ let Some(views) = g.as_mut() else { return };
+ for i in 0..u64::from(n) {
+ let to = (dst + i * inc) as usize;
+ let old = match views.get(&((src + i * inc) as usize)).copied() {
+ Some(res) => {
+ add_ref(res);
+ views.insert(to, res)
+ }
+ None => views.remove(&to),
+ };
+ if let Some(res) = old { replaced.push(res); }
+ }
+ }
+ // Release can call back into descriptor bookkeeping.
+ for res in replaced { release(res); }
}
/// `XCL_TRACE_FRAME=1`: what console code does with each resource it later presents –AI assistance: OpenAI Codex (GPT-6) prepared the candidate, ran the controls and drafted this report. |
fe9039d to
843d868
Compare
|
@andrewDoing thanks, both findings are right: an RTV or DSV written by Fixed in 2d632bd (squashed into the PR's commit, which is now on Edit: the first push of this, 843d868, crashed an existing test ( Not covered: the other pairing on a GPU (an RTV through Written with Claude Code (Claude Fable 5). |
|
@Kalmarv we ran the whole suite of your head on an RTX 3090 against its base on the same machine: no failure the base doesn't have. All 4 new tests pass:
Tested:
Also on a tree with #3179: cherry-picked onto Not tested: a title run; a release build; AMD / Intel. Your loyal testing minion, as ever. AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon. |
843d868 to
2d632bd
Compare
|
Verified the two outstanding GPU pairings on the author’s current implementation, The destination initially named superseded target A, and the source named superseded target B. Both started unmapped. Binding the copied destination remapped B only in both cases:
Each A/B readback independently checked all 262,144 texels. Direct recreation and the converse API pairings gave the same results. The original head Four further cases copied a valid native descriptor whose source association was intentionally absent from XCL’s table. For both copy APIs and both view types, binding left stale A unmapped and all 16,384 pixels of the actually named live target received the clear. 16 fresh-process cases passed, zero skips. This covers normal single-descriptor replacement, including a single range; multi-range copies and retail rendering were outside this run. AI use: OpenAI Codex adapted the prior native fixture to the head’s four-slot test heap, ran the controls and prepared the report. |
|
Independent check of #3192 head
I found two remaining paths that can leave a superseded target unmapped:
Tested candidate for the list #146 boundarydiff --git a/crates/xcl/src/hle/d3d12x/list_x.rs b/crates/xcl/src/hle/d3d12x/list_x.rs
index fe7a11fc..d256eeec 100644
--- a/crates/xcl/src/hle/d3d12x/list_x.rs
+++ b/crates/xcl/src/hle/d3d12x/list_x.rs
@@ -4932,19 +4932,20 @@ pub(super) unsafe extern "system" fn dispatch_x(this: *mut c_void, x: u32, y: u3
/// their order; groups and barrier arrays that are not readable memory are passed over.
unsafe fn barrier_group_textures(n: u32, groups: *const c_void) -> Vec<usize> {
let mut out = Vec::new();
- let count = (n as usize).min(256);
+ let mut seen = HashSet::new();
+ let count = n as usize;
if count == 0 || groups.is_null() || !crate::gpu::shader::readable(groups as usize, count * std::mem::size_of::<D3D12_BARRIER_GROUP>()) {
return out;
}
for g in std::slice::from_raw_parts(groups as *const D3D12_BARRIER_GROUP, count) {
- let m = (g.NumBarriers as usize).min(4096);
+ let m = g.NumBarriers as usize;
let p = g.Anonymous.pTextureBarriers;
if g.Type != D3D12_BARRIER_TYPE_TEXTURE || m == 0 || p.is_null() || !crate::gpu::shader::readable(p as usize, m * std::mem::size_of::<D3D12_TEXTURE_BARRIER>()) {
continue;
}
for b in std::slice::from_raw_parts(p, m) {
let r: usize = transmute_copy(&b.pResource);
- if r != 0 && !out.contains(&r) {
+ if r != 0 && seen.insert(r) {
out.push(r);
}
}
@@ -11789,6 +11790,29 @@ mod tests {
assert_eq!(barrier_group_textures(3, at), vec![0x1000, 0x2000], "the groups past the count are not read");
assert!(barrier_group_textures(0, at).is_empty());
assert!(barrier_group_textures(5, std::ptr::null()).is_empty());
+
+ // A valid group or barrier beyond the old scan caps still names its texture.
+ let one = [tex(0x4000)];
+ let mut many_groups = vec![D3D12_BARRIER_GROUP {
+ Type: D3D12_BARRIER_TYPE_GLOBAL,
+ NumBarriers: 0,
+ Anonymous: D3D12_BARRIER_GROUP_0 { pGlobalBarriers: std::ptr::null() },
+ }; 257];
+ many_groups[256] = D3D12_BARRIER_GROUP {
+ Type: D3D12_BARRIER_TYPE_TEXTURE,
+ NumBarriers: 1,
+ Anonymous: D3D12_BARRIER_GROUP_0 { pTextureBarriers: one.as_ptr() },
+ };
+ assert_eq!(barrier_group_textures(257, many_groups.as_ptr().cast()), vec![0x4000]);
+
+ let mut many_barriers = vec![tex(0); 4097];
+ many_barriers[4096] = tex(0x5000);
+ let group = [D3D12_BARRIER_GROUP {
+ Type: D3D12_BARRIER_TYPE_TEXTURE,
+ NumBarriers: 4097,
+ Anonymous: D3D12_BARRIER_GROUP_0 { pTextureBarriers: many_barriers.as_ptr() },
+ }];
+ assert_eq!(barrier_group_textures(1, group.as_ptr().cast()), vec![0x5000]);
}
}
}Update — GPU reproduction of point 2. I ran the existing superseded-render-target fixture in an isolated child test process with the documented Tested presentation-off reproduction and minimal functional candidatediff --git a/crates/xcl/src/hle/d3d12x/present.rs b/crates/xcl/src/hle/d3d12x/present.rs
index 9e915e39..d81857e1 100644
--- a/crates/xcl/src/hle/d3d12x/present.rs
+++ b/crates/xcl/src/hle/d3d12x/present.rs
@@ -214,9 +214,6 @@ unsafe fn release(p: usize) {
}
pub unsafe fn note_rtv(handle: usize, res: *mut c_void) {
- if !enabled() {
- return;
- }
let mut g = RTVS.lock().unwrap();
let m = g.get_or_insert_with(HashMap::new);
if !res.is_null() {
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
index a174d526..836aabcb 100644
--- a/crates/xcl/src/hle/d3d12x/real.rs
+++ b/crates/xcl/src/hle/d3d12x/real.rs
@@ -14868,6 +14868,38 @@ mod superseded_target_tests {
/// (ClearRenderTargetView) or names it in a texture barrier of list #146's groups, and the
/// clear is in it. Before, only a legacy barrier or a copy gave them back: the target stayed
/// without tiles, what was drawn to it was dropped.
+ #[test]
+ fn gpu_a_superseded_rtv_remaps_when_presentation_is_off() {
+ const CHILD: &str = "XCL_TEST_PRESENT_OFF_CHILD";
+ if std::env::var_os(CHILD).is_none() {
+ let output = std::process::Command::new(std::env::current_exe().expect("test binary"))
+ .arg("--exact")
+ .arg("hle::d3d12x::real::superseded_target_tests::gpu_a_superseded_rtv_remaps_when_presentation_is_off")
+ .arg("--test-threads=1")
+ .env(CHILD, "1")
+ .output()
+ .expect("isolated presentation-off test");
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ if stdout.contains("SKIPPED") {
+ crate::gpu::recomp::runner::skip_test("isolated presentation-off GPU fixture skipped");
+ }
+ assert!(output.status.success(), "isolated presentation-off fixture failed:\n{stdout}\n{stderr}");
+ return;
+ }
+ let mut config = crate::config::Config::default();
+ config.present = "off".into();
+ crate::state::set_boot(crate::config::Boot {
+ title: "synthetic".into(),
+ exe_path: std::path::PathBuf::new(),
+ game_root: std::path::PathBuf::new(),
+ data_dir: std::env::temp_dir(),
+ config,
+ });
+ assert_eq!(crate::state::config().present, "off");
+ gpu_a_superseded_render_target_the_title_binds_clears_or_moves_is_mapped_again();
+ }
+
#[test]
fn gpu_a_superseded_render_target_the_title_binds_clears_or_moves_is_mapped_again() {
let _vram = vram::VRAM_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());The three-line |
|
merge-check claim |
|
@thehollowedone thanks, both hold: Changed in ee8bb3d (squashed into the PR's commit):
Run on ee8bb3d so far (RTX 5070 Ti and WARP, debug): Not run yet on ee8bb3d: the whole suite and the regression run; the description gets both when they are done, and until then its numbers are of 2d632bd. @throny the head is now ee8bb3d. Written with Claude Code (Claude Fable 5). |
2d632bd to
ee8bb3d
Compare
|
merge-check (This replaces our claim above. The smoke we mentioned there is not coming from us: the RTX 5090 is taken up by other work, so this check is the suite on an RTX 3090 only.) |
|
merge-check |
|
World runs for this PR on an RTX 4080 16 GB (621.40), as announced (edited: now 10 runs). With this PR the open world came out lit in 3 of 5 runs (31 to 41 % of the frame); with Tested
Not tested
AI use: Claude Code (Claude Fable 5.2) built the trees, made the runs and wrote this; Claude Haiku 5.5 compared the frames. |
|
Re-ran the superseded-target remapping tests at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used. |
|
I checked this head against newer main after #3179 and #3287 landed. On Windows Release, RTX 5070 Ti Laptop system (NVIDIA 621.24), Rust 1.97.1 MSVC. Placement, barrier-group and superseded-target tests passed 25/25 with no skips. The R32_FLOAT and D16 GPU readback cases also passed 2/2 in a fresh process with OpenAI Codex (GPT-6.2 Sol) assisted with source review and Windows verification. |
…ed again A render target or depth buffer placed on title pages loses its tiles when a newer placement covers other pages of it (placements: superseded), and gets them back when the title uses it again. A use was only seen in a legacy ResourceBarrier or a copy. A title that moves its textures with the barrier groups of list xcl-dev#146 and then clears and draws into such a target was never seen: the target stayed without tiles, every write to it was dropped and every read of it returned 0. A use is now also: - a texture barrier in the groups of list xcl-dev#146 (the groups are read only while the title holds a superseded target, then all groups of the call and all barriers of a group), - OMSetRenderTargets with its RTVs (the handles the list keeps, so a single range is stepped by the device's increment) or its DSV, - ClearRenderTargetView and ClearDepthStencilView of it. The RTV and DSV handles of placed textures are kept for this in one table of addresses (placements::note_view). present's table of RTVs is not used: it holds a reference for each view and is empty with present = "off". A view the title copies (CopyDescriptorsSimple, CopyDescriptors) names what its source names: a bind or clear through a copied view would otherwise look up what its handle named earlier. All of these are calls that record into a list, so the mapping is queued before the list's submit waits for the tile mappings (vram::before_execute). Tests: the textures named by barrier groups, a 257th group and a 4097th barrier among them; the handle table; on a GPU with tiled resources, a superseded R32_FLOAT target and a superseded D16 depth buffer are mapped again by each of the calls above and hold the value they are then cleared to, one bind through a copied RTV and one clear through a copied DSV among them, the RTVs with nothing in present's table. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ee8bb3d to
7c60a35
Compare
|
CI follow-up for head The test can check its own mapped mip groups instead of a device-wide delta, then compare the two fully mapped resources' tile identities to retain the sharing check. This follows the earlier #718 correction. Candidate against this head, not run locally: Candidate test-only diffdiff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -6956,9 +6956,8 @@
super::super::vram::LEVEL_PAGES_FOR_TEST.store(true, Ordering::Relaxed);
let dev_key = dev.as_raw() as usize;
- let dev_pages = || super::super::vram::page_bytes_for(dev_key).0;
- let p0 = dev_pages();
let small = place_tex(at);
+ let small_key = small.as_raw() as usize;
super::super::vram::LEVEL_PAGES_FOR_TEST.store(false, Ordering::Relaxed);
if !super::super::vram::has_lazy_levels(small.as_raw() as usize) {
// (not reserved, or a tiling that does not add up: it has its pages as before)
@@ -6967,14 +6966,14 @@
return println!("SKIPPED {NAME}: this adapter's texture was not placed with lazy levels");
}
super::super::vram::LEVEL_PAGES_FOR_TEST.store(true, Ordering::Relaxed);
- assert_eq!(dev_pages(), p0, "no pages before the first upload");
+ assert_eq!(super::super::vram::mapped_level_tiles(small_key), Some(0), "no pages before the first upload");
// the tiles of mip 0 and of all of it, as this driver lays them out
let (mut all, mut n, mut mip0) = (0u32, 1u32, D3D12_SUBRESOURCE_TILING::default());
dev.GetResourceTiling(&small, Some(&mut all), None, None, Some(&mut n), 0, &mut mip0);
let top_tiles = mip0.WidthInTiles * mip0.HeightInTiles as u32 * mip0.DepthInTiles as u32;
assert!(n == 1 && top_tiles > 0 && top_tiles < all, "mip 0 has tiles of its own: {top_tiles} of {all}");
refresh(queue.as_raw());
- assert_eq!(dev_pages() - p0, ((all - top_tiles) as usize) << 16, "pages for the levels with texels, none for mip 0");
+ assert_eq!(super::super::vram::mapped_level_tiles(small_key), Some((all - top_tiles) as u64), "pages for the levels with texels, none for mip 0");
for sub in 1..11u32 {
assert!(read_sub(&small, sub) == want[sub as usize].data, "level {sub} after the first upload");
}
@@ -6986,7 +6985,7 @@
std::ptr::copy_nonoverlapping(whole.as_ptr().add(top), (at + top) as *mut u8, size - top);
let full = place_tex(at);
refresh(queue.as_raw());
- assert_eq!(dev_pages() - p0, (all as usize) << 16, "mip 0's pages come with its texels; the other levels' are shared");
+ assert_eq!(super::super::vram::mapped_level_tiles(full.as_raw() as usize), Some(all as u64), "mip 0's pages come with its texels");
assert!(!super::super::vram::has_unmapped_levels(full.as_raw() as usize));
for sub in 0..11u32 {
assert!(read_sub(&full, sub) == want[sub as usize].data, "level {sub} once all of it is there");
@@ -6995,7 +6994,10 @@
// the pages of its address, which hold what the second one's upload put there
let write = capture_gpu_write(small.as_raw() as usize, ALL).unwrap();
publish_gpu_writes(WriterQueueId { raw: queue.as_raw() as usize, generation: 1 }, &[write]);
- assert_eq!(dev_pages() - p0, (all as usize) << 16, "the same pages");
+ assert_eq!(super::super::vram::mapped_level_tiles(small_key), Some(all as u64), "the GPU-written texture has every level mapped");
+ let small_tiles = super::super::vram::mapped_tiles_for(dev_key, small_key).expect("small texture is fully mapped");
+ let full_tiles = super::super::vram::mapped_tiles_for(dev_key, full.as_raw() as usize).expect("full texture is fully mapped");
+ assert_eq!(small_tiles, full_tiles, "the textures share the same physical tiles");
assert!(read_sub(&small, 0) == want[0].data, "a GPU-written texture has pages under all its levels");
// the title takes the memory from under mip 0 again (a streamed level it let go): the
// second texture's next upload finds mip 0 all zeros, and mip 0 gives back its pages;Separately, the description check requires a newly generated clean AI use: Codex (GPT-6.2 Sol) traced the CI and source; Codex (GPT-6.2 Astra) independently checked the idle-page sweep and candidate direction. |
|
Review (head 7c60a35, diff read, not a merge-check:
Fine: no nested locks, the same queue wait as the existing AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
A placed render target or depth buffer that a newer placement supersedes (
placements.rs,XCL_PLACE_RETIRE, on by default) has its tiles unmapped once the queues have passed, andplacements::note_usemaps them again when the title uses it again. A use was only seen in a legacyResourceBarrierand in the copies. A title that moves its textures with the barrier groups of list slot #146 and then binds and clears such a target was never seen: the target stayed without tiles, every write to it was dropped and every read of it returned 0.A use is now also a texture barrier in list #146's groups,
OMSetRenderTargetswith its RTVs or DSV,ClearRenderTargetViewandClearDepthStencilView. All of them record into a list, so the mapping is queued before that list's submit waits for the tile mappings (vram::before_execute). An RTV or DSV the title copies (CopyDescriptorsSimple,CopyDescriptors) names what its source names, as one made at that handle does: otherwise a bind or clear through a copied view looks up what the destination handle named earlier (@andrewDoing's controls below). The handles of both kinds are kept inplacements, not looked up inpresent's table of RTVs, which holds nothing withpresent = "off"(@thehollowedone's reproduction below).Related: #3179 does the same for textures bound through descriptor tables. This PR is the other side, the calls that write a target; neither covers the other's calls. Both add
placements::any_superseded(), so whichever is merged second needs a rebase that keeps one copy; I will do that for this one.What is in it
hle/d3d12x/placements.rs:any_superseded()(one atomic load: the calls below do nothing more while no target is superseded) and the RTV and DSV handles of placed textures (note_view,note_view_use,views_copied: one table of addresses, no references held). Unit testa_view_handle_names_the_placed_texture_it_was_last_made_of(made at a handle, copied to it, copied from a handle that names nothing).hle/d3d12x/list_x.rs:uav_barrier_x(list Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146) notes the textures of its texture barrier groups (barrier_group_textures: read only while a target is superseded, every group of the call and every barrier of a group, groups that are not readable memory are passed over);clear_depth_stencil_xnotes its DSV. Unit testthe_texture_barriers_of_barrier_groups_name_their_textures(a 257th group and a 4,097th barrier among them).hle/d3d12x/real.rs:cl_om_set_render_targetsnotes the RTVs the list now holds and its DSV,cl_clear_rtvits RTV,dev_create_rtvanddev_create_dsv_xfeed the handle table; the two descriptor copy hooks pass RTV and DSV copies to it (target_views_copied, ranges walked bydepth_uav::pieces, which ispub(super)for it). GPU testssuperseded_target_tests::gpu_a_superseded_render_target_the_title_binds_clears_or_moves_is_mapped_again(R32_FLOAT) andgpu_a_superseded_depth_buffer_the_title_binds_or_clears_is_mapped_again(D16): they place a target on title pages, place a smaller one over its last page so that it is superseded and loses its tiles, call each hook on an adopted list (one bind through an RTV copied withCopyDescriptorsSimple, one clear through a DSV copied withCopyDescriptors), and require the target to have tiles again after each call and to read back the value it was then cleared to. The render-target test first dropspresent's entries of its RTVs, which is whatpresent = "off"leaves. They printSKIPPEDwithout tiled resources.Tested
cargo test -p xcl --lib -- superseded_target a_view_handle the_texture_barriers copy_descriptors_remaps --test-threads=1: 6 passed, 0 failed on each; the same tests on the runtime code of 2d632bd (superseded_target the_texture_barriers): 2 passed, 2 failed on each.CARGO_PROFILE_DEV_DEBUG=0), release smoke; DXC 1.9.2609 viaXCL_DXC_DIR.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 --skip a_refused_gpu_upload_segment_becomes_custom --skip mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment --skip failed_restore_stops_before_importing_an_unbacked_windowon 2d632bd: 2594 passed, 1 failed, 49 ignored. The same command onmain765b2c5b: 2590 passed, 1 failed, 49 ignored. The three skippeduma_drivertests ended the lib test process on NVIDIA onnvidia-dev54225f5, whichmainnow contains (reported on [OFFICIAL] Merge queue: which PRs can be merged next, and how to claim a merge check #3041; Tests: the mixed-window remake tests run in a child process #3187).765b2c5bas well:a_preparation_worker_also_builds_a_split_programs_whole_form.SKIPPED: 8 no wave64; 1 const_mask, wave64: no wave64; 1 f32 arithmetic, wave64: no wave64; 1 f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); 1 f16 arithmetic, wave64: no wave64; 1 f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); 1 f16 packed, wave64: no wave64; 1 f32 compares, wave64: no wave64; 1 integer arithmetic, wave64: no wave64; 1 f64, wave64: no wave64; 1 mask_ff0_flbit, wave64: no wave64; 1 f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); 1 f32 conversions, wave64: no wave64; 1 integer carries, wave64: no wave64; 1 f32 rounding, wave64: no wave64; 1 f32 transcendentals, wave64: no wave64; 1 f32 three-source, wave64: no wave64; 1 no heap windows (opt-in: XCL_HEAP_WINDOWS=1); 1 no heap windows.placements::tests::a_superseded_target_used_again_is_mapped_again, release (cargo test --release -p xcl --lib superseded_target -- --test-threads=1) on 2d632bd: 3 passed, 0 failed on the RTX 5070 Ti (3 runs, 0 skipped) and 3 passed, 0 failed on WARP (XCL_ADAPTER=warp, 0 skipped).still without tiles after ["OMSetRenderTargets", "ClearDepthStencilView", "ClearDepthStencilView with a copied DSV"]andstill without tiles after ["OMSetRenderTargets", "OMSetRenderTargets with a copied RTV", "ClearRenderTargetView", "a texture barrier in list #146's groups"].target_views_copiedreturning at once, WARP): 1 passed, 2 failed, withstill without tiles after ["ClearDepthStencilView with a copied DSV"]andstill without tiles after ["OMSetRenderTargets with a copied RTV"].Regression run
150 s runs after the startup shader preparation, same title, same env (
XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=all XCL_DIRECT_SPLIT_INSTRUCTIONS=0 XCL_PSO_JOURNAL=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=120000, DXC 1.9), the same graphics pipeline history at the start.main's run uses a DXIL cache precompiled for it (xcl shaders --precompile --pipelines --used-only --windows 16), the head's a hard-link copy of that folder taken aftermain's run.The two runs below are not of the same scene, so their frame and commit lines do not compare. The harness presses the gamepad at times counted from the process start (the last at 197 s).
main's run prepared shaders for 459 s, so no press reached the title and ended with 1440 textures and 6186 MB of video memory on the first screen; the head's run prepared for 166 s (the driver blobs were on disk by then), got the presses and ended with 57719 textures and 14045 MB of video memory in the loaded world. Amainrun that gets the presses as well is pending; thePR descriptioncheck stays red on the frame and commit comparison until it replaces the first block.main(daae0330, the parent of merge 765b2c5 that has its tree):This PR's head:
The head's run does not show the change being reached: its log has no
a superseded texture is used againline (main's: 0). The run of this PR's earlier head fe9039d onnvidia-dev54225f5 (4 UMA windows, no startup preparation) had 64 such lines (the log prints at most 64), 16-bit depth targets and R32_UINT targets with unordered access; why this run has none was not looked into.Not tested
mainin the same scene, and the change being reached in a title run onmain(see Regression run).CopyDescriptorsand a DSV copied withCopyDescriptorsSimplein this PR's tests: they take the other pairing, and both hooks go through the sametarget_views_copied(@andrewDoing ran both pairings on 2d632bd, the head before this one). Whether the title copies RTVs or DSVs at all was not counted.present = "off"set in a title's config: the GPU test only emptiespresent's table (@thehollowedone's child-process test with the setting was not taken).AI use
🤖 Generated with Claude Code