Repository navigation
Conversation
|
I checked the overlapping-descriptor case called out under Not tested on
There is a potential correctness case beyond repeated uploads. The scanner visits table entries regardless of which slot the shader actually samples. If a draw uses only A with B also present later in the table, B can undo A’s reactivation before submission and remove A from the pending set. This verifies CPU state and descriptor traversal only, with COM and GPU operations stubbed. Pixel output and frame-time cost remain unmeasured. OpenAI Codex assisted with verification. |
|
I followed up on the overlapping-descriptor observation with a native GPU readback on RTX 5070 / NVIDIA 616.92. This uses the direct parent Two 64×64 R8 committed textures had partially overlapping guest ranges. Each run verified A's initial GPU pixels and B's updated GPU pixels, then supplied an ordering directly to
The A-then-B case preserves all 4,096 old A texels, while the A-only and B-then-A controls restore all 4,096. This extends the earlier CPU-state report to the pixel consequence of the ordering. The fixture supplied the resource order itself; it did not execute descriptor scanning or shader sampling, use tiled resources, or run a retail title. It therefore does not establish the frequency or visual impact in gameplay. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed the results and prepared this report. |
|
I tested a separate-draw case on RTX 5070 / NVIDIA 616.92, comparing the same two native draws on parent For the head I supplied only the corresponding resource to
All stale A pixels matched the old value. Thus this synthetic committed-texture case also needs attention across draws in one submission: identifying exactly which resource each shader reads is insufficient if the second reactivation cancels the first before the shared refresh. The fixture did not exercise real guest binding, tiled resources, a retail title, or performance. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report. |
|
Verified PR #2956 ( Environment
Test Results (
|
| Command | Adapter | Result |
|---|---|---|
cargo test --locked -p xcl --lib -- title_textures -- --test-threads=1 |
NVIDIA RTX 4060 Laptop | 30 passed, 0 failed (2.63s, includes a_sampled_shadowed_texture_is_active_again) |
cargo test --locked -p xcl --lib -- hle::d3d12x::bind:: -- --test-threads=1 |
NVIDIA RTX 4060 Laptop | 53 passed, 0 failed (0.48s) |
cargo test --locked -p xcl --lib -- title_textures -- --test-threads=1 |
Intel(R) UHD Graphics | 30 passed, 0 failed (2.14s) |
cargo test --locked -p xcl --lib -- hle::d3d12x::bind:: -- --test-threads=1 |
Intel(R) UHD Graphics | 53 passed, 0 failed (0.51s) |
cargo build --workspace --locked && cargo test --workspace --locked --no-fail-fast -- --test-threads=4 |
NVIDIA RTX 4060 Laptop | 1,817 passed, 9 failed, 48 ignored (30 SKIPPED lines) |
All 9 failures in the workspace run are a subset of the documented pre-existing nvidia-dev eae01502 failures (gpu_compute_thread_limits_leave_the_lanes_past_them_out, texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays, texture_upload::tests::pieces_hold_the_texels_of_their_levels, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, async_compute_pso_registers_real_pso_and_not_standin, split_compute_prefers_the_offline_whole_pipeline ×2, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs ×2; fuzz_validate_and_gpu_0..3 passed here).
Diff Review Notes
crates/xcl/src/hle/d3d12x/title_textures.rs:Table::uncoverpreservesby_va's disjointness invariant, updatespending_resandpending_deltacleanly on both displaced and restored entries, keeps displaced textures mapped for in-flight draws, resetsmax_shadowed_sizewhenshadowedempties, andHAS_SHADOWEDis updated across all four mutation sites (register,retire_overlapping,forget,uncover_drawn).uncover_drawnclones resources underTEXTURESand drops the mutex before callingvram::remap_if_unmapped/vram::map_levels, avoiding anyTEXTURES↔vram::PAGESlock-order inversion.
crates/xcl/src/hle/d3d12x/bind.rs:uncover_bound_tablesshort-circuits viahas_shadowed(), safely falls back tocopy_readableoutside committed window 0, filters to texture T# descriptors (slot[15] >> 4 >= 8 && index != 0), and resolves byte-copied descriptors throughconsole_heap::named_by_index.
Not Tested
- Live retail title runs / visual verification of shadowed Bink planes (no retail game files used).
- AMD or native wave64 hardware.
- The 48
#[ignore]tests in the workspace suite.
(AI disclosure: diff review, test execution commands, and summary formatting were assisted by Antigravity / Gemini 4; all tests were executed locally on the hardware listed above.)
Table::insert shadows the active textures a newer one overlaps, and a placed texture over a different range is unmapped as well. Shadowed textures are never uploaded again, but a title can keep sampling them: GTA 6 samples the Bink planes of its credit-card scene after a newer placement lands over part of them, so the GPU read zeros and the cards rendered green with blocky streaks (over 131k draws sampled shadowed textures in one 355 s run). When a draw binds descriptor tables, the textures they name that are shadowed become active again: the active ones overlapping them are shadowed without being unmapped, the texture is marked pending (unless the GPU wrote it), remapped if it was unmapped, and its known content is forgotten so the next submit uploads it. When two overlapping textures are made active in turn before a submit (one draw sampling both, or two draws of one submission), the second shadows the first again. The first stays pending and the next submit uploads it all the same, since a draw already recorded samples it. Assisted-by: Codex CLI (gpt-6.2-sol) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8fb4127 to
d527335
Compare
|
Thanks @ettehn and @andrewDoing, the A-then-B case was a real bug, and your readbacks pinned it down. Thanks @retrope13 for the test run. Fixed in d527335, squashed into the one commit. When a texture that is still pending is shadowed again by a later Tests:
Still open, and listed under Not tested: a texture that is active (not pending) and is displaced later in the same submission misses that submission's dirty-page updates, because those are tracked only for active entries. It catches up at the next refresh that has work. AI use: Claude Code (Claude Opus 5.5) wrote this fix, its tests and this reply. 🤖 Generated with Claude Code |
|
I reran the same two-draw native RTX 5070 fixture from my earlier report on updated head
Both focused runs passed without skips. As before, the fixture supplies each draw's resource directly to AI use: OpenAI Codex with GPT-6.2 Astra ran the retest; Codex reviewed and prepared this report. |
|
Re-verified Results (
|
|
I reproduced @retrope13's The fixture uses partially overlapping committed R8 textures. It first uploads A's old value, updates the guest bytes, and gives B a distinct value through a real GPU copy followed by
Each case ran in a fresh process. The normal case fails the expected-A assertion; the control passes it. This supports the early-return hypothesis and shows its pixel consequence in this fixture while preserving the GPU-written B value. The fixture supplies reactivation and the write notification directly; guest binding, tiled textures, retail incidence, and performance were not tested. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report. |
|
Follow-up to the native GPU reproduction on this head: I tested a narrow guard for the On Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Rust 1.99.1 MSVC, DXC 1.8.2502.11, with
Local candidate diff (not committed)diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index 5c139fea..bc4d6806 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -269,2 +269,3 @@ impl Table {
if let Some(old) = self.by_res.remove(&ores) {
+ self.displaced.remove(&ores);
self.unlink_src(ores, old.src, old.tex.size() as usize);
@@ -282,2 +283,3 @@ impl Table {
if let Some(old) = self.shadowed.remove(&sres) {
+ self.displaced.remove(&sres);
if old.placed && !old.unmapped {
@@ -300,2 +302,3 @@ impl Table {
fn insert(&mut self, res: usize, mut entry: Entry) -> (isize, Vec<usize>) {
+ self.displaced.remove(&res);
let va = entry.va;
@@ -365,2 +368,3 @@ impl Table {
let mut e = self.shadowed.remove(&res)?;
+ self.displaced.remove(&res);
self.shadowed_by_va.remove(&(e.va, res));
@@ -410,2 +414,3 @@ impl Table {
fn remove(&mut self, res: usize) -> (bool, isize, Vec<usize>) {
+ self.displaced.remove(&res);
if let Some(old) = self.shadowed.remove(&res) {
@@ -436,2 +441,3 @@ impl Table {
if let Some(mut e) = self.shadowed.remove(&sres) {
+ self.displaced.remove(&sres);
// (the one that lay over it may have been uploaded over the same video memory)
@@ -498,2 +504,3 @@ static TEXTURES_LEN: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicU
static HAS_SHADOWED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
+static HAS_DISPLACED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
/// cached `watch_ranges` keyed by `watch_key`
@@ -589,2 +596,3 @@ pub(super) unsafe fn register(device: *mut c_void, res: *mut c_void, va: usize,
HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+ HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
clone_resources(&unmap_ptrs)
@@ -895,2 +903,3 @@ pub(super) unsafe fn retire_overlapping(va: usize, len: usize) {
HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+ HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
(retired, clone_resources(&unmap_ptrs))
@@ -914,2 +923,3 @@ pub fn forget(res: usize) {
HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+ HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
(removed, unsafe { clone_resources(&remap_ptrs) })
@@ -958,2 +968,3 @@ pub(super) fn uncover_drawn(res: &[usize]) {
HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+ HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
(restored, unsafe { clone_resources(&remap) })
@@ -1855,3 +1866,3 @@ unsafe fn refresh_parts(queue: *mut c_void, look: bool) {
recheck_streamed_unwatched(&ranges, recheck_frame);
- if dirty_len == 0 && PENDING.load(Ordering::Relaxed) == 0 && AGAIN.lock().unwrap().is_empty() {
+ if dirty_len == 0 && PENDING.load(Ordering::Relaxed) == 0 && !HAS_DISPLACED.load(Ordering::Acquire) && AGAIN.lock().unwrap().is_empty() {
return;
@@ -1867,2 +1878,3 @@ unsafe fn refresh_parts(queue: *mut c_void, look: bool) {
let displaced = std::mem::take(&mut t.displaced);
+ HAS_DISPLACED.store(false, Ordering::Release);
names.extend(displaced.iter().copied());
@@ -3913,2 +3925,3 @@ pub(super) mod tests {
assert!(tbl.by_res.contains_key(&1));
+ assert!(!tbl.displaced.contains(&1), "reactivated A is owned by the active pending queue");
@@ -3922,2 +3935,13 @@ pub(super) mod tests {
assert!(tbl.by_res.contains_key(&10) && !tbl.by_res[&11].pending && tbl.shadowed.contains_key(&12));
+
+ let mut released = Table::new();
+ let mut gpu_b = entry(0x30_0000, &tex_64k, false, false);
+ gpu_b.gpu_written = true;
+ released.insert(20, entry(0x30_4000, &tex_16k, true, false));
+ released.insert(21, gpu_b);
+ assert!(released.uncover(20).is_some());
+ assert!(released.uncover(21).is_some());
+ assert!(released.displaced.contains(&20));
+ assert!(released.remove(20).0);
+ assert!(!released.displaced.contains(&20), "released resources cannot be uploaded after address reuse");
}
@@ -3977,2 +4001,15 @@ pub(super) mod tests {
assert_eq!(read_r8(dev, &queue, &b), vec![0x33; 64 * 64]);
+ // Consume the next guest write while A is shadowed, then model a GPU write to B.
+ // B must not become pending when it displaces A before the following refresh.
+ std::ptr::write_bytes(base as *mut u8, 0x44, 2 * size);
+ refresh(queue.as_raw());
+ note_gpu_write(0, kb);
+ uncover_drawn(&[ka, kb]);
+ assert_eq!(PENDING.load(Ordering::Relaxed), 0);
+ assert!(TEXTURES.lock().unwrap().displaced.contains(&ka));
+ assert!(HAS_DISPLACED.load(Ordering::Acquire));
+ refresh(queue.as_raw());
+ assert!(!HAS_DISPLACED.load(Ordering::Acquire));
+ let a_pixels = read_r8(dev, &queue, &a);
+ assert_eq!(a_pixels.iter().filter(|&&v| v == 0x44).count(), 64 * 64, "displaced A goes up with no dirty pages or active pending texture");
drop((_rb, _ra));This closes the measured early-return path for committed textures. The PR's separate active-but-not-pending dirty-page limitation still needs a focused regression and a design that retains those bytes through the refresh; this test does not validate placed/tiled overlaps, guest binding, a retail title, the full workspace suite, or paired smoke. AI use: Codex (GPT-6.2 Sol) wrote and ran the local GPU regression and candidate; Codex (GPT-6.2 Astra) independently traced the displaced-set lifecycle and refresh ordering. |
|
On #2956 head The added table regression models A as already uploaded ( Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC. Adding A only to Failing table regressiondiff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index 5c139fea..8b22c9b3 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -3921,4 +3921,17 @@ pub(super) mod tests {
assert_eq!(tbl.uncover(11), Some((0, false)));
assert!(tbl.by_res.contains_key(&10) && !tbl.by_res[&11].pending && tbl.shadowed.contains_key(&12));
+
+ // An already uploaded A is displaced by B before its next dirty-page scan.
+ let mut dirty_tbl = Table::new();
+ let mut b = entry(0x30_0000, &tex_64k, false, true);
+ b.src = 0x5000_0000;
+ let mut a = entry(0x30_4000, &tex_16k, false, true);
+ a.src = 0x4000_0000;
+ assert_eq!(dirty_tbl.insert(20, b).0, 0);
+ assert_eq!(dirty_tbl.insert(21, a).0, 0);
+ assert!(dirty_tbl.coarse.contains_key(&(0x4000_0000 >> SRC_COARSE_SHIFT)));
+ assert_eq!(dirty_tbl.uncover(20), Some((1, true)));
+ assert!(dirty_tbl.coarse.contains_key(&(0x4000_0000 >> SRC_COARSE_SHIFT)), "A's source must stay watched until refresh");
+ assert!(dirty_tbl.displaced.contains(&21), "refresh must consider dirty A");
}AI use: Codex (GPT-6.2 Sol) traced the relevant state transitions, wrote and ran the table regression, checked the lifecycle conditions, and drafted this report. |
|
Tested PR #2956 ( Environment
Paired
|
| Run | Exit | Crashes / Removals | Frames (PresentX) |
Heavy world start | Peak Commit | Peak Local VRAM | Peak Non-Local | Target Pages |
|---|---|---|---|---|---|---|---|---|
Base eae01502 |
0x0 |
0 / 0 |
1764 |
109.31 s |
25679 MB |
8285 MB |
4288 MB |
3647 MB |
#2956 (d5273351) |
0x0 |
0 / 0 |
1911 |
122.32 s |
25488 MB |
8414 MB |
4353 MB |
3632 MB |
In #2956, once inside the open world (120.85 s–121.94 s), the title triggered the new reactivation path and logged:
D3D12.X: 65 shadowed textures sampled by draws so far were made active again (0 needed remapping in this batch)(with1needing remapping per batch in earlier batches at120.85 s–121.81 s).
Unit tests (title_textures)
Note on test stability when running cargo test --locked -p xcl --lib -- title_textures on d5273351 (31 tests total; placed_title_textures_share_vram_and_preserve_pixels is newly added on d5273351 and not present on eae01502):
- First default parallel batch run:
30 passed; 1 failed(hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels ... FAILED). - Re-run with
-- --test-threads=1:31 passed; 0 failed(2.20 s). - Follow-up standalone default parallel run:
31 passed; 0 failed(2.26 s).
So placed_title_textures_share_vram_and_preserve_pixels passed reliably sequentially and on retry, with one observed intermittent failure under parallel execution.
When a newer texture is placed over part of an older one,
title_textures::Table::insertshadows the older one (and unmaps it if the new placement covers a different range). Shadowed textures are never uploaded again. A title can still sample them, though. GTA 6 does this with the Bink Y/Cr/Cb planes of its credit-card scene: a newer placement lands over part of the planes, the GPU then reads zeros from them, and the cards render green with blocky streaks. In one 355 s run, more than 131k draws sampled shadowed textures.This change makes a shadowed texture active again when a draw binds it. The active textures that overlap it are shadowed but not unmapped. The texture is remapped if it was unmapped, marked pending unless the GPU wrote it, and its known content is forgotten, so the next submit uploads it again. When two overlapping textures are made active in turn before a submit (one draw sampling both, or two draws in one submission), the first is shadowed again, but it stays pending and the next submit still uploads it, since a draw already recorded samples it. ettehn and andrewDoing found this case in review.
Part of #505. Based on nvidia-dev eae0150. It merges into the current tip a5e2d85 without conflicts, and none of the 15 newer commits touches shadowing.
What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs:Table::uncover,uncover_drawnandhas_shadowed(anAtomicBool, so draws skip the scan when nothing is shadowed);Table::displaced: pending textures thatuncovershadowed again, which the nextrefreshstill uploads;a_sampled_shadowed_texture_is_active_again, and the GPU testgpu_both_overlapping_textures_a_draw_samples_go_up(A then B made active, one refresh, both read back; on 8fb4127, withoutdisplaced, A reads back its old bytes).crates/xcl/src/hle/d3d12x/bind.rs:uncover_bound_tablesreads the first 64 slots of each bound descriptor table that hold a T#. It resolves them to title textures throughconsole_heap::named_by_indexand passes them touncover_drawn. It is called frombind_abiand, for graphics only, fromprepare_two_pass_stage.Tested
cargo test --workspace --release --no-fail-fast -- --test-threads=4on d527335: 1815 passed, 12 failed, 48 ignored.split_compute_prefers_the_offline_whole_pipelineandtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobseach count twice, because their harness runs them again:fuzz_validate_and_gpu_0..3;gpu_compute_thread_limits_leave_the_lanes_past_them_out;d3d12_mesh_streamconsole_ms_in_as_slot_and_ms_with_as_are_refused_cleanly;gpu_compute_e2efailures (async_compute_pso_registers_real_pso_and_not_standin, andsplit_compute_prefers_the_offline_whole_pipelinetwice);gpu_two_pass_cache_e2e, twice.sparse::tests::a_tile_decommitted_and_committed_again_keeps_its_video_memory(assert!(s.drain_quarantined())), is in a file this PR does not touch. It passed 3 of 3 runs on its own and incargo test --release -p xcl --lib hle::d3d12x::sparse(62 passed), so I take it for a timing flake under the parallel suite.SKIPPEDlines, for these reasons: no wave64 (21), no heap windows, no debug layer / d3d12SDKLayers.dll, and refused f16 instructions.cargo test --release -p xcl --lib title_textures: 31 passed.displaced), with the same environment:Regression run
The main block is from b49be18, the last main commit before the shader-preparation screen (#2555). On the current main tip, shader preparation did not finish within 2 h on this machine. All blocks were made with
XCL_PRESS_A_AT=70andXCL_DXC_DIRset, one run at a time, with warm shader caches. I ran two rounds and include both, unedited. The PR blocks were rerun on d527335; the main and base blocks are from the same rounds as before.This does not meet the limits against main.
Against its own base, the PR has 97 % and 95 % of the frames, and 112 % and 102 % of the peak commit.
Round 1, main b49be18:
Round 1, nvidia-dev base eae0150 (without this change):
Round 1, this PR, d527335:
Round 2, main b49be18:
Round 2, nvidia-dev base eae0150:
Round 2, this PR, d527335:
Not tested
sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_viewwith device removal (0x887a0005). That test is insparse.rs, which this PR does not touch; it passes here.AI use
displacedfix for the case found in review and its GPU test, and ran the test suite and the smoke runs on d527335.🤖 Generated with Claude Code