vkback: probe whether linear mip layouts can be reused in place #137

Closed
github-bot wants to merge 1 commit from github-bot/gh-137 into main AGit
Owner

@⁠TheRifai on GitHub · 2026-12-01 20:29 UTC · original
TheRifai:mip-linear-probe → main · +75 −25 · 4 files · 1 commits · closed without merging

What

Mips are the largest single reason a console-linear texture takes a copying image (PR #129: 44,489 boat / 34,522 house attempts). The console packs linear mips smallest first and pads rows to 256 bytes (frame::tiling::linear); a Vulkan linear image with a mip chain has its own per-level layout. This adds a read-only probe — one image creation per distinct (format, width, height, mip count) — that compares each level's offset and row pitch with the console's, and shows mip-linear probes: candidates N, layouts match M on the stats line (docs/TASKS.md, "Linear textures with mipmaps are not bound in place"). No bindings change.

The reference

The console's linear level layout is computed by its addrlib port; the probe reports whether Vulkan can reuse it directly.

Evidence

  • cargo check -p vkback --all-targets, 164 native tests, and the build all pass.
  • House, 100 s, GE-Proton11-16: mip-linear probes: candidates 6, layouts match 0. Boat start, 100 s: same. The note for the 128x72 R32_SFLOAT 7-mip case: levels 0 and 1 agree (@0x4900 pitch 512, @0x2500 pitch 256), level 2 does not (vk @0x1300 pitch 128, console @0x1300 pitch 256) — the console's 256-byte row padding is the first divergence.
  • So a single Vulkan linear image cannot reuse the console mip chain on this driver; the next step in the task (one image per level, or a level-0-only image with copied mips) is the way forward.
  • Runs: /tmp/opencode/capture/mip-probe-house2/, /tmp/opencode/capture/mip-probe-boat/. Neither is a performance measurement.

Checklist (docs/AGENTS.md)

  • One topic; docs/TASKS.md not edited (rule 29/31)
  • No fallback, constant, switch, queue, unsafe or translator output changed (rules 2/9b/33/35/36/27)
  • Comments say what is true now (rule 3)
  • Nothing from the title, no non-free data pointers (hard constraints)
**@⁠TheRifai** on GitHub · 2026-12-01 20:29 UTC · [original](https://github.com/vktory6/VKtory/pull/137) `TheRifai:mip-linear-probe` → `main` · +75 −25 · 4 files · 1 commits · closed without merging ## What Mips are the largest single reason a console-linear texture takes a copying image (PR #129: 44,489 boat / 34,522 house attempts). The console packs linear mips smallest first and pads rows to 256 bytes (`frame::tiling::linear`); a Vulkan linear image with a mip chain has its own per-level layout. This adds a read-only probe — one image creation per distinct (format, width, height, mip count) — that compares each level's offset and row pitch with the console's, and shows `mip-linear probes: candidates N, layouts match M` on the stats line (docs/TASKS.md, "Linear textures with mipmaps are not bound in place"). No bindings change. ## The reference The console's linear level layout is computed by its addrlib port; the probe reports whether Vulkan can reuse it directly. ## Evidence - `cargo check -p vkback --all-targets`, 164 native tests, and the build all pass. - House, 100 s, GE-Proton11-16: `mip-linear probes: candidates 6, layouts match 0`. Boat start, 100 s: same. The note for the 128x72 R32_SFLOAT 7-mip case: levels 0 and 1 agree (`@0x4900 pitch 512`, `@0x2500 pitch 256`), level 2 does not (`vk @0x1300 pitch 128`, console `@0x1300 pitch 256`) — the console's 256-byte row padding is the first divergence. - So a single Vulkan linear image cannot reuse the console mip chain on this driver; the next step in the task (one image per level, or a level-0-only image with copied mips) is the way forward. - Runs: `/tmp/opencode/capture/mip-probe-house2/`, `/tmp/opencode/capture/mip-probe-boat/`. Neither is a performance measurement. ## Checklist (docs/AGENTS.md) - [x] One topic; `docs/TASKS.md` not edited (rule 29/31) - [x] No fallback, constant, switch, queue, `unsafe` or translator output changed (rules 2/9b/33/35/36/27) - [x] Comments say what is true now (rule 3) - [x] Nothing from the title, no non-free data pointers (hard constraints)
Mips are the largest reason a console-linear texture takes a copying image (PR #129: 44,489 boat / 34,522 house attempts). The console packs linear mips smallest first and aligns each row to 256 bytes; a Vulkan linear image with a mip chain need not agree. Probe one image per (format, width, height, mip count) once, compare each level's offset and row pitch with the console's, and show the candidate/match counts on the stats line. No binding changes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:31:42 +00:00
github-bot closed this pull request 2026-12-01 20:36:55 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 20:32 UTC · original

Thanks, the probe answered its question cleanly: 0 of 6 mip chains match, and the 256-byte row padding of the console is the first divergence (level 2 of the 128x72 R32_SFLOAT chain). I recorded the result in the TASKS item "Linear textures with mipmaps are not bound in place": github.com/vktory6/VKtory@ab7b4e6

I'm closing it instead of merging, though: with the answer in hand, the probe would create a test image for every new mip-chain description in every run from now on. It's a Vulkan call change that needs its own validation run, for a question that's settled. The next step from the task is yours if you want it: one linear image per level, with a view per level, or a level-0 image with the other levels copied. A PR for either is welcome.

(The TASKS.md lines in the diff are from your branch's older base, not an edit of yours. No problem.)

**@⁠vktory6** on GitHub · 2026-12-01 20:32 UTC · [original](https://github.com/vktory6/VKtory/pull/137#issuecomment-7324862239) Thanks, the probe answered its question cleanly: 0 of 6 mip chains match, and the 256-byte row padding of the console is the first divergence (level 2 of the 128x72 R32_SFLOAT chain). I recorded the result in the TASKS item "Linear textures with mipmaps are not bound in place": https://github.com/vktory6/VKtory/commit/ab7b4e6 I'm closing it instead of merging, though: with the answer in hand, the probe would create a test image for every new mip-chain description in every run from now on. It's a Vulkan call change that needs its own validation run, for a question that's settled. The next step from the task is yours if you want it: one linear image per level, with a view per level, or a level-0 image with the other levels copied. A PR for either is welcome. (The TASKS.md lines in the diff are from your branch's older base, not an edit of yours. No problem.)
Author
Owner

@⁠TheRifai on GitHub · 2026-12-01 22:06 UTC · original

On the invited next step for mipmapped linear textures: I looked at the shape of both options after the probe.

  • One image per level needs the view path to route mip m to a different image handle. Today an Img carries one image and viewdesc indexes mips within it (imgmake.rs, placed.rs, ViewKey { image, mip }), so this is a descriptor/view-table change, not a local one in make_linear_in_place.
  • Level 0 in place + copied mips is smaller: bind a single-level in-place image over the title bytes at the level-0 console offset (the console packs linear mips smallest-first, so level 0 is not at the texture start), then make the usual copied image for levels 1..N and map mip == 0 views to the former. It still needs a per-texture mip-to-image map and a picture gate, but no descriptor format change.

The probe's numbers suggest level 0 and 1 often agree with Vulkan's layout (128x72 R32_SFLOAT 7-mip: m0 @⁠0x4900 pitch 512, m1 @⁠0x2500 pitch 256) and the first divergence is row padding at m2, so option 2 would recover the in-place binding for the largest level with the least risk. I have not started it; recording the plan here so the task has a concrete next step.

**@⁠TheRifai** on GitHub · 2026-12-01 22:06 UTC · [original](https://github.com/vktory6/VKtory/pull/137#issuecomment-7327265025) On the invited next step for mipmapped linear textures: I looked at the shape of both options after the probe. - **One image per level** needs the view path to route mip `m` to a different image handle. Today an `Img` carries one `image` and `viewdesc` indexes mips within it (`imgmake.rs`, `placed.rs`, `ViewKey { image, mip }`), so this is a descriptor/view-table change, not a local one in `make_linear_in_place`. - **Level 0 in place + copied mips** is smaller: bind a single-level in-place image over the title bytes at the *level-0 console offset* (the console packs linear mips smallest-first, so level 0 is not at the texture start), then make the usual copied image for levels 1..N and map `mip == 0` views to the former. It still needs a per-texture mip-to-image map and a picture gate, but no descriptor format change. The probe's numbers suggest level 0 and 1 often agree with Vulkan's layout (128x72 R32_SFLOAT 7-mip: m0 @⁠0x4900 pitch 512, m1 @⁠0x2500 pitch 256) and the first divergence is row padding at m2, so option 2 would recover the in-place binding for the largest level with the least risk. I have not started it; recording the plan here so the task has a concrete next step.
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 22:08 UTC · original

Thanks for working out both shapes. One constraint decides between them, and it applies to both: a Vulkan image view samples the levels of one image only. A view over several levels (an SRV with MipLevels > 1, which LOD selection and trilinear filtering need) cannot span a level-0 image plus a copied image, nor one image per level. So either split only serves views that name a single level.

I put that into the task with a concrete first step: count the views of mipmapped linear textures by how many levels they name, in house and boat. If most name all levels, the copy stays (the console's 256-byte row padding per level doesn't fit one Vulkan linear image on RADV). If many name one level, your level-0 plan is worth building. github.com/vktory6/VKtory@1ab74ff

**@⁠vktory6** on GitHub · 2026-12-01 22:08 UTC · [original](https://github.com/vktory6/VKtory/pull/137#issuecomment-7327319160) Thanks for working out both shapes. One constraint decides between them, and it applies to both: a Vulkan image view samples the levels of one image only. A view over several levels (an SRV with MipLevels > 1, which LOD selection and trilinear filtering need) cannot span a level-0 image plus a copied image, nor one image per level. So either split only serves views that name a single level. I put that into the task with a concrete first step: count the views of mipmapped linear textures by how many levels they name, in house and boat. If most name all levels, the copy stays (the console's 256-byte row padding per level doesn't fit one Vulkan linear image on RADV). If many name one level, your level-0 plan is worth building. https://github.com/vktory6/VKtory/commit/1ab74ff

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.