Proposal: make host textures only for the mip levels the title has mapped (levels on demand), after measuring it #462

Open
opened 2026-11-27 21:03:18 +00:00 by github-bot · 5 comments
Owner

@⁠Hayyan612 on GitHub · 2026-11-27 21:00 UTC · original

Mip-streamed textures are placed in a reservation and their levels mapped as they stream in, tail first and level 0 last (texture_tests::streamed_mips_across_scattered_pool_pages_upload_each_step_without_whole_rereads). Uploads already follow that step by step. But the host texture seems to be made with the whole chain from the start, so a level the title has not mapped yet still takes host memory. Level 0 alone is about 73% of a texture's.

ScarlettPort (ZigZagBoi1/ScarlettPort#64) makes host textures level by level as the title fills them. On an RX 9060 XT: median frame 18.9 → 22.0 fps, 90th percentile 92–160 ms → 75 ms, texture passes that found no room 2,839 → 48, with 19,900 host copies alive in 4.8 GB where 12,000 had taken 5.2 GB. They note that system RAM did not drop there, because staging grew. On Apple's unified memory the host copies are system memory, so the saving should count in full.

Measure first. A diagnostic, off by default (VICTORY_TRACE_UNMAPPED_LEVELS=1): every N submissions, log the host bytes of texture levels whose title pages are all unmapped, total and per format. If testers' world runs show that it is large, then:

Then. Make a mip-streamed texture's host copy with only its mapped levels, through the same host_mip_range mapping the top-mip drop (#349/#348) uses for views, and remake it with the next level when the title maps one. Metal sparse textures (heap-backed tiles following the title's page mappings) would be the other way, without the remake; Apple GPUs support them.

Not claiming the change. I can write the diagnostic, with a test on the streamed-mips fixture, if it is wanted.

**@⁠Hayyan612** on GitHub · 2026-11-27 21:00 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458) Mip-streamed textures are placed in a reservation and their levels mapped as they stream in, tail first and level 0 last (`texture_tests::streamed_mips_across_scattered_pool_pages_upload_each_step_without_whole_rereads`). Uploads already follow that step by step. But the host texture seems to be made with the whole chain from the start, so a level the title has not mapped yet still takes host memory. Level 0 alone is about 73% of a texture's. ScarlettPort (ZigZagBoi1/ScarlettPort#64) makes host textures level by level as the title fills them. On an RX 9060 XT: median frame 18.9 → 22.0 fps, 90th percentile 92–160 ms → 75 ms, texture passes that found no room 2,839 → 48, with 19,900 host copies alive in 4.8 GB where 12,000 had taken 5.2 GB. They note that system RAM did not drop there, because staging grew. On Apple's unified memory the host copies are system memory, so the saving should count in full. **Measure first.** A diagnostic, off by default (`VICTORY_TRACE_UNMAPPED_LEVELS=1`): every N submissions, log the host bytes of texture levels whose title pages are all unmapped, total and per format. If testers' world runs show that it is large, then: **Then.** Make a mip-streamed texture's host copy with only its mapped levels, through the same `host_mip_range` mapping the top-mip drop (#349/#348) uses for views, and remake it with the next level when the title maps one. Metal sparse textures (heap-backed tiles following the title's page mappings) would be the other way, without the remake; Apple GPUs support them. Not claiming the change. I can write the diagnostic, with a test on the streamed-mips fixture, if it is wanted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:03:18 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 22:07 UTC · original

/claim

Taking the measure-first step only: VICTORY_TRACE_UNMAPPED_LEVELS=1 logging, every N submissions, the host bytes of texture levels whose title pages are all unmapped (total and per format). No behaviour change; the levels-on-demand remake stays for after the measurement.

**@⁠AnastasisKon** on GitHub · 2026-11-27 22:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7229053951) /claim Taking the measure-first step only: VICTORY_TRACE_UNMAPPED_LEVELS=1 logging, every N submissions, the host bytes of texture levels whose title pages are all unmapped (total and per format). No behaviour change; the levels-on-demand remake stays for after the measurement.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-27 22:08 UTC · original

Claimed by @⁠AnastasisKon. Open a draft pull request with Refs #458 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-27 22:08 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7229056565) Claimed by @⁠AnastasisKon. Open a draft pull request with `Refs #458` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 21:07 UTC · original

/release

**@⁠AnastasisKon** on GitHub · 2026-11-28 21:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7245788726) /release
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 21:07 UTC · original

Releasing the claim: the remaining step on #462 is the measurement itself — world runs with VICTORY_TRACE_UNMAPPED_LEVELS=1 to see whether the unmapped-level host bytes are large enough to justify the levels-on-demand remake. The full game data (~137 GB at /Volumes/Anastasis' SSD/GTA6.Xbox.v1.0.2.1-CYBERLEEK) is still downloading on this machine, so no in-game numbers can be produced here yet; the diagnostic itself has landed (PR #500) and is ready for anyone with a complete install to run. The unit-test issues stay claimed — none of them need a game run.

**@⁠AnastasisKon** on GitHub · 2026-11-28 21:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7245789029) Releasing the claim: the remaining step on #462 is the measurement itself — world runs with VICTORY_TRACE_UNMAPPED_LEVELS=1 to see whether the unmapped-level host bytes are large enough to justify the levels-on-demand remake. The full game data (~137 GB at /Volumes/Anastasis' SSD/GTA6.Xbox.v1.0.2.1-CYBERLEEK) is still downloading on this machine, so no in-game numbers can be produced here yet; the diagnostic itself has landed (PR #500) and is ready for anyone with a complete install to run. The unit-test issues stay claimed — none of them need a game run.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 21:07 UTC · original

Released. This issue is free to claim.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 21:07 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7245790558) Released. This issue is free to claim.
This discussion has been locked. Commenting is limited to contributors.
No description provided.