GPU: a tracked texture write detiles and copies only the rows it touches (#1135) #2985

Open
github-bot wants to merge 4 commits from github-bot/gh-2985 into main AGit
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 02:17 UTC · original
wwwwwwww3333333:fix/texture-rows → main · +633 −63 · 5 files · 4 commits · open

Ports the idea of #1135 to current main (63bcca4). Credit to @⁠talakasse, whose patch #1135 carries, to @⁠divyeshganta, who opened #1135, and to @⁠akimfomin, whose comment there points the same way for the GPU copy.

Main already reads and detiles only the subresources a tracked write reaches. It still re-reads and detiles each of those whole: one 64 KiB page written into mip 0 of a 4K BC7 texture costs all 16 MiB of that mip.

What changes

  • victory-formats: Layout::touched_rows returns the rows of a subresource whose tiled bytes overlap the written ranges, and the tiled bytes those rows read. Layout::detile_rows detiles only those rows. walk takes an optional row range; its run computation moved into Layout::runs, unchanged.
  • victory-gpu (texture.rs): for a subresource that owns a written page (the path that already skips hashing), only the band's tiled bytes are read, only its rows are detiled, and only those rows are copied, through a D3D12_BOX. Staging buffers come from a shared pool, so the rows outside the band hold stale bytes and are never copied. Subresources on shared pages, untracked memory and layouts the layout code cannot address keep the whole-subresource path. Upload now carries (subresource, Option<rows>).

Tests (RX 6750 XT, i5-13400F, Windows 11, Rust 1.98.1 MSVC, on 63bcca4)

  • New detiling_the_touched_rows_matches_detiling_all (victory-formats): 7 layouts (linear, 256B/4KB/64KB S and D, BC, arrays, 3D), random pages written. A change stays inside the rows reported, and detiling those rows from only the reported bytes (the rest garbage) matches a full detile. It asserts that more than 50 cases are partial bands.
  • New a_write_into_one_page_uploads_its_rows_alone (victory-gpu, on hardware): a 512x512 texture, one page written then another. The written rows arrive, the other rows keep their earlier contents, and one subresource is copied each time.
  • victory-formats 47/47 and victory-gpu 232/232, twice each (main alone: 46 and 231).
  • cargo clippy -p victory-formats -p victory-gpu --all-targets -- -D warnings: clean.

Timing (release, ignored test detile_the_rows_of_one_written_page_of_a_4k_bc7_texture): 4096x4096 BC7, one 64 KiB page in mip 0. Whole mip: 2.73 ms. Touched rows (64 of 1024, 1 MiB of tiled memory read instead of 16 MiB): 0.086 ms. CPU detile only; the smaller read and GPU copy are not timed.

Not measured: the effect on a frame in a title.

Unit tests only, no game files.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 02:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985) `wwwwwwww3333333:fix/texture-rows` → `main` · +633 −63 · 5 files · 4 commits · open Ports the idea of #1135 to current main (63bcca4). Credit to @⁠talakasse, whose patch #1135 carries, to @⁠divyeshganta, who opened #1135, and to @⁠akimfomin, whose comment there points the same way for the GPU copy. Main already reads and detiles only the subresources a tracked write reaches. It still re-reads and detiles each of those whole: one 64 KiB page written into mip 0 of a 4K BC7 texture costs all 16 MiB of that mip. **What changes** - `victory-formats`: `Layout::touched_rows` returns the rows of a subresource whose tiled bytes overlap the written ranges, and the tiled bytes those rows read. `Layout::detile_rows` detiles only those rows. `walk` takes an optional row range; its run computation moved into `Layout::runs`, unchanged. - `victory-gpu` (`texture.rs`): for a subresource that owns a written page (the path that already skips hashing), only the band's tiled bytes are read, only its rows are detiled, and only those rows are copied, through a `D3D12_BOX`. Staging buffers come from a shared pool, so the rows outside the band hold stale bytes and are never copied. Subresources on shared pages, untracked memory and layouts the layout code cannot address keep the whole-subresource path. `Upload` now carries `(subresource, Option<rows>)`. **Tests** (RX 6750 XT, i5-13400F, Windows 11, Rust 1.98.1 MSVC, on 63bcca4) - New `detiling_the_touched_rows_matches_detiling_all` (victory-formats): 7 layouts (linear, 256B/4KB/64KB S and D, BC, arrays, 3D), random pages written. A change stays inside the rows reported, and detiling those rows from only the reported bytes (the rest garbage) matches a full detile. It asserts that more than 50 cases are partial bands. - New `a_write_into_one_page_uploads_its_rows_alone` (victory-gpu, on hardware): a 512x512 texture, one page written then another. The written rows arrive, the other rows keep their earlier contents, and one subresource is copied each time. - victory-formats 47/47 and victory-gpu 232/232, twice each (main alone: 46 and 231). - `cargo clippy -p victory-formats -p victory-gpu --all-targets -- -D warnings`: clean. **Timing** (release, ignored test `detile_the_rows_of_one_written_page_of_a_4k_bc7_texture`): 4096x4096 BC7, one 64 KiB page in mip 0. Whole mip: 2.73 ms. Touched rows (64 of 1024, 1 MiB of tiled memory read instead of 16 MiB): 0.086 ms. CPU detile only; the smaller read and GPU copy are not timed. **Not measured:** the effect on a frame in a title. Unit tests only, no game files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:22 +00:00
Address both cases reported by fuzeofficlal on #2985. Hash the entire affected subresource when some of it is ordinary memory, and requeue consumed tracked pages when staging returns no upload. Exercise initial contents, a write to ordinary memory alone, and retry with and without a later tracked write.
The test freed its three pools while the guards of their tracked pages were
still held. A later test's pool, given the same addresses, never saw its
writes (a_copy_is_refreshed_once_per_submission_by_the_pages_written read 0
changed bytes when run after it). Like the other draw tests, leave the pools
allocated.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LwHmoV6jP696CZH3DVW7V1
Author
Owner

@⁠pickles976 on GitHub · 2026-11-26 02:44 UTC · original

Independent Wine/vkd3d-proton 3.2.0 verification, exact head 632d05e1: detiling_the_touched_rows_matches_detiling_all 1/1 passed; a_write_into_one_page_uploads_its_rows_alone 1/1 passed on the physical RTX 4060 Laptop GPU (NVIDIA 590.48.1, vendor masking disabled), including GPU readback showing unchanged rows retain their prior contents across two page writes. No in-title frame-time or host-RAM peak measured; this does not clear our loading RAM guard. Logs .compat-runtime/logs/verify-pr2985-wine-{touched-rows-parity,rtx4060-partial-texture-upload}.log.

**@⁠pickles976** on GitHub · 2026-11-26 02:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7181078849) Independent Wine/vkd3d-proton 3.2.0 verification, exact head 632d05e1: `detiling_the_touched_rows_matches_detiling_all` 1/1 passed; `a_write_into_one_page_uploads_its_rows_alone` 1/1 passed on the *physical RTX 4060 Laptop GPU* (NVIDIA 590.48.1, vendor masking disabled), including GPU readback showing unchanged rows retain their prior contents across two page writes. No in-title frame-time or host-RAM peak measured; this does not clear our loading RAM guard. Logs `.compat-runtime/logs/verify-pr2985-wine-{touched-rows-parity,rtx4060-partial-texture-upload}.log`.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 02:57 UTC · original

The conflict with #2626 is resolved on codex/pr2985-packed-rows. Its parents are this PR at 632d05e and #2626 at c8cc83e. The packed path expands tiled spans directly into RGBA8 staging and keeps the copy limited to the rows populated. To try it from this PR, run git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2985-packed-rows then git merge --ff-only FETCH_HEAD.

The committed packed_page_updates_respect_texture_ownership test reads 64 × 1,536 pixels through normal descriptor-table submission. On both RTX 5080 (621.40) and Windows WARP, native sampled B5G5R5A1 and B4G4R4A4 initialized correctly, then updated rows 256–511 and 0–255 on successive writes. All other rows retained their colors, with zero wrong pixels in three runs per adapter. In a separate control I prefilled staging with a sentinel and widened each partial copy to the full mip. Exactly 81,920 pixels outside each 256-row band then failed, on both adapters and both formats.

On the RTX the writable versions used RGBA8 and took their initial pixels from title memory once. They kept those pixels after the two later guest writes, as #2626 intends. WARP used native writable formats. The two existing partial-copy and padding tests from #2626 also passed three times on each adapter.

For the BC and pitched-copy question in the review, a separate test drove the staging and copy routines directly. Each adapter matched 81,084 packed texels and 1,278 BC1 blocks across 3D mips and array slices, including the last rows of 34×18 and 17×9 BC mips and an untouched middle array slice. These are synthetic Windows readbacks. I’m checking mixed tracking coverage and retry behavior separately. Format suite 47 passed, six ignored. Strict Clippy and asset policy passed.

AI-assisted with Codex.

**@⁠steven-seagull27** on GitHub · 2026-11-26 02:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7181265945) The conflict with #2626 is resolved on [`codex/pr2985-packed-rows`](https://github.com/steven-seagull27/VIctory/commit/df3aa42e204373013921490614d41c4a6425d1d6). Its parents are this PR at `632d05e` and #2626 at `c8cc83e`. The packed path expands tiled spans directly into RGBA8 staging and keeps the copy limited to the rows populated. To try it from this PR, run `git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2985-packed-rows` then `git merge --ff-only FETCH_HEAD`. The committed `packed_page_updates_respect_texture_ownership` test reads 64 × 1,536 pixels through normal descriptor-table submission. On both RTX 5080 (621.40) and Windows WARP, native sampled B5G5R5A1 and B4G4R4A4 initialized correctly, then updated rows 256–511 and 0–255 on successive writes. All other rows retained their colors, with zero wrong pixels in three runs per adapter. In a separate control I prefilled staging with a sentinel and widened each partial copy to the full mip. Exactly 81,920 pixels outside each 256-row band then failed, on both adapters and both formats. On the RTX the writable versions used RGBA8 and took their initial pixels from title memory once. They kept those pixels after the two later guest writes, as #2626 intends. WARP used native writable formats. The two existing partial-copy and padding tests from #2626 also passed three times on each adapter. For the BC and pitched-copy question in [the review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2985), a separate test drove the staging and copy routines directly. Each adapter matched 81,084 packed texels and 1,278 BC1 blocks across 3D mips and array slices, including the last rows of 34×18 and 17×9 BC mips and an untouched middle array slice. These are synthetic Windows readbacks. I’m checking mixed tracking coverage and retry behavior separately. Format suite 47 passed, six ignored. Strict Clippy and asset policy passed. AI-assisted with Codex.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 03:14 UTC · original

@⁠fuzeofficlal I confirmed both review findings on the RTX 5080 and Windows WARP. 2fa3f3d fixes both in one commit directly on this PR’s 632d05e. It also merges cleanly with the separate packed-format integration.

Each row below gives wrong pixels out of 49,152, identical on both adapters in three runs each. Page A and page B belong to the same sampled RGBA8 mip.

Readback main 63bcca4 PR 632d05e Fix 2fa3f3d
Initial sample, one ordinary page and two tracked pages 0 16,384 0
Write only the ordinary page, sample again 16,384 16,384 0
Fully tracked mip, defer A’s staging once, submit again without another write 16,384 16,384 0
Defer A again, write B, submit both changes 0 16,384 0

The test checks the live tracker’s coverage and reads every pixel through the ordinary descriptor table. The retry fixture returns None once from the detile step after the dirty ranges have been taken, so it’s repeatable without exhausting GPU memory. Mixed-coverage mips now use the full-subresource hash path. A failed stage requeues the tracked pages alongside later writes. An unchanged follow-up submission issued zero copies. The existing fully tracked sparse-upload test still passes on both adapters.

To apply on the current PR head:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2985-tracked-retry
git cherry-pick 2fa3f3dc74dc9c2c0dda705a9b72dda5ad268a69
cargo test -p victory-gpu --lib mixed_pages_and_deferred_rows -- --nocapture --test-threads=1

Final committed tests passed three times per adapter. Strict Clippy, asset policy and the format suite passed (47 tests, six ignored). AI-assisted with Codex.

**@⁠steven-seagull27** on GitHub · 2026-11-26 03:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7181526584) @⁠fuzeofficlal I confirmed both [review findings](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2985) on the RTX 5080 and Windows WARP. [`2fa3f3d`](https://github.com/steven-seagull27/VIctory/commit/2fa3f3dc74dc9c2c0dda705a9b72dda5ad268a69) fixes both in one commit directly on this PR’s `632d05e`. It also merges cleanly with the separate packed-format integration. Each row below gives **wrong pixels out of 49,152**, identical on both adapters in three runs each. Page A and page B belong to the same sampled RGBA8 mip. | Readback | main `63bcca4` | PR `632d05e` | Fix `2fa3f3d` | |---|---:|---:|---:| | Initial sample, one ordinary page and two tracked pages | 0 | 16,384 | 0 | | Write only the ordinary page, sample again | 16,384 | 16,384 | 0 | | Fully tracked mip, defer A’s staging once, submit again without another write | 16,384 | 16,384 | 0 | | Defer A again, write B, submit both changes | 0 | 16,384 | 0 | The test checks the live tracker’s coverage and reads every pixel through the ordinary descriptor table. The retry fixture returns `None` once from the detile step after the dirty ranges have been taken, so it’s repeatable without exhausting GPU memory. Mixed-coverage mips now use the full-subresource hash path. A failed stage requeues the tracked pages alongside later writes. An unchanged follow-up submission issued zero copies. The existing fully tracked sparse-upload test still passes on both adapters. To apply on the current PR head: ```sh git fetch https://github.com/steven-seagull27/VIctory.git codex/pr2985-tracked-retry git cherry-pick 2fa3f3dc74dc9c2c0dda705a9b72dda5ad268a69 cargo test -p victory-gpu --lib mixed_pages_and_deferred_rows -- --nocapture --test-threads=1 ``` Final committed tests passed three times per adapter. Strict Clippy, asset policy and the format suite passed (47 tests, six ignored). AI-assisted with Codex.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 03:15 UTC · original

Note for whoever merges this together with #2639: #2639 adds the tracker's untracked parts (loose) as candidates. With both, a subresource that owns a changed tracked page and also overlaps a changed untracked part would take the row path here, and touched_rows sees only the tracked ranges, so the rows of the untracked part would not be read again. The fix for whichever lands second is to take the row path only where the subresource overlaps no loose range (the whole-subresource path then reads and hashes it, as #2639 does). I can rebase this onto #2639 with that rule if it lands first.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 03:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7181536873) Note for whoever merges this together with #2639: #2639 adds the tracker's untracked parts (`loose`) as candidates. With both, a subresource that owns a changed tracked page and also overlaps a changed untracked part would take the row path here, and `touched_rows` sees only the tracked ranges, so the rows of the untracked part would not be read again. The fix for whichever lands second is to take the row path only where the subresource overlaps no `loose` range (the whole-subresource path then reads and hashes it, as #2639 does). I can rebase this onto #2639 with that rule if it lands first.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 03:32 UTC · original

Your proposed loose overlap guard fixes the mixed-write case. I combined this PR (632d05e) with @⁠BastienRodz's #2639 (2f98c15), which supplies the ordinary-memory candidate ranges. I used one fully resident, three-page mip: the first page is ordinary memory and the other two are write-watched.

After confirming the old values, I changed the ordinary page from 0x99 to 0x55 and the adjacent tracked page from 0x33 to 0x77 before one normal submission. With just the two PRs combined, the tracked and untouched pages were correct, but all 16,384 texels on the ordinary page still sampled as 0x99. The next unchanged submit caught up by copying the mip again. With the overlap exclusion, all 49,152 texels matched on the first submit (one copy), and the unchanged submit copied nothing. The RTX 5080 and Windows built-in WARP gave these results in three fresh processes each. The earlier ordinary-only, fully tracked and deferred-staging checks also passed on the fixed branch.

I put the optional combined branch and simultaneous-write test on my fork. It retains both original PR histories and 2fa3f3d. Candidate selection uses #2639's loose ranges, the row shortcut excludes mips overlapping them, and a deferred upload retries consumed tracked pages. The branch is available for comparing either eventual rebase. BastienRodz's corresponding note on #2639.

**@⁠steven-seagull27** on GitHub · 2026-11-26 03:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7181813803) Your proposed `loose` overlap guard fixes the mixed-write case. I combined this PR (`632d05e`) with @⁠BastienRodz's #2639 (`2f98c15`), which supplies the ordinary-memory candidate ranges. I used one fully resident, three-page mip: the first page is ordinary memory and the other two are write-watched. After confirming the old values, I changed the ordinary page from `0x99` to `0x55` and the adjacent tracked page from `0x33` to `0x77` before one normal submission. With just the two PRs combined, the tracked and untouched pages were correct, but **all 16,384 texels on the ordinary page still sampled as `0x99`**. The next unchanged submit caught up by copying the mip again. With the overlap exclusion, **all 49,152 texels matched on the first submit** (one copy), and the unchanged submit copied nothing. The RTX 5080 and Windows built-in WARP gave these results in three fresh processes each. The earlier ordinary-only, fully tracked and deferred-staging checks also passed on the fixed branch. I put the [optional combined branch and simultaneous-write test on my fork](https://github.com/steven-seagull27/VIctory/commit/76bbdd9c35f4061a16a2b388ced4bb93e6d8d266). It retains both original PR histories and `2fa3f3d`. Candidate selection uses #2639's `loose` ranges, the row shortcut excludes mips overlapping them, and a deferred upload retries consumed tracked pages. The branch is available for comparing either eventual rebase. [BastienRodz's corresponding note on #2639](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2639).
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 04:11 UTC · original

Thanks @⁠fuzeofficlal and @⁠steven-seagull27. Both findings are confirmed and fixed on this branch.

  • A partly tracked mip no longer skips its untracked rows, and a staging upload that fails is retried instead of leaving rows stale. This is steven-seagull27's commit 91284ea, taken as is with his authorship, including the loose-overlap rule for #2639.
  • One follow-up, cf6d7ee: the new test freed its three pools at the end. The guards of their tracked pages outlive the textures, so a later test whose pool got the same addresses never saw its writes. a_copy_is_refreshed_once_per_submission_by_the_pages_written then failed in 4 of 6 full runs of the suite (0 changed bytes, expected 65536). The new test now leaves its pools allocated, like the other draw tests. With that, the full victory-gpu suite passed 4 of 4 runs, then victory-formats and clippy too. This is not tested in a title.

@⁠steven-seagull27: you may want the same change in your branch if you carry the test there.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 04:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7182370342) Thanks @⁠fuzeofficlal and @⁠steven-seagull27. Both findings are confirmed and fixed on this branch. - A partly tracked mip no longer skips its untracked rows, and a staging upload that fails is retried instead of leaving rows stale. This is steven-seagull27's commit 91284ea, taken as is with his authorship, including the loose-overlap rule for #2639. - One follow-up, cf6d7ee: the new test freed its three pools at the end. The guards of their tracked pages outlive the textures, so a later test whose pool got the same addresses never saw its writes. `a_copy_is_refreshed_once_per_submission_by_the_pages_written` then failed in 4 of 6 full runs of the suite (0 changed bytes, expected 65536). The new test now leaves its pools allocated, like the other draw tests. With that, the full victory-gpu suite passed 4 of 4 runs, then victory-formats and clippy too. This is not tested in a title. @⁠steven-seagull27: you may want the same change in your branch if you carry the test there.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:33 UTC · original

Automated triage for the maintainers.

Merge candidate. When a tracked write lands on pages a subresource owns alone, Staging::refresh_now in victory-gpu/src/texture.rs now reads, detiles and copies only the rows those pages reach. It uses Layout::touched_rows / detile_rows in victory-formats and a D3D12_BOX in copies. Shared pages, untracked memory and layouts the layout code cannot address still take the whole-subresource path.

Both findings from the earlier review are fixed in 91284ea:

  • a mip that overlaps untracked memory takes the full path (own);
  • a failed stage requeues its pages (Tracked::retry in watch.rs).

The format test checks that a row-limited detile matches a full one over 7 layouts, including BC and 3D. Independent runs on NVIDIA and WARP in the comments agree.

Worth knowing:

  • Untracked spans now count as changes at every refresh, so subresources that overlap them are re-read and hashed each submission, as Tracked::untracked documents.
  • The test fix in cf6d7ee leaves pools allocated because tracked-page guards outlive their textures. That is existing behaviour, but worth an issue.
  • Nothing was measured in a title.

CI: passing. Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 05:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7183598143) <!-- victory-triage v1 head=cf6d7ee5aa93ecfc6d83d13f94e2d56803d7e09a verdict=merge-candidate at=2026-11-26T05:33:32Z --> Automated triage for the maintainers. **Merge candidate.** When a tracked write lands on pages a subresource owns alone, `Staging::refresh_now` in `victory-gpu/src/texture.rs` now reads, detiles and copies only the rows those pages reach. It uses `Layout::touched_rows` / `detile_rows` in `victory-formats` and a `D3D12_BOX` in `copies`. Shared pages, untracked memory and layouts the layout code cannot address still take the whole-subresource path. Both findings from the earlier review are fixed in `91284ea`: - a mip that overlaps untracked memory takes the full path (`own`); - a failed stage requeues its pages (`Tracked::retry` in `watch.rs`). The format test checks that a row-limited detile matches a full one over 7 layouts, including BC and 3D. Independent runs on NVIDIA and WARP in the comments agree. Worth knowing: - Untracked spans now count as changes at every refresh, so subresources that overlap them are re-read and hashed each submission, as `Tracked::untracked` documents. - The test fix in `cf6d7ee` leaves pools allocated because tracked-page guards outlive their textures. That is existing behaviour, but worth an issue. - Nothing was measured in a title. CI: passing. Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 05:48 UTC · original

@⁠wwwwwwww3333333 Thanks for catching the pool lifetime in my test. I carried your cf6d7ee correction, with your authorship, onto both branches. The standalone tree now has the same file contents as your current head. The combined #2639 tree also keeps @⁠BastienRodz’s candidate-range changes and the simultaneous tracked/ordinary write check.

I ran mixed_pages_and_deferred_rows_reach_the_sampled_texture followed by a_copy_is_refreshed_once_per_submission_by_the_pages_written in the same test process, with one test thread. On each branch the pair passed in 6/6 fresh processes on the RTX 5080 and 6/6 on built-in Windows WARP. The D3D12 debug layer and an adapter identity check were enabled in every process. On the combined branch, the mixed-page test still checks all 49,152 texels after the simultaneous writes and expects zero new copies on the next unchanged submission.

Your four full-suite runs cover the broader ordering. My rerun targeted the two tests you identified. AI-assisted with Codex.

**@⁠steven-seagull27** on GitHub · 2026-11-26 05:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7183830825) @⁠wwwwwwww3333333 Thanks for catching the pool lifetime in my test. I carried your `cf6d7ee` correction, with your authorship, onto both branches. The [standalone tree](https://github.com/steven-seagull27/VIctory/commit/205e3890f9dcb922d88806d212183671eff9f5d1) now has the same file contents as your current head. The [combined #2639 tree](https://github.com/steven-seagull27/VIctory/commit/a7f4bfa376c576e888f55f0f79c286cd4683a444) also keeps @⁠BastienRodz’s candidate-range changes and the simultaneous tracked/ordinary write check. I ran `mixed_pages_and_deferred_rows_reach_the_sampled_texture` followed by `a_copy_is_refreshed_once_per_submission_by_the_pages_written` in the **same test process**, with one test thread. On each branch the pair passed in **6/6 fresh processes on the RTX 5080** and **6/6 on built-in Windows WARP**. The D3D12 debug layer and an adapter identity check were enabled in every process. On the combined branch, the mixed-page test still checks all 49,152 texels after the simultaneous writes and expects zero new copies on the next unchanged submission. Your four full-suite runs cover the broader ordering. My rerun targeted the two tests you identified. AI-assisted with Codex.
Author
Owner

@⁠MeMako on GitHub · 2026-11-26 06:28 UTC · original

Verified #2985 (cf6d7ee) on AMD RDNA 4 (Windows 11 10.0.26200, Ryzen 9 7950X, RX 9070 XT, driver 32.0.32029.2010, 32 GB RAM).

Tests & Microbenchmark

  • cargo clippy -p victory-formats -p victory-gpu --all-targets --locked -- -D warnings: clean.
  • victory-formats: 47/47 passed (including detiling_the_touched_rows_matches_detiling_all).
  • victory-gpu: 272/272 passed (including a_write_into_one_page_uploads_its_rows_alone and mixed_pages_and_deferred_rows_reach_the_sampled_texture).
  • detile_the_rows_of_one_written_page_of_a_4k_bc7_texture (--release, 4096×4096 BC7 mip 0, 1 written 64 KiB page):
    • Whole mip: 1.591 ms
    • Touched rows (64 of 1024): 0.0678 ms (23.5x faster)

Live Title Verification (RX 9070 XT)

  • Setup: Local integration branch (main 63bcca4 + #2051 + #2472 + #2918 + #1010 + #2130 with VRAM upload flags off + #3055 + #2914), adding #2985 + #2849 + #3035 together in the same live run (n=54 world frames / n=38 heavy frames vs. n=51 / n=38 baseline).
  • Result: 0 crashes, 0 device removals, 0 visual texture artifacts through the intro and opening world scene.
  • Subsystem metrics (steady tail, last 20 heavy frames — 6,186 draws vs. 5,290 draws in baseline):
    • Texture uploads (fps log line): 9.4 ms / 11.8 MB/frame → 6.2 ms / 3.0 MB/frame (-34% time, -75% upload bandwidth)
    • bindless::uploads stage: median 24.9 → 20.9 ms (avg 30.1 → 25.2 ms)
  • Combined frame-time delta (all three PRs #2985 + #2849 + #3035 together): steady-tail frame time dropped 453.3 → 423.6 ms (2.20 → 2.40 fps), even with +17% more draws; the texture upload timers above isolate #2985's share cleanly from the watch.rs (prep → deferred / copy_back) gains.

Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.

**@⁠MeMako** on GitHub · 2026-11-26 06:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7184469823) Verified `#2985` (`cf6d7ee`) on AMD RDNA 4 (Windows 11 `10.0.26200`, Ryzen 9 7950X, RX 9070 XT, driver `32.0.32029.2010`, 32 GB RAM). ### Tests & Microbenchmark - `cargo clippy -p victory-formats -p victory-gpu --all-targets --locked -- -D warnings`: clean. - `victory-formats`: **47/47 passed** (including `detiling_the_touched_rows_matches_detiling_all`). - `victory-gpu`: **272/272 passed** (including `a_write_into_one_page_uploads_its_rows_alone` and `mixed_pages_and_deferred_rows_reach_the_sampled_texture`). - `detile_the_rows_of_one_written_page_of_a_4k_bc7_texture` (`--release`, 4096×4096 BC7 mip 0, 1 written 64 KiB page): - Whole mip: **1.591 ms** - Touched rows (64 of 1024): **0.0678 ms** (**23.5x faster**) ### Live Title Verification (RX 9070 XT) - **Setup:** Local integration branch (`main` `63bcca4` + `#2051` + `#2472` + `#2918` + `#1010` + `#2130` with VRAM upload flags off + `#3055` + `#2914`), adding `#2985` + `#2849` + `#3035` together in the same live run (`n=54` world frames / `n=38` heavy frames vs. `n=51` / `n=38` baseline). - **Result:** 0 crashes, 0 device removals, 0 visual texture artifacts through the intro and opening world scene. - **Subsystem metrics (steady tail, last 20 heavy frames — `6,186` draws vs. `5,290` draws in baseline):** - Texture uploads (`fps` log line): **9.4 ms / 11.8 MB/frame → 6.2 ms / 3.0 MB/frame** (**-34%** time, **-75%** upload bandwidth) - `bindless::uploads` stage: median **24.9 → 20.9 ms** (avg **30.1 → 25.2 ms**) - **Combined frame-time delta (all three PRs `#2985` + `#2849` + `#3035` together):** steady-tail frame time dropped **453.3 → 423.6 ms** (**2.20 → 2.40 fps**), even with +17% more draws; the texture upload timers above isolate `#2985`'s share cleanly from the `watch.rs` (`prep → deferred` / `copy_back`) gains. *Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.*
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 02:33 UTC · original · reviewed

Verified: touched_rows over-approximates a row's tiled byte span via the run extent [min start, max end), which is exact for packed layouts and conservative for padded ones — a hit between row extents yields an empty range and correctly detiles nothing. detile_rows keeps linear offsets at original y so the copy box maps staging rows 1:1 onto texture rows. The test is properly discriminating: one dirty page moves only its rows, untouched rows provably keep prior host content, and >50 genuinely-partial cases are asserted.

**@⁠kotekompotek** on GitHub · 2026-11-26 02:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#pullrequestreview-6067792012) · **reviewed** Verified: touched_rows over-approximates a row's tiled byte span via the run extent [min start, max end), which is exact for packed layouts and conservative for padded ones — a hit between row extents yields an empty range and correctly detiles nothing. detile_rows keeps linear offsets at original y so the copy box maps staging rows 1:1 onto texture rows. The test is properly discriminating: one dirty page moves only its rows, untouched rows provably keep prior host content, and >50 genuinely-partial cases are asserted.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 02:41 UTC · original · reviewed

Reviewed 632d05e1 against main (63bcca43) — row geometry, BC 4-texel Y-interval alignment, mip/slice bounds, and sorted disjoint dirty ranges look solid, but there are two subtle partial-upload data-corruption bugs worth fixing before merge:

  1. First upload can omit initialized rows in a partially tracked mip (crates/victory-gpu/src/texture.rs:588-636, watch.rs:331-365):

    • watch.rs allows tracking to cover only part of a texture's allocation. Because texture.rs:588-636 builds its row plan solely from tracked dirty ranges, if a mip overlaps at least one full tracked page (own(i) enables partial upload) alongside adjacent rows living on untracked pages, the first upload copies only the tracked rows and omits valid initialized data on the untracked pages (main uploaded the whole touched mip).
    • Falling back to the full-subresource upload path whenever a mip overlaps untracked memory (plus a mixed-coverage test) would prevent dropping untracked rows.
  2. A failed staging upload can leave rows permanently stale after a later write (crates/victory-gpu/src/texture.rs:594, 681-685):

    • Dirty pages are consumed at line 594 before staging succeeds, while the staging-failure path at 681-685 only clears hashes.
    • If staging fails while page A is dirty, and later page B of the same mip becomes dirty, the subsequent upload copies only B's rows, leaving A's rows stale (on main, B's upload re-copied the full mip and healed A).
    • Preserving failed dirty ranges for retry (or marking the affected subresource for a full upload on the next attempt) closes that gap.

(Minor test note: the GPU test in crates/victory-gpu/src/draw.rs:3152-3202 uses RGBA8 and counts subresources, which a full-mip upload could also satisfy — adding a BC GPU test verifying partial copy bounds would lock in the 4×4 block-aligned copy path.)

**@⁠fuzeofficlal** on GitHub · 2026-11-26 02:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#pullrequestreview-6067843348) · **reviewed** Reviewed `632d05e1` against `main` (`63bcca43`) — row geometry, BC 4-texel Y-interval alignment, mip/slice bounds, and sorted disjoint dirty ranges look solid, but there are **two subtle partial-upload data-corruption bugs** worth fixing before merge: 1. **First upload can omit initialized rows in a partially tracked mip (`crates/victory-gpu/src/texture.rs:588-636`, `watch.rs:331-365`)**: - `watch.rs` allows tracking to cover only part of a texture's allocation. Because `texture.rs:588-636` builds its row plan solely from tracked dirty ranges, if a mip overlaps at least one full tracked page (`own(i)` enables partial upload) alongside adjacent rows living on untracked pages, the first upload copies only the tracked rows and omits valid initialized data on the untracked pages (`main` uploaded the whole touched mip). - Falling back to the full-subresource upload path whenever a mip overlaps untracked memory (plus a mixed-coverage test) would prevent dropping untracked rows. 2. **A failed staging upload can leave rows permanently stale after a later write (`crates/victory-gpu/src/texture.rs:594, 681-685`)**: - Dirty pages are consumed at line `594` before staging succeeds, while the staging-failure path at `681-685` only clears hashes. - If staging fails while page A is dirty, and later page B of the same mip becomes dirty, the subsequent upload copies only B's rows, leaving A's rows stale (on `main`, B's upload re-copied the full mip and healed A). - Preserving failed dirty ranges for retry (or marking the affected subresource for a full upload on the next attempt) closes that gap. *(Minor test note: the GPU test in `crates/victory-gpu/src/draw.rs:3152-3202` uses RGBA8 and counts subresources, which a full-mip upload could also satisfy — adding a BC GPU test verifying partial copy bounds would lock in the 4×4 block-aligned copy path.)*
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 06:13 UTC · original · approved these changes

Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • Diff review: Computing the touched row band per subresource from tracked dirty page ranges, detiling only those rows, and issuing bounded CopyTextureRegion boxes cleanly avoids full-texture detiles/uploads for partial tracked writes (#1135).
  • cargo test -p victory-formats texture: 17 passed, 0 failed (including detiling_the_touched_rows_matches_detiling_all).
  • cargo test -p victory-gpu texture::tests -- --test-threads=1: 2 passed, 0 failed.
  • cargo test -p victory-gpu tracked_rows -- --test-threads=1 (RTX 5090 & WARP): 1 passed, 0 failed on both (mixed_pages_and_deferred_rows_reach_the_sampled_texture).
  • cargo clippy -p victory-formats -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 06:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#pullrequestreview-6069352498) · **approved these changes** Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP): - Diff review: Computing the touched row band per subresource from tracked dirty page ranges, detiling only those rows, and issuing bounded `CopyTextureRegion` boxes cleanly avoids full-texture detiles/uploads for partial tracked writes (#1135). - `cargo test -p victory-formats texture`: 17 passed, 0 failed (including `detiling_the_touched_rows_matches_detiling_all`). - `cargo test -p victory-gpu texture::tests -- --test-threads=1`: 2 passed, 0 failed. - `cargo test -p victory-gpu tracked_rows -- --test-threads=1` (RTX 5090 & WARP): 1 passed, 0 failed on both (`mixed_pages_and_deferred_rows_reach_the_sampled_texture`). - `cargo clippy -p victory-formats -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 09:18 UTC · original

Added a GPU test for the block-compressed case you mentioned (block_compressed_rows_keep_their_block_alignment_across_pages, next to the existing tracked-rows test, commit aca9f15): a 64-wide BC1 texture over three pages, in both the mixed and the tracked pool. It checks that each page decodes to its own color, that a page rewritten in place (including a deferred upload) updates alone while the others keep their previous content, and that the subresource copy counts match. Ran on an RX 6750 XT: the new test and the rest of the victory-gpu suite pass (234 passed, 1 ignored) and clippy is clean with -D warnings. It does not measure how many rows a copy carries, only that the sampled result is right.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 09:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7187758383) Added a GPU test for the block-compressed case you mentioned (`block_compressed_rows_keep_their_block_alignment_across_pages`, next to the existing tracked-rows test, commit aca9f15): a 64-wide BC1 texture over three pages, in both the mixed and the tracked pool. It checks that each page decodes to its own color, that a page rewritten in place (including a deferred upload) updates alone while the others keep their previous content, and that the subresource copy counts match. Ran on an RX 6750 XT: the new test and the rest of the victory-gpu suite pass (234 passed, 1 ignored) and clippy is clean with `-D warnings`. It does not measure how many rows a copy carries, only that the sampled result is right.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 09:51 UTC · original · approved these changes

Re-reviewed at aca9f15a (including 91284ea9..aca9f15a). The follow-up commits cleanly address the untracked-page, deferred-staging retry (Tracked::retry), and BCn block-row alignment cases:

  • own(i) excludes subresources overlapping untracked pages so mixed tracked/untracked textures stay on the full-subresource hash path.
  • detile failure requeues taken pages via t.retry(&ranges) and clears last.hashes[i], preventing dropped page updates.
  • copies() scales element row ranges by staging.layout.desc.block.max(1) (clamped to f.Height) and falls back to None when the full subresource is touched; Layout::touched_rows / detile_rows preserve slice/3D depth alignment.

Verified locally on Windows 11 (RTX 5090 + WARP + VICTORY_D3D12_DEBUG=1, git merge-tree against 63bcca43 clean):

  • cargo clippy --workspace --all-targets [--all-features] -- -D warnings: clean; cargo xtask policy: 192 files ok
  • victory-formats: detiling_the_touched_rows_matches_detiling_all passed; release benchmark on 4096x4096 BC7 mip 0: 1.582 ms whole vs 57.7 us for 64 touched rows (rows 512..576, 1024 KiB read, 27.4x faster)
  • RTX 5090: texture:: + watch:: + tracked_rows:: + a_write_into_one_page_uploads_its_rows_alone — 20/20 passed
  • RTX 5090 + VICTORY_D3D12_DEBUG=1: tracked_rows:: + a_write_into_one_page_uploads_its_rows_alone — 3/3 passed (zero debug layer errors on BC1 block-row CopyTextureRegion boxes)
  • WARP (--features diagnostics, VICTORY_D3D12_WARP=1) + VICTORY_D3D12_DEBUG=1: 5/5 passed

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 09:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#pullrequestreview-6071872194) · **approved these changes** Re-reviewed at `aca9f15a` (including `91284ea9..aca9f15a`). The follow-up commits cleanly address the untracked-page, deferred-staging retry (`Tracked::retry`), and BCn block-row alignment cases: - `own(i)` excludes subresources overlapping `untracked` pages so mixed tracked/untracked textures stay on the full-subresource hash path. - `detile` failure requeues taken pages via `t.retry(&ranges)` and clears `last.hashes[i]`, preventing dropped page updates. - `copies()` scales element row ranges by `staging.layout.desc.block.max(1)` (clamped to `f.Height`) and falls back to `None` when the full subresource is touched; `Layout::touched_rows` / `detile_rows` preserve slice/3D depth alignment. Verified locally on Windows 11 (RTX 5090 + WARP + `VICTORY_D3D12_DEBUG=1`, `git merge-tree` against `63bcca43` clean): - `cargo clippy --workspace --all-targets [--all-features] -- -D warnings`: clean; `cargo xtask policy`: `192 files ok` - `victory-formats`: `detiling_the_touched_rows_matches_detiling_all` passed; release benchmark on 4096x4096 BC7 mip 0: `1.582 ms` whole vs `57.7 us` for 64 touched rows (`rows 512..576`, 1024 KiB read, 27.4x faster) - RTX 5090: `texture::` + `watch::` + `tracked_rows::` + `a_write_into_one_page_uploads_its_rows_alone` — 20/20 passed - RTX 5090 + `VICTORY_D3D12_DEBUG=1`: `tracked_rows::` + `a_write_into_one_page_uploads_its_rows_alone` — 3/3 passed (zero debug layer errors on BC1 block-row `CopyTextureRegion` boxes) - WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`) + `VICTORY_D3D12_DEBUG=1`: 5/5 passed LGTM.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 09:57 UTC · original

@⁠wwwwwwww3333333 I measured the row counts left open in your BC1 test update. On aca9f15a, changing the middle tracked page issued a single D3D12 copy with top=1024, bottom=2048. That is exactly 256 BC1 block rows out of 768. Both the RTX 5080 and Windows WARP recorded the same copy.

Change to the 64 × 3072 texture Copy recorded on each adapter
Middle page rewritten in the fully tracked allocation Texel rows 1024–2047 only
First, ordinary-memory page rewritten in the mixed allocation All 3072 rows
First and last tracked pages changed across a deferred upload All 3072 rows
Repeat submission with no further changes, in either allocation No copy

I logged the source box at the production CopyTextureRegion call and kept the test’s original pixel and copy-count assertions. Two fresh processes per adapter, seven submissions per run. Each adapter returned 2,752,512 sampled pixels, zero mismatches. DXGI identified the RTX 5080 and the Microsoft Basic Render Driver. The D3D12 debug layer was enabled. AI-assisted instrumentation and write-up, using the synthetic fixture.

**@⁠steven-seagull27** on GitHub · 2026-11-26 09:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2985#issuecomment-7188713469) @⁠wwwwwwww3333333 I measured the row counts left open in [your BC1 test update](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2985). On `aca9f15a`, changing the middle tracked page issued a single D3D12 copy with `top=1024, bottom=2048`. That is exactly **256 BC1 block rows** out of 768. Both the RTX 5080 and Windows WARP recorded the same copy. | Change to the 64 × 3072 texture | Copy recorded on each adapter | |---|---| | Middle page rewritten in the fully tracked allocation | Texel rows 1024–2047 only | | First, ordinary-memory page rewritten in the mixed allocation | All 3072 rows | | First and last tracked pages changed across a deferred upload | All 3072 rows | | Repeat submission with no further changes, in either allocation | No copy | I logged the source box at the production `CopyTextureRegion` call and kept the test’s original pixel and copy-count assertions. Two fresh processes per adapter, seven submissions per run. Each adapter returned **2,752,512 sampled pixels, zero mismatches**. DXGI identified the RTX 5080 and the Microsoft Basic Render Driver. The D3D12 debug layer was enabled. AI-assisted instrumentation and write-up, using the synthetic fixture.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2985/head:github-bot/gh-2985'
git switch 'github-bot/gh-2985'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2985'
git switch 'github-bot/gh-2985'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2985'
git switch 'github-bot/gh-2985'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2985'
git switch 'main'
git merge --squash 'github-bot/gh-2985'
git switch 'main'
git merge --ff-only 'github-bot/gh-2985'
git switch 'main'
git merge 'github-bot/gh-2985'
git push origin 'main'
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!2985
No description provided.