native: texture copy-back fixes and cost counters #449
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by lautarocherro on 2026-11-27T19:55:53Z.
What this changes
Refs #46. Built on #447 (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)Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T21:06:16Z.
Evidence for copy-back, from #437's tree (
b998bb65+ #437) 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.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T22:16:50Z.
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 #456), 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.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:42:42Z.
Review: CHANGES_REQUESTED
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:46:58Z.
The maintainer is handling this one himself; please follow his lead rather than my review.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by lautarocherro on 2026-11-28T06:25:17Z.
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 (#339)" bullet. CI passes on the new head, and GitHub shows the PR as mergeable.Pull request closed