Skip to content

GPU: prepare and upload only dirty texture bands (opt-in) - #2358

Open
nicolasveilleux wants to merge 2 commits into
Marvisak:mainfrom
nicolasveilleux:perf/texture-upload-bands
Open

nicolasveilleux wants to merge 2 commits into
Marvisak:mainfrom
nicolasveilleux:perf/texture-upload-bands

Conversation

@nicolasveilleux

Copy link
Copy Markdown

What changes

When a tracked, single-mip 2D texture is reached through the descriptor heap, a sparse update can now read and detile only the affected tile rows and copy just that band to the GPU. The first upload, dense changes and unsupported layouts keep the existing full path. This is opt-in (VICTORY_TEXTURE_UPLOAD_BANDS=1) and off by default.

The scope is within a subresource. #1135 skips unaffected mips and slices on the CPU but still uploads the full texture. This PR does not change the eager upload timing addressed by #230 and #1891.

Validation

On Windows 11, RTX 2070 Super (driver 610.60), 24 paired runs of a synthetic 4096 × 4096 RGBA8 texture:

Sparse update Off On
End-to-end median 36.81 ms 1.37 ms
CPU preparation median 30.04 ms 0.91 ms
End-to-end p95 43.11 ms 1.96 ms
GPU upload 64 MiB 2 MiB

Timing includes the CPU write, preparation, and submission through queue completion. The partial path won 24/24 pairs. Dense updates kept the full 64 MiB copy in both modes (45.31 vs. 43.53 ms median). Full GPU readback matched expected bytes in both modes for both patterns. No game files or gameplay measurements.

  • Formats: 38 passed, 5 ignored. GPU: 145 passed, 2 ignored, with the same two descriptor/memory failures on the baseline. All six texture tests passed on hardware and WARP. Clippy (both crates, all features) and the asset-policy check passed.
  • Separately ran the synthetic #1891 regression: the same four outcomes (16/16, 0/16, 0/16, 16/16) on main (940d32f) and on this branch with bands off and on. The test was not included in this PR.

AI-assisted (OpenAI Codex).

Keep full copies for the first upload and ineligible layouts. Use tracked tile-row ranges only for bindless uploads, and validate the D3D12 copy with synthetic readback.
Read the complete tiled row band and detile into only those staging rows. Keep the full fallback and validate band bounds and pixel parity for linear, swizzled and block-compressed layouts.
@DrDarkDK

Copy link
Copy Markdown

I adapted the GPU band-copy fixture on 8da78cf to a 260×516 BC3 texture with a padded row pitch. A dirty page at the bottom selected texel rows 512..516, exactly one BC3 block row.

On native Windows with an RTX 4070 Ti (621.01) and WARP, the full readback matched on both adapters: the last block row held the new pattern, and all 128 preceding block rows kept their original bytes.

This exercises dirty_band and the GPU copy with prefilled staging data. Synthetic only.

AI-assisted with Codex.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prepare and upload only dirty texture bands (opt-in VICTORY_TEXTURE_UPLOAD_BANDS): detile_rows partial detiling in victory-formats + GPU wiring (+523). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. The formats-side detile_rows is the portable part — being batch-tested on macOS now, will follow up.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up to my earlier static note: the victory-formats side (detile_rows partial detiling) tested locally — merged into main 940d32f, cargo test -p victory-formats --locked on macOS arm64: 38 passed, 0 failed, 5 ignored. The portable detiling math is green; the GPU upload wiring remains Windows-only (static).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants