Repository navigation
Conversation
|
At The sampled texture was 256×256 RGBA8 (four 64 KiB tiles). In each fresh process I GPU-cleared a live RGBA8 render target, waited for the queue, then placed the sampled texture with level pages enabled. I compared the pool/tile identities and XCL's per-device allocated texture-page counter before and after the sampled placement.
For these aligned resources, a live first page triggered eager placement of the entire sampled texture. A live second page alone did not. The 192 KiB is the increase in XCL's allocated texture-page accounting for the three previously absent pages; DXGI residency and heap capacity were not measured. Four focused tests passed, zero skipped. Retail title behavior was outside this test. AI use: OpenAI Codex (GPT-6) prepared the test-only fixture, ran the four native controls and wrote the report. |
|
Ran the aliased lazy-level-page 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. |
ae348ff to
74ef846
Compare
|
Source review of head
Update — RTX 3080 Ti reproduction of point 1. I extended the existing GPU fixture with an unaliased sampled control, then placed a one-tile sampled texture at another VA and a four-tile sampled texture at the same VA. The control remained lazy. On the unchanged head Test-only regression diff on 74ef846diff --git a/crates/xcl/src/hle/d3d12x/vram.rs b/crates/xcl/src/hle/d3d12x/vram.rs
index b65441ec..5f578d29 100644
--- a/crates/xcl/src/hle/d3d12x/vram.rs
+++ b/crates/xcl/src/hle/d3d12x/vram.rs
@@ -5178,6 +5178,37 @@ mod tests {
rb.Unmap(0, None);
assert_eq!(px, [64, 128, 192, 255], "sampled view did not read GPU-written target texels");
+ // A sampled texture without a preceding page is eligible for lazy levels.
+ let larger = D3D12_RESOURCE_DESC { Flags: D3D12_RESOURCE_FLAG_NONE, ..rt_desc };
+ let mut raw_control: *mut c_void = std::ptr::null_mut();
+ let hr = place_pages(dev.as_raw(), va + 0x2000_0000, &larger, D3D12_RESOURCE_STATE_COPY_SOURCE.0 as u32, std::ptr::null(), Some(bytes), iid, &mut raw_control);
+ assert!(hr.is_some_and(|h| h >= 0) && !raw_control.is_null(), "control sampled placement failed: {hr:?}");
+ let control = ID3D12Resource::from_raw(raw_control);
+ assert!(has_lazy_levels(control.as_raw() as usize), "an unaliased sampled texture should have lazy levels");
+ forget(control.as_raw() as usize);
+ drop(control);
+
+ // A sampled upload at a different VA is not evidence of a GPU-owned producer.
+ let sampled_va = va + 0x1000_0000;
+ LEVEL_PAGES_FOR_TEST.store(false, Ordering::Relaxed);
+ let small = D3D12_RESOURCE_DESC { Width: 128, Height: 128, Flags: D3D12_RESOURCE_FLAG_NONE, ..rt_desc };
+ let mut raw_small: *mut c_void = std::ptr::null_mut();
+ let hr = place_pages(dev.as_raw(), sampled_va, &small, D3D12_RESOURCE_STATE_COPY_SOURCE.0 as u32, std::ptr::null(), Some(128 * 128 * 4), iid, &mut raw_small);
+ assert!(hr.is_some_and(|h| h >= 0) && !raw_small.is_null(), "first sampled placement failed: {hr:?}");
+ let small = ID3D12Resource::from_raw(raw_small);
+ assert!(has_live_page(dev.as_raw() as usize, sampled_va));
+ let bytes_before = page_bytes().0;
+ LEVEL_PAGES_FOR_TEST.store(true, Ordering::Relaxed);
+ let mut raw_larger: *mut c_void = std::ptr::null_mut();
+ let hr = place_pages(dev.as_raw(), sampled_va, &larger, D3D12_RESOURCE_STATE_COPY_SOURCE.0 as u32, std::ptr::null(), Some(bytes), iid, &mut raw_larger);
+ assert!(hr.is_some_and(|h| h >= 0) && !raw_larger.is_null(), "second sampled placement failed: {hr:?}");
+ let larger = ID3D12Resource::from_raw(raw_larger);
+ assert!(has_lazy_levels(larger.as_raw() as usize), "sampled-only overlap should not disable lazy level pages ({} additional page bytes)", page_bytes().0 - bytes_before);
+ forget(larger.as_raw() as usize);
+ forget(small.as_raw() as usize);
+ drop(larger);
+ drop(small);
+
forget(srv.as_raw() as usize);
forget(rt.as_raw() as usize);
drop(srv);For a production fix, count GPU-owned references on each physical |
|
merge-check claim |
|
merge-check |
|
Re-ran the aliased lazy-level-page 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 prototyped the producer-ownership approach from the review above on main The candidate counts mapped GPU owners by exact Windows Release CPU tests on the local candidate passed 6/6, including later and unaligned overlap, exact extra-tile keys, the last of two producer releases, and the existing level-ownership controls. A positive overlap still maps the entire texture, including non-shared tiles. Native GPU follow-up. Windows Release on an RTX 5070 Ti Laptop (621.24). The combined synthetic run passed 7/7 with zero skips. Two 128×128 RGBA8 reserved textures shared one physical page. With the producer transitioned to OpenAI Codex (GPT-6.2 Sol) assisted with implementation and Windows verification. |
…ve GPU page Port of amd-dev dece6dd (part 1) to nvidia-dev: under XCL_TEXTURE_LEVEL_PAGES=1, a sampled Texture2D placed at the same 64 KiB page as a live GPU-owned texture (render target, depth buffer, or UAV) has all-zero CPU memory at that VA, so map_levels_with_texels never maps its tiles and shaders read zeros. Disable lazy level pages in vram::place_pages when the 64 KiB-aligned VA already has a live page in Pages::pages, mapping eagerly onto the existing shared pages at zero extra VRAM cost. Includes CPU unit tests and a D3D12 GPU test verifying that a sampled Texture2D placed at the VA of a cleared render target under XCL_TEXTURE_LEVEL_PAGES=1 maps eagerly and reads back the GPU-written texels. Co-Authored-By: Antigravity (Gemini 4 Neon) <noreply@google.com>
74ef846 to
c8faf77
Compare
|
Review (head c8faf77, diff read, not a merge-check: the
Fine: the diagnosis matches main (lazy levels only get pages from non-zero CPU texels, AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Test report (not a merge-check: AI-written and posted by Foniass without a human check of each point. |
Port of
amd-devdece6dd9(part 1, by @raylitebull) tonvidia-dev.Under
XCL_TEXTURE_LEVEL_PAGES=1,vram::place_pagessetslazy = truefor every sampled 2D single-slice texture (D3D12_RESOURCE_FLAG_NONE), deferring tile mapping untilmap_levels_with_texelssees non-zero CPU texels at the placement VA. When a sampled texture is placed at the same 64 KiB-aligned VA as a live GPU-owned texture (render target, depth buffer, or UAV), CPU memory at that VA is all zeros, so its tiles are never mapped and shaders read zeros. Mapping eagerly whenPages::pagesalready holds a live page atcanonical_va(va)reuses the existing shared pages at zero extra VRAM cost.This is separate from #3116 (which issues a NULL-range
UpdateTileMappingsand fence wait on lazy placement to avoid page faults) and #3094 (XCL_ALIAS_COPY=1, which copies across different formats).What is in it
crates/xcl/src/hle/d3d12x/vram.rs: addhas_live_pageandshould_use_lazy_levels, and disable lazy level pages inplace_pageswhenva % PAGE == 0andPages::pagesalready containscanonical_va(va).vram::tests::should_use_lazy_levels_skips_gpu_aliased_sampled_textures.vram::tests::gpu_sampled_texture_aliasing_live_gpu_target_maps_eagerly_with_level_pages: places anR8G8B8A8_UNORMrender target at a 64 KiB-aligned VA, clears it on the GPU, places a sampledR8G8B8A8_UNORMtexture at the same VA withLEVEL_PAGES_FOR_TEST = true, and asserts!has_lazy_levels(srv)and that reading back the sampled view returns the cleared texels[64, 128, 192, 255].Tested
cargo test --release -p xcl --lib -- should_use_lazy_levels gpu_sampled_texture_aliasing --nocapture: 2 passed, 0 failed.Not tested
Regression run
150 s each, same title (
ea3b5e4d), same GPU (NVIDIA GeForce RTX 5070 Ti), release build, warm DXIL cache (XCL_DIRECT_DXIL=all,XCL_HEAP_WINDOWS=1,XCL_DRED=1).main(b49be183):nvidia-devbase (54225f58):This PR's head (
ae348ff5):AI use
Antigravity (Gemini 4 Neon) ported the change, wrote the GPU test, ran the tests and smoke run, and drafted this description.