Formats: reserve texture metadata memory in XG layouts #263

Closed
github-bot wants to merge 1 commit from gh-pr/263/head into gh-pr/263/base
Owner

@⁠Quat3rnion on GitHub · 2026-11-24 01:53 UTC · original
Quat3rnion:victory-texture-metadata → main · +137 −12 · 2 files · 1 commits · closed without merging

What

Render targets and depth buffers carry compression metadata (HTILE, CMASK,
DCC) on the console. The XG layout reported only the data planes, so a title
that sized a pool from it could run out of memory. This adds a conservative
metadata reservation after the data planes in the reported size and
alignment.

The exact metadata plane shapes depend on the GPU's pipe configuration and
their XG usage codes are not published. Rather than invent plane types that
a title might try to copy from, this reserves upper-bound memory (one eighth
of the data for depth, one sixteenth for color, rounded to 64 KiB) and leaves
the plane list and the host's data-plane layout unchanged. Sampled textures
get no reservation.

An AI tool wrote part of this change.

Tested

  • Linux: cargo test --workspace with PR #112's Linux build fix applied locally (not part of this PR): 167 passed, 0 failed, 3 ignored. Three new tests cover sampled versus render targets, offset/overflow behaviour and the XG layout output.
  • Windows cross-build: cargo check --target x86_64-pc-windows-gnu --workspace --tests passes. Windows-only tests were not run; there is no Windows host here.
  • cargo xtask policy passes (150 files ok). No game files or data from them were added.
  • Not tested: a real title or console GPU. If the title expects distinct metadata planes rather than a larger total, this change does not supply them.

Checklist

  • cargo fmt on the changed hunks; workspace tests and Windows cross-check pass.
  • cargo xtask policy passes. No game files or data from them were added.
  • AI authorship is disclosed above.
**@⁠Quat3rnion** on GitHub · 2026-11-24 01:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/263) `Quat3rnion:victory-texture-metadata` → `main` · +137 −12 · 2 files · 1 commits · closed without merging ## What Render targets and depth buffers carry compression metadata (HTILE, CMASK, DCC) on the console. The XG layout reported only the data planes, so a title that sized a pool from it could run out of memory. This adds a conservative metadata reservation after the data planes in the reported size and alignment. The exact metadata plane shapes depend on the GPU's pipe configuration and their XG usage codes are not published. Rather than invent plane types that a title might try to copy from, this reserves upper-bound memory (one eighth of the data for depth, one sixteenth for color, rounded to 64 KiB) and leaves the plane list and the host's data-plane layout unchanged. Sampled textures get no reservation. An AI tool wrote part of this change. ## Tested - Linux: `cargo test --workspace` with PR #112's Linux build fix applied locally (not part of this PR): 167 passed, 0 failed, 3 ignored. Three new tests cover sampled versus render targets, offset/overflow behaviour and the XG layout output. - Windows cross-build: `cargo check --target x86_64-pc-windows-gnu --workspace --tests` passes. Windows-only tests were not run; there is no Windows host here. - `cargo xtask policy` passes (150 files ok). No game files or data from them were added. - Not tested: a real title or console GPU. If the title expects distinct metadata planes rather than a larger total, this change does not supply them. ## Checklist - [x] `cargo fmt` on the changed hunks; workspace tests and Windows cross-check pass. - [x] `cargo xtask policy` passes. No game files or data from them were added. - [x] AI authorship is disclosed above.
Render targets and depth buffers carry compression metadata on the console. Report an upper-bound reservation after the data planes in XG layouts so titles do not undersize pools. Keep the host's data-plane layout unchanged and avoid inventing metadata plane types whose usage codes are not published. Add unit tests for the sizing and the layout output.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:57:08 +00:00
github-bot closed this pull request 2026-11-26 03:57:08 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:01 UTC · original

Tested the open PR at head 50d27a5a9237aaf00fee8090fc236e0358a90f2f (still current when refreshed before posting).

  • cargo test --locked -p victory-formats metadata_ — passed metadata_reserves_room_only_for_render_targets and metadata_never_overlaps_or_overflows, covering sampled versus render-target reservations, 1D handling, alignment and overflow bounds in texture.rs.
  • cargo test --locked -p victory-hle render_targets_reserve_metadata_memory — passed render_targets_reserve_metadata_memory, exercising the XG layout response for color/depth size and alignment while checking data-plane count in xg.rs.

These are synthetic unit tests; a real title or console GPU was not exercised.

**@⁠jeremygold02** on GitHub · 2026-11-24 04:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/263#issuecomment-7121638689) Tested the open PR at head `50d27a5a9237aaf00fee8090fc236e0358a90f2f` (still current when refreshed before posting). - `cargo test --locked -p victory-formats metadata_` — passed `metadata_reserves_room_only_for_render_targets` and `metadata_never_overlaps_or_overflows`, covering sampled versus render-target reservations, 1D handling, alignment and overflow bounds in [texture.rs](https://github.com/Marvisak/VIctory/blob/50d27a5a9237aaf00fee8090fc236e0358a90f2f/crates/victory-formats/src/texture.rs). - `cargo test --locked -p victory-hle render_targets_reserve_metadata_memory` — passed `render_targets_reserve_metadata_memory`, exercising the XG layout response for color/depth size and alignment while checking data-plane count in [xg.rs](https://github.com/Marvisak/VIctory/blob/50d27a5a9237aaf00fee8090fc236e0358a90f2f/crates/victory-hle/src/modules/xg.rs). These are synthetic unit tests; a real title or console GPU was not exercised.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:01 UTC · original

Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/263#issuecomment-7148045052) Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!263
No description provided.