Skip to content

GPU: copy-back reads into scratch sized to the changed stretch, not a zeroed 64 KiB per range - #240

Open
fffluffy-dev wants to merge 1 commit into
fxceless:mainfrom
fffluffy-dev:gpu/copy-back-scratch
Open

fffluffy-dev wants to merge 1 commit into
fxceless:mainfrom
fffluffy-dev:gpu/copy-back-scratch

Conversation

@fffluffy-dev

Copy link
Copy Markdown

Shadow::copy_back_with allocated and zeroed a 64 KiB scratch (vec![0u8; PIECE]) on every call, once per joined span, though it only reads the stretch from the first to the last changed byte of each differing piece. The merge moves into back_piece unchanged; the scratch now starts empty and is sized to each stretch, as card_merge already does.

Same bytes compared, read and written back as before; only the scratch changes. Every scratch byte used is first filled by read_into for exactly that stretch, and a failed read returns before the merge, as before.

Model of one submission (8 MiB copy, overlapping and repeated ranges): scratch bytes zeroed 40,763,392 (622 allocations) → 10,912 (171); bytes compared, pieces and bytes written back unchanged. Marvisak/VIctory#1656 found the same allocation before upstream redesigned Shadow.

Validation (cargo-xwin, tests under Wine): cargo test -p victory-gpu 111 passed, 1 ignored, new test a_piece_put_back_reads_only_its_stretch; clippy clean both ways; policy ok. On a real frame: "copying back" ms should fall at the same MB.

AI use: written with Claude Code (Claude Opus 5.5); reviewed and posted with my approval. No game files were used.

… zeroed 64 KiB per range

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant