GPU: upload CPU-written textures before full and region copies #671

Manually merged
github merged 2 commits from gh-pr/671/head into gh-pr/671/base 2026-11-26 04:12:25 +00:00
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 06:31 UTC · original
fuzeofficlal:fix/copyresource-cpu-texture-source → main · +6 −0 · 1 files · 2 commits · merged 2026-11-24 08:20 UTC

Problem

The first GPU use of a CPU-written source texture can be a whole CopyResource or a texture-to-texture CopyTextureRegion. Both paths previously recorded the copy before uploading the CPU-authored bytes.

Change

The two commits use the existing title_written check and texture upload path before recording each copy's transitions.

Verification

Synthetic readback on RTX 5090 and WARP Baseline Patched
Whole 4×4 RGBA8 copy d2a4bae, 0/16 pixels matched 16/16
2×2 crop from (1,1)..(3,3) to destination (1,2) 0064c08, all four copied pixels read zero, 12 outside pixels matched 16/16, including the 12 outside canaries

The explicit-upload, GPU render target, and GPU-copy-written source controls matched all 16 pixels. The D3D12 debug layer reported zero errors. The whole-copy controls were rerun after the region change. The diagnostics GPU suite passed on both adapters, with 45 passed and one existing benchmark ignored per adapter. The staged asset policy check passed.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 06:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/671) `fuzeofficlal:fix/copyresource-cpu-texture-source` → `main` · +6 −0 · 1 files · 2 commits · merged 2026-11-24 08:20 UTC ## Problem The first GPU use of a CPU-written source texture can be a whole `CopyResource` or a texture-to-texture `CopyTextureRegion`. Both paths previously recorded the copy before uploading the CPU-authored bytes. ## Change The two commits use the existing `title_written` check and texture upload path before recording each copy's transitions. ## Verification | Synthetic readback on RTX 5090 and WARP | Baseline | Patched | | --- | --- | --- | | Whole 4×4 RGBA8 copy | `d2a4bae`, 0/16 pixels matched | 16/16 | | 2×2 crop from `(1,1)..(3,3)` to destination `(1,2)` | `0064c08`, all four copied pixels read zero, 12 outside pixels matched | 16/16, including the 12 outside canaries | The explicit-upload, GPU render target, and GPU-copy-written source controls matched all 16 pixels. The D3D12 debug layer reported zero errors. The whole-copy controls were rerun after the region change. The diagnostics GPU suite passed on both adapters, with 45 passed and one existing benchmark ignored per adapter. The staged asset policy check passed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:12:23 +00:00
github manually merged commit 4f53d6f1f3 into gh-pr/671/base 2026-11-26 04:12:25 +00:00
Author
Owner

@⁠ifBars on GitHub · 2026-11-24 06:50 UTC · original

I reproduced this on the downstream Causeway renderer with Agility WARP and GPU-based validation. The test writes a 4×4 RGBA8 guest texture and calls the guest command list's CopyResource twice, A → B → C. B's guest memory stays zero, so the second copy also checks that first-use upload respects GPU ownership.

Before the change, all 16 pixels read back from C were zero. With these three lines after Causeway's format check, all 16 matched the source. No game files were used for the regression test. The fixture is in Causeway #26. AI-assisted verification with Codex.

**@⁠ifBars** on GitHub · 2026-11-24 06:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/671#issuecomment-7124346089) I reproduced this on the downstream Causeway renderer with Agility WARP and GPU-based validation. The test writes a 4×4 RGBA8 guest texture and calls the guest command list's CopyResource twice, A → B → C. B's guest memory stays zero, so the second copy also checks that first-use upload respects GPU ownership. Before the change, all 16 pixels read back from C were zero. With these three lines after Causeway's format check, all 16 matched the source. No game files were used for the regression test. The fixture is in [Causeway #26](https://github.com/ifBars/VICauseway/pull/26/files). AI-assisted verification with Codex.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 07:04 UTC · original

I checked the staging-order question on 4f53d6f. texture::upload records the staging-buffer-to-texture copy in the command list before the texture-to-destination copy. It defers filling the staging buffer. Host::execute runs that fill before submitting the list.

For a direct check I recorded and closed each copy, then changed the synthetic CPU texture before calling Host::execute. On both RTX 5090 and WARP, the whole and region copies each matched 16/16 pixels against the later pattern, including the untouched pixels outside the region. The GPU-written controls kept their GPU values despite the CPU edit. The debug layer reported zero errors.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 07:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/671#issuecomment-7124591658) I checked the staging-order question on `4f53d6f`. `texture::upload` records the staging-buffer-to-texture copy in the command list before the texture-to-destination copy. It defers filling the staging buffer. `Host::execute` runs that fill before submitting the list. For a direct check I recorded and closed each copy, then changed the synthetic CPU texture before calling `Host::execute`. On both RTX 5090 and WARP, the whole and region copies each matched 16/16 pixels against the later pattern, including the untouched pixels outside the region. The GPU-written controls kept their GPU values despite the CPU edit. The debug layer reported zero errors.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!671
No description provided.