Repository navigation
perf(gpu): detile and upload only touched rows on tracked texture writes - #416
Conversation
Port dirty-row partial texture detiling and upload so a tracked write into a subresource that owns a changed page reads, detiles, and copies only the affected element-row band through a block-aligned D3D12_BOX instead of re-reading and detiling the entire mip: - victory-formats: add Layout::touched_rows and Layout::detile_rows, extending the paired-row walk_runs loop to support arbitrary (including odd-starting) row ranges without breaking row-pair alignment. - victory-gpu (watch): add Tracked::retry to requeue taken pages when staging allocation or detiling fails so dirty updates are never dropped. - victory-gpu (texture): plan per-subresource row bands on tracked writes (with VICTORY_DIRTY_ROWS=0 opt-out for A/B testing), exclude subresources overlapping untracked memory from partial-row skipping so ordinary-memory rows never go stale, scale block-compressed D3D12_BOX row bounds by block size, and requeue failed uploads via Tracked::retry. - Add format parity/timing tests and D3D12/D3DMetal GPU tests covering partial RGBA8 and BC1/BC7 row uploads, mixed tracked+untracked mips, and deferred staging retry.
|
An M4 Pro follow-up to the single-page result. I used gdemontalivet’s exact #416 revision to compare the current single row band with a prototype that plans each contiguous dirty range and merges touching row bands. Two native release runs, 24 samples per mode, with byte-exact output against a full detile in every sample.
This measures resident-memory copying, planning and the real detile function. GPU upload cost and gameplay pacing are separate measurements. Prepared and tested with Codex. |
|
Correction: this PR is not the cause. More runs show the dark first indoor area and grey, ashen skin come and go with the host pipeline library. The dark runs, with or without this PR, each had 35 to 42 frames that dropped work while about 2,000 pipelines were still being made after the library was replaced. The lit runs had 1 to 3. Switching between builds is what emptied the library in my comparison, so the earlier result here was an artifact of how I tested, and I'm sorry for the noise. The likely mechanism: one-time setup work at the start of the scene, probably the lighting, gets dropped because its pipeline isn't ready yet, and the scene stays wrong afterwards. I'll test this PR again with a warm library. Prepared with Claude Code.
In-game check on an M5 Pro (macOS 27.0.1, CrossOver 26.3 Wine with the repo's current patches, D3DMetal 4.0 beta 3, Series X). Runs with the same opening and scripted input, on
Happy to run a debug switch or extra logging if that helps narrow it down. Prepared with Claude Code. |
|
Thanks for this. Many pull requests landed today, and this one now conflicts with main. Could you merge or rebase main into it, rerun the checks and ping here? I will review and merge it as soon as CI is green. |
Summary
victory-formatstiled row walking (including paired-rowwalk_runsodd-start handling) to detile only the row range touched by dirty 64 KiB pages of a tracked texture mip.D3D12_BOXbands viaCopyTextureRegion(VICTORY_DIRTY_ROWS=1default,0opts out for A/B testing).Tracked::retryon failed staging allocation/detile.Measured M5 Max (CrossOver / D3DMetal) Impact
945.1 µs → 47.2 µs(20.0× faster, 16× less tiled memory read).844.2 ms → 664.5 ms(-21.3%), CPU prep370.9 ms → 244.1 ms(-34.2%), submit-thread textures48.0 ms → 29.1 ms(-39.4%), GPU time107.5 ms → 95.8 ms(-10.9%).Verification
cargo xtask policy: passcargo test -p victory-formats: 55 passedtexture::,tracked_rows::, single-page upload): 17/17 passedcargo clippy --target x86_64-pc-windows-gnullvm --workspace --all-targets -- -D warnings(default &--features diagnostics): 0 warnings