Repository navigation
Conversation
luckyteagirl
left a comment
There was a problem hiding this comment.
On 94c5930, a recycled tile can still be mapped with its previous texture's bytes if the zeroer cannot start. For example, if the first batch contains a dirty recycled tile and creating the zeroer's upload buffer fails, Zeroer::new returns None. zero_tiles returns without submitting any clear, but bind_range continues to map the tile and reports success. The reset and command-list-close error branches also proceed without clearing the affected chunk. The caller's non-tiled fallback only runs when the bind reports failure.
Could zero_tiles report failure so bind_range can stop before publishing the new mapping and return all selected tiles with their original dirty bits? take_batch already clears dirty bits on success, so the existing reservation rollback alone would need to restore those bits in this case. A failure-injection fixture could exhaust fresh tiles, recycle one dirty tile, fail zeroer initialization, then assert the bind does not publish a mapping and that a subsequent reservation still flags the tile for clearing.
This is an exact-head source review. I did not inject a D3D12 failure or run a GPU test.
TilePool hands recycled cooling tiles back to Pages::bind_range with stale bytes from their prior texture, causing tile-shaped garbage blocks on new render targets, depth buffers, and UAVs (xcl-dev#505). Track per-heap recycled dirty bits in TilePool and lazily zero dirty tiles on the Pages mapping queue via a scratch reserved buffer and pre-zeroed upload buffer before mapping them to the new resource. Fresh heaps from CreateHeap and live/idle same-address aliases are untouched. Tested with recycled_pages_tiles_are_zeroed_before_reuse (failed with [ff, 00, ff, ff] leak pre-fix; passed post-fix) and tile_pool_marks_recycled_tiles_dirty_and_preserves_dirty_on_rollback. Assisted-by: Google Antigravity CLI (Gemini 4 Hydrogen (High))
|
amd-win test report for Environment
Tested (all with the PR checked out detached at
Result
Not tested
AI use: Claude Code (Claude Sonnet 5.5) ran the verification and wrote this report; Claude Code (Claude Opus 5.5) coordinated. Results are from the runs above. |
|
Independent AMD RDNA4 (native wave64) verification of exact PR head Tested
(Compare against Not tested
AI use
|
|
I ran the recycled-tile fixture on Windows at Tested Windows 11 Home build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver cargo test --locked -p xcl --lib -j 1 hle::d3d12x::vram::tests::recycled_pages_tiles_are_zeroed_before_reuse -- --exact --test-threads=1 --nocapture
Both runs used Not tested Zeroer initialization, reset, or close failures were not injected. I did not run the full workspace suite or a title. AI use OpenAI Codex (GPT-6.2 Sol) ran the tests, prepared and restored the adapter overlay, and drafted this report. |
94c5930 to
e540403
Compare
|
Thanks for the thorough review @luckyteagirl. Pushed squashed commit
Tested (
Not tested
AI use
|
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2759 at Setup
Targeted RTX 4060 release unit tests (
|
|
Ran the VRAM tile-recycling tests at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build. All three new tests pass here, including the GPU test What this adds: the author tested an RTX 5080 and an RTX 2080 SUPER with the same driver. This is a third NVIDIA host (Blackwell, 16 GB) and the thread has no report from another machine. Not tested: the title's tile-mosaic visual A/B, injected zeroer failures, multi-chunk/multi-copy stress, the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, native wave64, Wine, release profile, title data. AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
|
RX 9070 / Wine verification of recycled-tile zeroing, including multi-chunk/slot-reuse coverage and a combined-suite limitation. Tested
With the head's unchanged 256-tile chunk size and eight slots, the 4096-tile case exercises 16 chunks and slot reuse. This coverage follows from the observed tile count and the unchanged batching code; no production instrumentation was added. The original Combined-module results and controls Filter
The common failure is The ignored test is Not tested Injected zeroer initialization/reset/close failures, other formats, native Windows, full workspace suite, retail visual behavior, smoke workloads, performance or FPS. The combined module is not a clean pass on this setup. AI use OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, adapted the local fixture, ran and verified the paired tests and controls, and drafted this report. Publication authorized by the account owner. |
|
Under Wine + vkd3d-proton on an RTX 4070, this pull request's Setup:
Not tested: Windows; the new tests without this pull request; an injected AI use: Claude Code (Claude Opus 5.5) ran the title and the tests and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
|
Reviewed
Whichever of the two merges second needs Checked with AI use: Antigravity (Claude Sonnet 5.5) applied both patches and compiled the combined tree; |
|
Suite on RTX 5070 Ti (Windows 11) at Tested
Not tested
AI use
|
|
Independent native D3D12 measurement on #2759 head Windows 11 build 26300; RTX 3080 Ti (621.35); Ryzen 7 9800X3D; rustc 1.99.1 MSVC; DXC 1.8.2502.11. The production path can hold Exact test-only instrumentation diff (restored after testing)diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs
index 27fe8e6b..a8e59259 100644
--- a/crates/xcl/src/hle/d3d12x/vram.rs
+++ b/crates/xcl/src/hle/d3d12x/vram.rs
@@ -879,6 +879,8 @@ impl Pages {
if tiles.is_empty() {
return true;
}
+ #[cfg(test)]
+ let (test_start, mut test_waits, mut test_wait_time) = (std::time::Instant::now(), 0usize, std::time::Duration::ZERO);
if self.zeroer.is_none() {
self.zeroer = Zeroer::new(dev);
}
@@ -892,7 +894,14 @@ impl Pages {
(slot.alloc.clone(), slot.list.clone(), slot.fence_val, z.scratch_buf.clone(), z.zero_buf.clone())
};
if fence_val > 0 && self.fence.GetCompletedValue() < fence_val {
+ #[cfg(test)]
+ let wait_start = std::time::Instant::now();
let _ = self.fence.SetEventOnCompletion(fence_val, windows::Win32::Foundation::HANDLE::default());
+ #[cfg(test)]
+ {
+ test_waits += 1;
+ test_wait_time += wait_start.elapsed();
+ }
}
if alloc.Reset().is_err() || list.Reset(&alloc, None).is_err() {
return false;
@@ -918,6 +927,11 @@ impl Pages {
z.slots[z.next_slot].fence_val = self.value;
z.next_slot = (z.next_slot + 1) % z.slots.len();
}
+ #[cfg(test)]
+ if tiles.len() > ZERO_SLOTS * ZERO_SCRATCH_TILES {
+ println!("zero_tiles: tiles={} chunks={} incomplete_slot_waits={} wait={:?} total={:?}",
+ tiles.len(), tiles.len().div_ceil(ZERO_SCRATCH_TILES), test_waits, test_wait_time, test_start.elapsed());
+ }
true
}
@@ -2333,7 +2347,7 @@ mod tests {
};
let sample = DXGI_SAMPLE_DESC { Count: 1, Quality: 0 };
let tex_desc = D3D12_RESOURCE_DESC {
- Dimension: D3D12_RESOURCE_DIMENSION_TEXTURE2D, Width: 256, Height: 256, DepthOrArraySize: 1, MipLevels: 1,
+ Dimension: D3D12_RESOURCE_DIMENSION_TEXTURE2D, Width: 8192, Height: 8192, DepthOrArraySize: 1, MipLevels: 1,
Format: DXGI_FORMAT_R8G8B8A8_UNORM, SampleDesc: sample, Layout: D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE,
Flags: D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, ..Default::default()
};
@@ -2348,7 +2362,9 @@ mod tests {
let tex_a = make_tex();
let mut total = 0u32;
dev.GetResourceTiling(&tex_a, Some(&mut total), None, None, None, 0, std::ptr::null_mut());
- assert!(total >= 4);
+ if total <= (ZERO_SLOTS * ZERO_SCRATCH_TILES) as u32 || total > 4096 {
+ return crate::gpu::recomp::runner::skip_test("4096-tile bound unavailable");
+ }
let (used_a, extra_a) = pages.bind(&dev, &tex_a, 0x10_0000, None, total).unwrap();
assert!(pages.zeroer.is_none(), "fresh pool heap tiles must not spin up the zeroer");
@@ -2431,8 +2447,8 @@ mod tests {
let pixels_b = read_tex(&pages, &tex_b, &mut fval);
let pitch = layout.Footprint.RowPitch as usize;
- for y in 0..256usize {
- let row = &pixels_b[y * pitch..y * pitch + 256 * 4];
+ for y in 0..8192usize {
+ let row = &pixels_b[y * pitch..y * pitch + 8192 * 4];
assert!(row.iter().all(|&b| b == 0), "recycled tile row {y} leaked non-zero data: {:02x?}", &row[..16]);
}
@@ -2442,7 +2458,7 @@ mod tests {
let tex_c = make_tex();
let (used_c, extra_c) = pages.bind(&dev, &tex_c, 0x20_0000, None, total).unwrap();
let pixels_c = read_tex(&pages, &tex_c, &mut fval);
- for y in [0usize, 127, 255] {
+ for y in [0usize, 4095, 8191] {
assert_eq!(&pixels_c[y * pitch..y * pitch + 4], [0, 255, 255, 255], "same-VA idle reuse at row {y} lost contents");
}
pages.release_tiles(used_c, extra_c, Instant::now(), false);AI use: Codex (GPT-6.2 Sol) reviewed the queue and fence path, ran the six synthetic GPU checks, and drafted this report. |
|
By reading only, not run, at #2436
amd-dev already hit this mechanism, with its own zeroing (d625b20, Ask: merge #2703 with or before #2436 + #2759. AI use: Claude Code (Claude Opus 5.5) found this; Claude Fable 5.2 rechecked it; checked by a person before posting. |
|
Thanks for the measurements and merge-interaction checks:
AI use
|
TilePoolhands cooled recycled tiles back toPages::bind_rangewith stale GPU bytes from their previous texture, which can surface as tile-shaped garbage blocks on newly bound render targets, depth buffers, and UAVs (part of#505, recycled-tile finding). This change tracks recycled dirty bits per backing heap inTilePooland lazily zeroes dirty recycled tiles onPages::queuebefore mapping them to the new resource. If zeroer initialization, reset, or command-list close fails,Pages::bind_rangereturns the reserved tiles toTilePoolwith their dirty bits restored and returnsNoneinstead of publishing an unzeroed mapping. Fresh heaps fromCreateHeapand same-address live orIDLEaliases incur no extra GPU work.What is in it
D3D12.X: zero recycled vram::Pages tiles before reuse(e5404036):crates/xcl/src/hle/d3d12x/vram.rs(TilePool::dirty_tilesper-heap bitset set indrain_cooling, restored on rollback inreturn_tiles, cleared onadd_heap_at/reclaim_empty_heapsand after successfultake_batch; lazyPages::Zeroerreturningboolsobind_rangerolls back and returnsNoneonZeroer::new,Reset, orClosefailure; unit teststile_pool_marks_recycled_tiles_dirty_and_preserves_dirty_on_rollbackandtile_pool_return_tiles_restores_dirty_bits_after_take_batch; GPU testrecycled_pages_tiles_are_zeroed_before_reuseverifying recycled-tile zeroing and same-VAIDLEalias preservation)Tested
Commit
e54040363979e2c629e45e323bd0f84b692770e4(based onmainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7), clean checkouts on each PC, debug builds for workspace tests and release builds for retail smoke runs.recycled_pages_tiles_are_zeroed_before_reusefailed without the fix (recycled tile row 0 leaked non-zero data: [ff, 00, ff, ff, ...]) and passes with the fix.32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200.9974,rustc 1.97.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA).cargo build --workspace: exit 0.cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1438 passed, 0 failed, 47 ignored.SKIPPED: 26 (wave64-only GPU tests,#1426wave32 f16/cvt refusals,heap_window_out_of_memory_falls_back_to_the_switch_form,pso_measurement_compiles_an_exact_synthetic_record0x887A002D).cargo test -p xcl --lib vram:: -- --test-threads=1 --nocapture: 22 passed, 0 failed, 1 ignored (churn_update_tile_mappings_timing), 0 SKIPPED (recycled_pages_tiles_are_zeroed_before_reuseandtile_pool_return_tiles_restores_dirty_bits_after_take_batchboth passed on the RTX 5080).32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200.8653,rustc 1.99.1(stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA).cargo build --workspace: exit 0.cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1438 passed, 0 failed, 47 ignored.SKIPPED: 29 (same 26 as PC 1 plus 3 requiringd3d12SDKLayers.dll).cargo test -p xcl --lib vram:: -- --test-threads=1 --nocapture: 22 passed, 0 failed, 1 ignored, 0 SKIPPED.Regression run
main(b49be183, RTX 5080, release):PR (
e5404036, RTX 5080, release):Not tested
#505tile-mosaic scene (the 60 s regression run above stays in the loading phase and verifies no performance/memory/stability regression onmain).Zeroer::new,Reset, orClosefailure on a live GPU (covered by source audit andtile_pool_return_tiles_restores_dirty_bits_after_take_batchonTilePool).>256tiles) and multi-copy (>16tiles) GPU stress paths.scripts/smoke.ps1on the RTX 2080 SUPER.AI use
Ran via Samaritan:
94c59303and theZeroer/reset/close error-rollback fix and unit test ine5404036, independently reviewede5404036, ran the pre-fix/post-fix repro, dual-PC workspace andvram::suites, and the fresh RTX 5080e5404036smoke run.94c59303(verdict PASS, 0 P0/P1 blockers) and re-ranvram::GPU tests on the RTX 5080.scripts/smoke.ps1baseline, ranscripts/pr_check.py --local, updated this PR description, and pushede5404036.