Retry texture detiling after an incomplete conversion #419

Open
github-bot wants to merge 2 commits from github-bot/gh-419 into main AGit
Owner

@⁠feanorsun on GitHub · 2026-11-27 01:47 UTC · original
feanorsun:fix/retry-failed-texture-detile → main · +492 −153 · 3 files · 2 commits · open

Refs #358 (section 1, item 5).

Staging recorded the source digest before detiling the first mip. If a later mip failed, the next refresh could accept the same input as a cache hit. The write-watch path could also advance its watermark, and a caller reading the whole texture could still pass it to the texture store.

Commit the digest after the last subresource succeeds. A failed attempt clears the digest and write-watch watermark and leaves the upload pending. Check every footprint against the same bounds used by Layout::detile before writing or zeroing any mip. An earlier copy command can still reference the staging allocation, so preserving its bytes on failure matters even when the current prelude skips the upload. This requires no second texture-sized buffer.

The prelude and the optional ahead queue both skip a failed conversion. Other ready jobs in the ahead batch can proceed. Whole-texture persistence and the dirty flag are updated on success. Partly mapped, all-zero input is still ignored, and the 30-frame polling interval is unchanged. A retry uses the next eligible refresh under the existing scheduling rules.

UwUCammie found that a fully reserved source with no committed pages could skip detiling altogether and still complete an ahead job. This update adapts that finding to the upstream ahead queue and list prelude. Both require a previously completed staging conversion. The worker releases unready jobs, wakes list waiters, and copies the ready members of the batch. Only a successful copy releases success callbacks. An abandoned job stays silent when the normal list later stages the texture. UwUCammie’s report · AMD port and follow-up commit

Windows CPU verification

For the baseline run, I kept the upstream digest comparison and early assignment in Last::convert and ran the two new cache regressions against that version of the crate. The same-input case failed on its second request even after the destination grew from five to six bytes. The partial-replacement case failed at the assertion that the conversion was marked incomplete. Both assertions pass with this change.

The same-input case now makes two conversion attempts across three requests. A short destination fails, the full destination receives all six bytes, then the identical input is skipped. A separate two-mip case exercises the staging preflight and checks that a short second mip leaves all six previous bytes intact, including when the first mip would otherwise have been zeroed.

Listed the tests first, then ran each selected full name separately with --exact --test-threads=1. 12 passed, 0 failed (8 in victory-gpu, 4 in victory-formats). The inputs and destinations were small CPU buffers. The upload paths were traced in source. No GPU, game, or visual performance tests were run.

With the original !incomplete check from 3699879, the CPU batch test sent the never-converted job to the copy, and the prelude test claimed a first upload for the same state. Both now pass. The callback test injects skipped, failed, and successful copy outcomes into the worker’s batch logic and checks notifications registered before, during, and after completion.

AMD device results reported by UwUCammie

UwUCammie’s Wine/RADV run passed six Windows MSVC texture tests. Their Radeon fixture reserved the source with no committed pages, observed no completion callback, then committed the pages and staged the same texture through the regular path. AMD PR #48 and test notes

The 300-second cold-story run at 720p on an RX 7900 XT recorded 1,711 presents (5.70 FPS) with the AMD port. Two stock runs with matching flags and driver recorded 8.63 and 8.84 FPS. This comparison showed no speedup. The cause of the frame-rate difference remains undetermined. UwUCammie’s cold-run comparison

Targeted commands and selected tests
cargo test --offline --locked -j 1 -p victory-gpu --lib texture::ahead::tests:: -- --list
cargo test --offline --locked -j 1 -p victory-gpu --lib texture::detile_retry:: -- --list
cargo test --offline --locked -j 1 -p victory-gpu --lib texture::prelude_upload_tests:: -- --list
cargo test --offline --locked -j 1 -p victory-formats --lib texture::tests:: -- --list

$gpuTests = @(
    'texture::ahead::tests::only_converted_staging_can_finish_an_ahead_upload'
    'texture::ahead::tests::callbacks_require_a_completed_copy'
    'texture::detile_retry::unchanged_input_retries_a_failed_detile_then_skips_a_completed_one'
    'texture::detile_retry::a_partial_replacement_cannot_skip_restoring_the_last_complete_input'
    'texture::detile_retry::keeps_staging_intact_when_a_later_mip_is_short'
    'texture::detile_retry::failed_watched_conversion_preserves_the_pending_upload_for_a_retry'
    'texture::prelude_upload_tests::first_upload_clean_skip_and_immediate_same_frame_reupload'
    'texture::prelude_upload_tests::three_buffer_ring_never_displays_stale_frame'
)
foreach ($testName in $gpuTests) {
    cargo test --offline --locked -j 1 -p victory-gpu --lib $testName -- --exact --test-threads=1
}
$formatTests = @(
    'texture::tests::detile_preflight_matches_the_copy'
    'texture::tests::texture_copies_reject_overflowing_pitches'
    'texture::tests::depth_pitch_rejects_overlapping_detile'
    'texture::tests::depth_pitch_rejects_overlapping_tile'
)
foreach ($testName in $formatTests) {
    cargo test --offline --locked -j 1 -p victory-formats --lib $testName -- --exact --test-threads=1
}
**@⁠feanorsun** on GitHub · 2026-11-27 01:47 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/419) `feanorsun:fix/retry-failed-texture-detile` → `main` · +492 −153 · 3 files · 2 commits · open Refs #358 (section 1, item 5). Staging recorded the source digest before detiling the first mip. If a later mip failed, the next refresh could accept the same input as a cache hit. The write-watch path could also advance its watermark, and a caller reading the whole texture could still pass it to the texture store. Commit the digest after the last subresource succeeds. A failed attempt clears the digest and write-watch watermark and leaves the upload pending. Check every footprint against the same bounds used by `Layout::detile` before writing or zeroing any mip. An earlier copy command can still reference the staging allocation, so preserving its bytes on failure matters even when the current prelude skips the upload. This requires no second texture-sized buffer. The prelude and the optional ahead queue both skip a failed conversion. Other ready jobs in the ahead batch can proceed. Whole-texture persistence and the dirty flag are updated on success. Partly mapped, all-zero input is still ignored, and the 30-frame polling interval is unchanged. A retry uses the next eligible refresh under the existing scheduling rules. UwUCammie found that a fully reserved source with no committed pages could skip detiling altogether and still complete an ahead job. This update adapts that finding to the upstream ahead queue and list prelude. Both require a previously completed staging conversion. The worker releases unready jobs, wakes list waiters, and copies the ready members of the batch. Only a successful copy releases success callbacks. An abandoned job stays silent when the normal list later stages the texture. [UwUCammie’s report](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/419) · [AMD port and follow-up commit](https://github.com/jtrudeau1530/VIctory-7900XTX/pull/48/commits/4b6b0f9f75e4a5af06bf5cc789f6516121e364e8) ### Windows CPU verification For the baseline run, I kept the upstream digest comparison and early assignment in `Last::convert` and ran the two new cache regressions against that version of the crate. The same-input case failed on its second request even after the destination grew from five to six bytes. The partial-replacement case failed at the assertion that the conversion was marked incomplete. Both assertions pass with this change. The same-input case now makes two conversion attempts across three requests. A short destination fails, the full destination receives all six bytes, then the identical input is skipped. A separate two-mip case exercises the staging preflight and checks that a short second mip leaves all six previous bytes intact, including when the first mip would otherwise have been zeroed. Listed the tests first, then ran each selected full name separately with `--exact --test-threads=1`. **12 passed, 0 failed** (8 in `victory-gpu`, 4 in `victory-formats`). The inputs and destinations were small CPU buffers. The upload paths were traced in source. No GPU, game, or visual performance tests were run. With the original `!incomplete` check from `3699879`, the CPU batch test sent the never-converted job to the copy, and the prelude test claimed a first upload for the same state. Both now pass. The callback test injects skipped, failed, and successful copy outcomes into the worker’s batch logic and checks notifications registered before, during, and after completion. ### AMD device results reported by UwUCammie UwUCammie’s Wine/RADV run passed six Windows MSVC texture tests. Their Radeon fixture reserved the source with no committed pages, observed no completion callback, then committed the pages and staged the same texture through the regular path. [AMD PR #48 and test notes](https://github.com/jtrudeau1530/VIctory-7900XTX/pull/48#issuecomment-7208446315) The 300-second cold-story run at 720p on an RX 7900 XT recorded 1,711 presents (5.70 FPS) with the AMD port. Two stock runs with matching flags and driver recorded 8.63 and 8.84 FPS. This comparison showed no speedup. The cause of the frame-rate difference remains undetermined. [UwUCammie’s cold-run comparison](https://git.gtahub.st/github/avatarmanz--VIctory-7900XTX/pulls/419) <details> <summary>Targeted commands and selected tests</summary> ```powershell cargo test --offline --locked -j 1 -p victory-gpu --lib texture::ahead::tests:: -- --list cargo test --offline --locked -j 1 -p victory-gpu --lib texture::detile_retry:: -- --list cargo test --offline --locked -j 1 -p victory-gpu --lib texture::prelude_upload_tests:: -- --list cargo test --offline --locked -j 1 -p victory-formats --lib texture::tests:: -- --list $gpuTests = @( 'texture::ahead::tests::only_converted_staging_can_finish_an_ahead_upload' 'texture::ahead::tests::callbacks_require_a_completed_copy' 'texture::detile_retry::unchanged_input_retries_a_failed_detile_then_skips_a_completed_one' 'texture::detile_retry::a_partial_replacement_cannot_skip_restoring_the_last_complete_input' 'texture::detile_retry::keeps_staging_intact_when_a_later_mip_is_short' 'texture::detile_retry::failed_watched_conversion_preserves_the_pending_upload_for_a_retry' 'texture::prelude_upload_tests::first_upload_clean_skip_and_immediate_same_frame_reupload' 'texture::prelude_upload_tests::three_buffer_ring_never_displays_stale_frame' ) foreach ($testName in $gpuTests) { cargo test --offline --locked -j 1 -p victory-gpu --lib $testName -- --exact --test-threads=1 } $formatTests = @( 'texture::tests::detile_preflight_matches_the_copy' 'texture::tests::texture_copies_reject_overflowing_pitches' 'texture::tests::depth_pitch_rejects_overlapping_detile' 'texture::tests::depth_pitch_rejects_overlapping_tile' ) foreach ($testName in $formatTests) { cargo test --offline --locked -j 1 -p victory-formats --lib $testName -- --exact --test-threads=1 } ``` </details>
Commit the source digest and write-watch watermark after a successful detile. Validate all staging footprints before writing so an error in a later mip cannot change bytes referenced by an earlier upload. Keep failed conversions out of the prelude, the ahead queue and the whole-texture store.

Refs #358
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:15:42 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 02:03 UTC · original

I adapted this to the direct upload lists and heap worker on linux-amd-best in jtrudeau1530/VIctory-7900XTX#48. The 19 format texture tests pass on Linux and six focused Windows MSVC tests pass under Wine. That includes reprocessing the same digest after a failure and preserving the old staging bytes when a later mip is short. I still need a matched in-game comparison for the visual effect.

**@⁠UwUCammie** on GitHub · 2026-11-27 02:03 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/419#issuecomment-7207791229) I adapted this to the direct upload lists and heap worker on `linux-amd-best` in jtrudeau1530/VIctory-7900XTX#48. The 19 format texture tests pass on Linux and six focused Windows MSVC tests pass under Wine. That includes reprocessing the same digest after a failure and preserving the old staging bytes when a later mip is short. I still need a matched in-game comparison for the visual effect.
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 02:50 UTC · original

I tested one more ahead-queue case from the AMD port. A fully reserved source with no committed pages can skip conversion entirely, so the ahead queue now waits for a successful staging conversion. The Radeon fixture kept the completion callback silent while the pages were absent, then staged the same texture after commit. That adjacent case is in the updated AMD PR, with six focused Windows MSVC tests passing on RADV under Wine. Patch and test notes

**@⁠UwUCammie** on GitHub · 2026-11-27 02:50 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/419#issuecomment-7208477193) I tested one more ahead-queue case from the AMD port. A fully reserved source with no committed pages can skip conversion entirely, so the ahead queue now waits for a successful staging conversion. The Radeon fixture kept the completion callback silent while the pages were absent, then staged the same texture after commit. That adjacent case is in the updated AMD PR, with six focused Windows MSVC tests passing on RADV under Wine. [Patch and test notes](https://github.com/jtrudeau1530/VIctory-7900XTX/pull/48#issuecomment-7208446315)
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-27 04:37 UTC · original

I finished a 300 s cold-story run of the AMD adapter on RX 7900 XT at 720p. It accepted 1,711 presents (5.70 FPS), below both stock launches with matching flags and driver (8.63 and 8.84 FPS). The focused tests still cover the original retry bug. The cold run gives no reason to promote this as a speedup. Run and branch details

**@⁠UwUCammie** on GitHub · 2026-11-27 04:37 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/419#issuecomment-7209958998) I finished a 300 s cold-story run of the AMD adapter on RX 7900 XT at 720p. It accepted 1,711 presents (5.70 FPS), below both stock launches with matching flags and driver (8.63 and 8.84 FPS). The focused tests still cover the original retry bug. The cold run gives no reason to promote this as a speedup. [Run and branch details](https://github.com/UwUCammie/victory-amd/commit/1898f851)
A reserved source can skip detiling altogether. Track successful conversion explicitly so neither the ahead worker nor the list prelude claims an unfilled buffer. Exercise mixed batches, fallback retries and completion callbacks without a device.

Thanks to UwUCammie for finding the uncommitted-page case and testing the AMD port in commit 4b6b0f9f. This adapts the readiness check and adds CPU coverage for the upstream queues.

AMD port: https://github.com/jtrudeau1530/VIctory-7900XTX/pull/48

Refs #358
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/419/head:github-bot/gh-419'
git switch 'github-bot/gh-419'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-419'
git switch 'github-bot/gh-419'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-419'
git switch 'github-bot/gh-419'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-419'
git switch 'main'
git merge --squash 'github-bot/gh-419'
git switch 'main'
git merge --ff-only 'github-bot/gh-419'
git switch 'main'
git merge 'github-bot/gh-419'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.