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

Open
opened 2026-11-27 21:00:49 +00:00 by Hayyan612 · 5 comments
Hayyan612 commented 2026-11-27 21:00:49 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Hayyan612 on 2026-11-27T21:00:49Z.


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 (#347/#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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6654404031 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458). Originally posted by [Hayyan612](https://github.com/Hayyan612) on 2026-11-27T21:00:49Z. --- 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 (#347/#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.
AnastasisKon commented 2026-11-27 22:07:51 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-27T22:07:51Z.


/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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229053951 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7229053951). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-27T22:07:51Z. --- /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.
github-actions[bot] commented 2026-11-27 22:08:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T22:08:02Z.


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7229056565 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7229056565). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T22:08:02Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #458` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-28 21:07:27 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T21:07:27Z.


/release

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245788726 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7245788726). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T21:07:27Z. --- /release
AnastasisKon commented 2026-11-28 21:07:28 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T21:07:28Z.


Releasing the claim: the remaining step on #458 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 #496) and is ready for anyone with a complete install to run. The unit-test issues stay claimed — none of them need a game run.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245789029 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7245789029). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T21:07:28Z. --- Releasing the claim: the remaining step on #458 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 #496) and is ready for anyone with a complete install to run. The unit-test issues stay claimed — none of them need a game run.
github-actions[bot] commented 2026-11-28 21:07:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T21:07:36Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7245790558 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/458#issuecomment-7245790558). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T21:07:36Z. --- Released. This issue is free to claim.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS#458
No description provided.