Textures the GPU writes and the title reads on the CPU must go back to title memory (water simulation; boats sink otherwise) #46
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 64bitMango on 2026-11-26T11:17:54Z.
From the Windows forks of the same build (1.0.2.1); worth planning for in the Metal backend's texture model.
What happens. The ocean's height and displacement maps are textures that compute passes write and the title's physics samples on the CPU. If the layer never copies them back into title memory, the CPU reads zeros: boats sink, the sea plane goes under, and the first boat mission fails. With the read-back, boats stay up through whole runs (avatarmanz/VIctory-7900XTX
docs/findings.md; fix by Geckomacabre, fxceless/victory-fork pull request #999,VICTORY_TEXTURE_BACK, on by default in avatarmanz's tree).Why it matters more natively. Even with title memory mapped straight into
MTLBuffers, textures live in Metal's own (twiddled) layouts, so a GPU write to a texture is not visible in the title's linear/tiled bytes. Textures the title reads back need an explicit copy and re-tiling into title memory after the GPU writes them, at least for those it is known to read (found by a CPU read fault on the texture's pages, as the forks do).Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T13:28:27Z.
Thanks for flagging this early, @64bitMango — good catch to keep on the radar before 3D world rendering and physics are active.
Because Metal textures use private/twiddled layouts even when title pools are zero-copy mapped as
MTLBuffers, GPU-written textures that the CPU samples (like the ocean height/displacement maps) will need an explicit readback + re-tiling path into title memory. Addedbugandhelp wantedlabels.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T15:56:59Z.
Status: not started. Matters once the world runs (see #15). Still open and up for grabs.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T17:16:15Z.
@Olima34, assigning this to you as well, lower priority than #4 and #43. It needs a way to find textures the GPU writes that the title then reads on the CPU, and a copy back into title memory after the GPU writes. Happy to discuss the design here before code.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T17:22:47Z.
Design proposal, for discussion before any code. Facts are from current main.
What exists
native/memory.rs,docs/native-host.md: "host textures never go back to title memory").victory_formats::Layout::tileshareswalkwithdetile, so it covers the same layouts. Its only caller today is XG.StorageModeShared, andResourceBackend::read_texture(getBytesof a mip) exists.glue::refresh(the 1 ms host thread, thenfence::raise) and the title's ownGetCompletedValue/SetEventOnCompletionpolls (fence.rs).TextureInfo.flags(RT 1 / DS 2 / UA 4) plus the bound targets andView::Unorderedat draw or dispatch time.Proposal, in three small PRs
VICTORY_TRACE_GPU_WRITTEN, off by default). At each draw or dispatch, record the texture keys bound as RT/DS or as UAV. Per submission, log each written texture once: key, format, size, swizzle mode, flags, and the submission's fence value. You run it on a story or world load and tell us which keys are the ocean maps (small, UAV, written every frame by compute). That gives us real data instead of a guess.read_texturefor each mip and slice;Layout::tileinto title memory;Ordering: the title can only read after it sees the fence, so the bytes are there in time. Unsupported layouts (
SW_4KB_R_X, MSAA, 96-bit) are logged once and skipped.MTLBufferat the end of the submission. It is ordered on the GPU and costs no CPU, and it is the same addressing as the planned compute detile (docs/metal-backend.md).What I'd rather not do: detect CPU reads with
PROT_NONEguards. The native host has no page protection. It would cost a fault per first touch per frame and hit the Rosetta masked-store problemwatch.rsdocuments. Picking the set from step 1 avoids it.Questions
If this looks right, I'll start with step 1.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T18:11:46Z.
@Olima34 The plan looks right; please start with step 1. A size cap is fine as the first rule, as long as step 1 logs the keys so we can check it against real data. We don't know yet whether the title waits on a fence before the physics reads the maps, but as you say, step 2 works either way.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by lautarocherro on 2026-11-27T19:48:31Z.
/claim
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T19:48:48Z.
Claimed by @lautarocherro. Open a draft pull request with
Refs #46in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by lautarocherro on 2026-11-29T02:25:40Z.
/release
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-29T02:25:49Z.
Released. This issue is free to claim.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-29T09:07:05Z.
/claim
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-29T09:07:22Z.
Claimed by @AnastasisKon. Open a draft pull request with
Refs #46in its description within 24 hours, or the claim expires.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-29T09:10:03Z.
Status after claiming and investigating: the implementation this issue asked for is already on main — the fence-driven copy-back behind VICTORY_TEXTURE_BACK=1 (textures.rs: Title::copy_back/write_back, retile through Back, the freed-range and left-pool skips of #339, BACK_LIMIT, render-target exclusion), documented in docs/native-host.md and ROADMAP. Credit to whoever landed it; nothing about the mechanism is missing.
What remains, per ROADMAP, is run evidence past the M5 Pro crash ('22 textures named, then crashes before boats can be seen'). From this machine (M3 Pro, current main bf64dc4e, headless run of 2026-11-29): the run never reaches textures at all — it dies at 3.4 s on the SGD5 shader-database int3 at image+0x141330a44, the boot blocker of docs/native-host.md, before a DirectStorage queue even exists. So the run evidence this issue needs is gated on solving that blocker first, which is the repo's standing item 3.
Releasing the claim: the remaining work here is blocked on the boot blocker, and whoever solves that (or runs on a machine past it) should take the verification run with VICTORY_TEXTURE_BACK=1.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-29T09:10:04Z.
/release
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-29T09:10:20Z.
Released. This issue is free to claim.