native: texture copy-back fixes and cost counters #453
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!453
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-449"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lautarocherro on GitHub · 2026-11-27 19:55 UTC · original
lautarocherro:feat/texture-back-default→main· +130 −9 · 6 files · 2 commits · closed without mergingWhat this changes
Refs #46. Built on #451 (its commit is the first here); review the last commit. First proposed as copy-back on by default; rescoped after a world run (below) showed the cost.
VICTORY_TEXTURE_BACK=1.read_textureskips it with no error) no longer writes zeros into title memory:downloadchecks the read happened (read_checked) and logs the texture as not copied back.textures copied back so farline gives copies, checks, KiB and microseconds.World run (M5 Pro, Series X, headless 480 s, switch on): 220 textures copied 9,320 times, 5.1 GiB, 44.9 s under the title lock (about 170 ms a world frame). 183 are over 8 KiB, mostly screen-sized intermediates. No copy wrote over another known texture or buffer. Turning it on needs a way to copy only what the title reads; docs/native-host.md and ROADMAP say so.
How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: 391 passed.cargo test -p victory-gpu(native arm64): 415 passed, with the switch unset and with=1. New:read_checked, copy-back off keeps title memory, counters in the copy-back test.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: passes.Checklist
VICTORY_*variable and documented (the cost line prints only withVICTORY_TEXTURE_BACK=1)@derz92 on GitHub · 2026-11-27 21:06 UTC · original
Evidence for copy-back, from #441's tree (
b998bb65+ #441) on an M5 Max, 36 GB, macOS 26.5, Series S, mode 1. Main's opt-inVICTORY_TEXTURE_BACK=1behaves the same as this PR's default.WaitForSingleObjectand two title threads busy. (The cold run got past it, probably just by being slower.)info.size > min(env, BACK_LIMIT)inwrite_back): 51 copied, 214 skipped as larger. The cutscene still plays through to the title's "move around / move the camera" prompt (frame about 1980), and the image is clean, with no speckle or streaks. The small ones copied were things like 1x1 format 3 (256 B), 54x30, 27x15 and 20x12 format 42, and 10x6 format 2.So on this title, the stall needs only small GPU results back, and writing back the large textures is what corrupts the image. Maybe a tiled layout that doesn't match, or the title reusing that memory. Copying everything by default would trade the stall for the noise. A size or kind limit, or finding which large textures go wrong, could keep both. I haven't yet narrowed down which large texture causes the noise; I can bisect by size if that helps.
@derz92 on GitHub · 2026-11-27 22:16 UTC · original
A correction to my comment above. The stall I credited copy-back with fixing doesn't depend on it. In a controlled run on one binary, alternating copy-back on and off (3 each, details on #460), none of the six runs froze. So "the stall needs small GPU results back" doesn't hold up. What still stands: the one run with full copy-back showed blocky pink and green noise that the same scene without it doesn't have. That's one run, though, so treat it as a lead, not a result.
native: copy GPU-written textures back by defaultto native: texture copy-back fixes and cost countersd09f16dd23to3031622dfd@Olima34 on GitHub · 2026-11-28 00:42 UTC · original · requested changes
Thanks @lautarocherro. We read the whole diff (
3031622d) while helping the maintainer clear the queue, and it holds up: keeping copy-back opt-in,read_checkedso a refused read no longer writes zeros into title memory, dropping a released queue's fence, and the cost counters, with tests for each. The world-run numbers in docs and ROADMAP are useful too.The only blocker: the maintainer just landed another batch on main (
226645f9), and this branch now conflicts with it indocs/native-host.md. Could you merge currentmaininto the branch (a merge commit is fine) and keep both sides of that paragraph? Once GitHub shows it as mergeable and CI is green on the new head, we'll merge it.@Olima34 on GitHub · 2026-11-28 00:46 UTC · original
The maintainer is handling this one himself; please follow his lead rather than my review.
@lautarocherro on GitHub · 2026-11-28 06:25 UTC · original
Merged current main (
bf9cdf17) into the branch incd1848c5. The conflict indocs/native-host.mdkeeps both sides: this PR's copy-back bullets and main's "Not into a pool the view left (#340)" bullet. CI passes on the new head, and GitHub shows the PR as mergeable.Pull request closed