Preserve lowest from offset in shadow::joined_piece_runs #453

Closed
ahmetbagci8 wants to merge 660 commits from upstream-pr/453 into main
ahmetbagci8 commented 2026-11-29 18:17:09 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by ahmetbagci8 on 2026-11-29T18:17:09Z.


Problem

In crates/victory-gpu/src/shadow.rs, joined_piece_runs sorts
uns only by
.first and updates last.to = last.to.max(run.to) without updating last.from. When two CardSpans start in the same 64 KiB piece (
un.first == last.first) and the one with the larger rom offset appears first, merging drops [run.from, last.from).

Fix

Sort by (r.first, r.from) and update last.from = last.from.min(run.from) when merging runs. Added unit test joined_piece_runs_preserves_lowest_from_in_same_piece.

Verification

  • cargo test -p victory-gpu --lib joined_piece_runs_preserves_lowest_from_in_same_piece (1 passed, 0 failed)
  • cargo clippy -p victory-gpu --tests (0 warnings)
<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5553657694 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/453). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-11-29T18:17:09Z. --- ## Problem In crates/victory-gpu/src/shadow.rs, joined_piece_runs sorts uns only by .first and updates last.to = last.to.max(run.to) without updating last.from. When two CardSpans start in the same 64 KiB piece ( un.first == last.first) and the one with the larger rom offset appears first, merging drops [run.from, last.from). ## Fix Sort by (r.first, r.from) and update last.from = last.from.min(run.from) when merging runs. Added unit test joined_piece_runs_preserves_lowest_from_in_same_piece. ## Verification - cargo test -p victory-gpu --lib joined_piece_runs_preserves_lowest_from_in_same_piece (1 passed, 0 failed) - cargo clippy -p victory-gpu --tests (0 warnings)
TaynanGT commented 2026-11-29 19:09:17 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:09:17Z.


Thanks for catching the lost low offset. Sorting by both piece and byte offset and retaining the minimum from fixes the demonstrated same-piece case. Please keep coverage for reversed input and adjacent or overlapping multi-piece runs, including their final byte bounds.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7261051816 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/453#issuecomment-7261051816). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:09:17Z. --- Thanks for catching the lost low offset. Sorting by both piece and byte offset and retaining the minimum from fixes the demonstrated same-piece case. Please keep coverage for reversed input and adjacent or overlapping multi-piece runs, including their final byte bounds.
TaynanGT commented 2026-11-30 17:05:54 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:05:54Z.


main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285714677 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/453#issuecomment-7285714677). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-30T17:05:54Z. --- `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
TaynanGT/Vice-Tay!453
No description provided.