Iter 24: GPU texture detiling and adaptive ring trim (VICTORY_GPU_DETILE) #9
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T02:27:13Z.
Summary
Ports
skornuta/victory-memory-stackGPU texture detiling (0001+0003:VICTORY_GPU_DETILE=1) and adaptive detile ring trimming (0014+0015:VICTORY_GPU_DETILE_TRIM) ontoMiniVI, adapted for MiniVI'sHostTexture(level0/copy.base),PreludeUpload(VICTORY_PRELUDE_UPLOADS=1),texture/ahead.rs(VICTORY_UPLOAD_AHEAD=1),pool::StagingPiece, and 8 GiB VRAM rigs:VICTORY_GPU_DETILE=1, off by default): Avoids per-texture persistent upload staging buffers by staging raw title bytes into a bounded 256 MiB upload ring (VICTORY_GPU_DETILE_RAW_MB), running a compute detile shader (Layout::copy_table) into a bounded card ring (VICTORY_GPU_DETILE_OUT_MB: defaults to 128 MiB on<= 9 GiBVRAM cards, 192 MiB on larger cards, with<= 85%VRAM budget halving down to 32 MiB), and falling back immediately to lazyCpuStagingif a ring or table buffer is full or a subresource table is unaligned.VICTORY_GPU_DETILE_TRIM, defaults ON whenVICTORY_GPU_DETILE=1;0disables): Shrinks idle rings toVICTORY_GPU_DETILE_SMALL_MB(64 MiBeach) afterVICTORY_GPU_DETILE_TRIM_S(20s) with no bursts and grows back on demand (retrying in 10s if VRAM budget temporarily lacks room without lowering the full target size).VICTORY_GPU_DETILEis unset; disablestexture/ahead.rscopy-queue uploads cleanly when GPU detiling is active; keeps PR #1 (fn record_upload) completely untouched.Changes
crates/victory-formats/src/texture.rs: AddedCopyRun,CopyRow,CopyTable,Layout::copy_table, and 4 comprehensive unit tests (copy_tables_detile_as_the_walk_does,copy_tables_check_as_the_walk_does,copy_table_alignment,copy_table_sizes).crates/victory-gpu/src/detile.rs: Added GPU detile rings,Arenafence-tracked allocator, table packer/cache, compute shader (DETILE), verification readback (VICTORY_GPU_DETILE_VERIFY), adaptive ring trim (fit), and WARP + table parity tests.crates/victory-gpu/src/texture_detile_tests.rs: Added WARP tests verifying CPU fallback upon ring full (warp_a_full_ring_after_the_staging_buffer_went_detiles_on_the_cpu) and subresource footprint bounds (warp_every_part_of_a_staging_layout_fits_its_slices).crates/victory-gpu/src/{lib,host,host/card_steps,texture,texture/ahead}.rs: WiredStep::GpuTexture,pre_list/sent/completedhooks,CpuStaginglazyOnceLock, andupload_on_card.Rig Specs Tested On
33,304,932KiB)10.0.26300/ NVIDIA Driver32.0.16.2124Run Settings & Profile
diag&release(RUSTFLAGS='-C link-self-contained=yes') @ branchfeat/iter24-gpu-texture-detile-and-trimseries-s(unattended launch smoke tests)VICTORY_EARLY_DEPTH=1)DLSS quality(VICTORY_DLSS=1,VICTORY_DLSS_MODE=quality,Streamlineloaded)offVICTORY_*Overrides:VICTORY_GPU_DETILEoff)VICTORY_GPU_DETILE=1 VICTORY_GPU_DETILE_VERIFY=10 VICTORY_GPU_DETILE_TRIM=1VICTORY_GPU_DETILE=1has not yet been playtested.)11 draws/frame).Measurements & Verification
30.0 fps(33.3 ms/frame) in both Smoke Test 1 (CPU default) and Smoke Test 2 (VICTORY_GPU_DETILE=1) with0 droppedoff)VICTORY_GPU_DETILE=1: textures are detiled on the card raw_mb=256 out_mb=128 table_mb=32 verify=10 trim=true;637indexed textures (195 MB) uploaded in Smoke Test 2 cleanly (0verify mismatches)0(6/7 [PASS]on both smoke tests — sole failing check is the pre-existing unmerged-PR#1 wave64 shader926c46bab3b86bd6; standalonediag&releasenon_system_mingw_dlls=0)cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy(296 files ok)cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask(6 passed; 0 failed)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings(0 warnings)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings(0 warnings)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-formats(46 passed; 0 failed; 5 ignored, including all 4copy_table*tests)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu -- --test-threads=1(455 passed; 0 failed; 36 ignored, including alldetile::tests::*andtexture::detile_fallback_tests::*)Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T02:33:03Z.
Verification complete for PR #9 (
98c18e7):elease binaries (RUSTFLAGS='-C link-self-contained=yes'):
on_system_mingw_dlls=0 on both
Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T03:04:04Z.
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingTechnical Review
CI is passing, and the implementation of opt-in GPU texture detiling (
VICTORY_GPU_DETILE=1) and adaptive ring trimming (VICTORY_GPU_DETILE_TRIM) looks solid and well-scoped.Verified Strengths
victory-formats(crates/victory-formats/src/texture.rs):Layout::copy_tableandCopyTable::{aligned, apply}mirrorLayout::detile's validation (mip/slice bounds, 3D slice checks,addressable()guard, pitch overflow checks) and are validated againstLayout::detileacross >1,000 layout/pitch combinations incopy_tables_detile_as_the_walk_does.crates/victory-gpu/src/detile.rs,crates/victory-gpu/src/texture.rs):pack()enforces 4-byte alignment andu32offset bounds;part()validatesshift + table.tiled_end <= raw_lenandtable.linear_end <= bytes; theDETILEcompute shader re-checksraw_lenandout_lenper 32-bit word.route()andStaging::ensure_cpucleanly fall back to a lazily allocatedCpuStaging(OnceLock) on any refusal (Unaligned,Tables,RawFull,OutFull,TooBig, etc.) while keepingSTAGED/LET_GObyte accounting balanced inStaging::dropandlet_go_idle.VICTORY_GPU_DETILEis unset,staging()eagerly allocatesCpuStagingas before andtexture/ahead.rsremains unaffected.crates/victory-gpu/src/detile.rs,crates/victory-gpu/src/host.rs):fit()only resizes/retires the rings whenraw_arena.used() == 0 && out_arena.used() == 0and all recorded pre-lists/jobs/checks have completed on the GPU fence, preventingout_buffer()from being swapped while any recordedUploador in-flightCopyTextureRegionreferences it.host.rsinsertsdetile::pre_list()at index0and shiftsfirsts[1..](keepingfirsts[0] == 0soVICTORY_GPU_TIMINGstill executes the detile pre-list ahead ofruns[0]), and notifiesdetile::sent(*submitted)on bothlateand synchronous submission paths.Step::GpuTextureis wired intoblocked_by(host.rs) anddoes_of(host/card_steps.rs) identically toStep::Texture.Why Local Real-GPU Testing Is Needed
Although unit tests, WARP tests, and unattended menu/intro smoke tests passed, this PR introduces a new D3D12 compute shader (
DETILE), host submission pre-list injection (pre_list/sent), VRAM-budgeted ring allocation (make_rings), and dynamic ring trimming (fit). As noted in the PR description, interactive open-world gameplay withVICTORY_GPU_DETILE=1(streaming bursts, ring pressure/fallback, and 20s idle trim/regrow transitions) has not yet been playtested on real GPU hardware.Generated with Antigravity CLI (
agy).