Repository navigation
Conversation
|
Diff review (head The GF(2) compute-detiling math (
AI use: Antigravity (Gemini 4 Neon) audited the full diff against |
|
Review (head d2a7bdb, diff read, not a merge-check):
Fine: the swizzle math matches AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
d2a7bdb to
5d0b81e
Compare
|
Rebased onto
Re-verified on RTX 5070 Ti + WARP ( AI use: Antigravity (Gemini 4 Neon) implemented these review fixes, ran the tests and smoke, and drafted this reply. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 5d0b81e4: 1 finding(s) (1 medium), most severe first.
- Medium
crates/xcl/src/hle/d3d12x/real.rs:4837: Not certain about this one, because it depends on D3D12 device children holding a reference on their device: the newdev_releasehook probably never evicts the gpu_detile cache for a real device. (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
|
|
||
| /// ID3D12Device::Release: evict per-device GPU detile pipelines before the final Release frees the | ||
| /// address (preventing both device leaks and ABA reuse). | ||
| unsafe extern "system" fn dev_release(this: *mut c_void) -> u32 { |
There was a problem hiding this comment.
Medium: Not certain about this one, because it depends on D3D12 device children holding a reference on their device: the new dev_release hook probably never evicts the gpu_detile cache for a real device. The cached root signature and five PSOs are device children, so while the entry exists the device refcount never drops to the value the AddRef probe looks for. After one large GPU-detiled upload, the title's final Release leaves the device, its PSOs and the MADE slot alive for the life of the process (up to 8 devices before FIFO eviction). If children don't hold that reference, the opposite problem appears: release_taking_first drops the taken PSOs in after only after the final Release has already freed the device. The unit test uses a fake object with no child references, so it can't tell the two apart. Evicting from an explicit device-teardown point, or holding the cache by weak/private-data association, would avoid both.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
Add an opt-in (`XCL_GPU_DETILE=1`, default off) staged GPU compute detiling path in `texture_upload::submit()` using `cs_5_0` shaders (compiled via D3DCompile, no runtime DXC) and the GF(2) offset tables (`ox`, `oy`, `hx`, `hy`) from `gpu::tiling` across 1-, 2-, 4-, 8-, and 16-byte elements (R8, R16, RG8, RGBA8, BC1, BC7). When enabled, 2D swizzled non-tail pieces at or above `XCL_GPU_DETILE_MIN_BYTES` (default 256 KiB) copy raw tiled blocks into the upload buffer and record `known` page hashes on the CPU (preserving CPU detiling's source-read timing and unchanged-page deduplication), then detile into a pooled DEFAULT-heap UAV scratch buffer before `CopyTextureRegion`. Both device-independent shader compilation (`D3DCompile`) and D3D12 pipeline creation (`CreateRootSignature` + 5x `CreateComputePipelineState`) run off the submitting thread on a background thread (`xcl-gpu-detile-init`), falling back cleanly to CPU detiling until ready so the submitting thread never blocks during startup PSO compilation. Each upload queue owns its own `gpu_detile::Slot` inside `QueueUploads` (dropped on `title_textures::forget_queue`), avoiding any global device cache or device Release hook. `Job::in_flight_bytes()` accounts for both UPLOAD staging and DEFAULT detile scratch against `IN_FLIGHT_BYTES` / `IN_FLIGHT_MAX`, and `take()` ranks pooled jobs by smallest fitting upload buffer before tie-breaking on detile scratch fit. Includes unit and GPU bit-exactness tests across all 64 KiB modes, partial updates, `known` page hashing, `in_flight_bytes()` accounting, `take()` pool ranking, non-blocking off-thread init polling, and CPU fallback. Co-Authored-By: Antigravity (Gemini 4 Neon) <noreply@google.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5d0b81e to
72a12a0
Compare
|
Thanks @Foniass and @bmjask for the thorough reviews — reworked and rebased onto
Verification on
Ready for re-check. (Update authored with Antigravity, Gemini 4 Neon.) |
Adds an opt-in (
XCL_GPU_DETILE=1, default off) staged GPU compute detiling path intexture_upload::submit()usingcs_5_0shaders (compiled viaD3DCompile, no runtime DXC required) and the GF(2) offset tables fromgpu::tilingacross 1-, 2-, 4-, 8-, and 16-byte elements (R8,R16,RG8,RGBA8,BC1,BC7).When enabled, 2D swizzled non-tail pieces at or above
XCL_GPU_DETILE_MIN_BYTES(default 256 KiB) copy raw tiled blocks into the upload buffer and recordknownpage hashes on the CPU before detiling into a pooled DEFAULT-heap UAV scratch buffer ahead ofCopyTextureRegion. This preserves CPU detiling's source-read timing and unchanged-page deduplication. The default stays off until end-to-end GPU-time benefits are measured on heavy streaming workloads; the direct-UMA read path is split out for a separate follow-up PR.Total diff vs
main: 5 files changed,+781 / -34(+595 / -33runtime,+186 / -1unit/GPU tests).What is in it
crates/xcl/src/gpu/tiling.rs(+7):Layout::gpu_detile_tablesexposing the existingox,oy,hx,hyGF(2) tables and fixed XOR bits.crates/xcl/src/hle/d3d12x/gpu_detile.rs(+429,mod gpu_detileinmod.rs):XCL_GPU_DETILE=1(default off) andXCL_GPU_DETILE_MIN_BYTES(default256 KiB).cs_5_0compute shaders (1, 2, 4, 8, 16B elements),TablePacklayout deduplication, andeligible()filter (2D swizzled non-tail pieces meeting the size threshold).xcl-gpu-detile-init): both device-independentD3DCompile+D3D12SerializeRootSignature(cached inOnceLock) and per-queueCreateRootSignature+ 5×CreateComputePipelineStaterun off the submitting thread; uploads fall back cleanly to CPU detiling until ready.Slotis owned directly bytitle_textures::QueueUploadsand dropped ontitle_textures::forget_queue, with no global device cache and noID3D12Device::Releasehook (real.rsuntouched).Slot::pollstate transitions, env parsing, table deduplication, andeligible()filtering.crates/xcl/src/hle/d3d12x/texture_upload.rs(+338 / -29) andcrates/xcl/src/hle/d3d12x/title_textures.rs(+6 / -5):Work::RawBlocksstaging, pooled DEFAULT-heap UAV detile scratch buffer (ensure_detile_buf), UAV barrier andCOMMON/COPY_SOURCEtransitions, andJob::in_flight_bytes()accounted againstIN_FLIGHT_BYTES/IN_FLIGHT_MAX.take()ranks pooled jobs by smallest fitting upload buffer first (pool_rank), tie-breaking on detile scratch fit, so small GPU batches do not grab the largest pooled upload buffer.take_ranks_upload_size_before_scratch_fitandgpu_detile_matches_xg_for_all_element_sizes_and_64k_modes(R8, R16, RG8, RGBA8, BC1, BC7 × all four 64 KiB modes, whole textures, array slices, partial dirty-tile updates,knownpage hashing,in_flight_bytes()accounting, andSlot::FailedCPU fallback).Tested
32.0.16.1074), AMD Ryzen 9 9950X 16-Core, Windows 11 x64,rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.cargo build --release -p xcl: ok (39 pre-existingxcllib warnings, 0 new vsmain, 0 in changed code)..\scripts\test.ps1(with DXC 1.9.2609): 3010 passed, 0 failed, 52 ignored; 24SKIPPED(22no wave64, 2no heap windows; 0 DXC skips; all 6 newgpu_detileandtexture_uploadtests passed).cargo test -p xcl --lib gpu_detile -- --test-threads=1,cargo test -p xcl --lib texture_upload::tests -- --test-threads=1, andXCL_ADAPTER=warpcargo test -p xcl --lib texture_upload::tests::gpu_detile -- --test-threads=1): all passed, 0 skipped.Regression run
main:
PR (default,
XCL_GPU_DETILEunset):PR (opt-in,
XCL_GPU_DETILE=1):XCL_GPU_DETILEunset) vsmain:1696vs1698frames shown (99.9%),60 60 60vs60 61 60last presents per 2 s,0device removals,0crashes,17246vs15798MB peak commit (109.2%); GPU detiling stays inactive.XCL_GPU_DETILE=1) vsmain:1697vs1698frames shown (99.9%),60 61 60vs60 61 60last presents per 2 s,0device removals,0crashes,17256vs15798MB peak commit (109.2%,+10 MBvs default off).texture upload: GPU compute detiling active (min_bytes=262144)logged at 5.2 s with 0 Present stalls and 0 errors.Not tested
XCL_GPU_DETILEon by default).AI use
origin/main(817eb1fc9), stripped the direct-UMA path out for a separate follow-up PR, defaultedXCL_GPU_DETILEoff, movedGpuDetileownership into per-queueQueueUploads(removing the global cache andreal.rshook), moved bothD3DCompileand D3D12 PSO creation onto a background init thread, fixedtake()pool ranking with a unit test, and ran the release build, DXC 1.9 test suite, WARP test, and paired 60 s smokes.