Skip to content

Sample depth attachments through equivalent red texture views - #988

Closed
thehobbit85 wants to merge 2 commits into
seedds:mainfrom
thehobbit85:codex/sample-depth-as-red
Closed

thehobbit85 wants to merge 2 commits into
seedds:mainfrom
thehobbit85:codex/sample-depth-as-red

Conversation

@thehobbit85

@thehobbit85 thehobbit85 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #985. Burnout Paradise Remastered registers a sampled R32F view of its D32F depth attachment. Metal rejects that cast even when the texture allows pixel-format views. Simply binding the original depth texture as colour gives the wrong channels: on an M2 Max, a depth value of 0.375 read back as (0.375, 0.375, 0.375, 1).

Keep the Metal depth format for D32F → R32F and D16 → R16 UNORM sampled views. Map the depth value to (R, 0, 0, 1) before composing the guest's channel swizzle. The view uses the selected subresources of the original attachment, so subsequent writes remain visible without copying it. Other format pairs and the stencil-only path are unchanged.

  • On an Apple M2 Max with Metal API validation enabled, the new test against unmodified main (65501fbb) aborts with the exact Depth32Float/R32Float assertion from the report. With the fix, make -C dm/gfx/tests GAME=010015100B514000 check_t_view_swizzle passes all 442 checks. The new cases exercise both formats through real NVN registration and GPU colour reads and samples. Different depths at two mips catch selection errors; a second render clear after lookup checks that the cached identity and remapped views both see the new depth.
  • The native Metal suite (make -j5 -C dm/gfx/tests GAME=010015100B514000 run) passed with six optional external reflection samples unavailable. The Mac host built. Python: 906 tool tests (16 skipped), 200 graphics tests (26 skipped), 42 iOS packaging tests; all 11 documentation tests passed.
  • Pinned Python lint (ruff and pyright): zero new or stale findings. Full LLVM 23.1.4 clang-tidy checked 217 sources; both changed files match the baseline. Two existing findings in the unrelated geometry-hazards test keep the repository-wide check red; PR #959 and PR #979 already address them.
  • Game regression targets: Luigi’s Mansion 3 renders through a D16/R16 alias; Super Monkey Ball Banana Rumble reads multisample depth; Pokémon Legends: Z-A samples depth-pyramid mips and the stencil plane; DRAGON QUEST VII Reimagined uses stencil-mode texture builders; Breath of the Wild composes channel swizzles on sampled render targets. The last four exercise neighboring paths. The impact tool also flags Pokémon Scarlet and Tears of the Kingdom through generic queue submission and texture registration; it does not prove they use these format pairs. scripts/regress.py check --games 0100DCA0064A6000,010031F019294000,0100F43008C44000,01007EF00011E000,0100A9D01C446000 stopped at preflight (exit 2): there are no configured game builds or regression directories here. Burnout has no repository profile. No gameplay or iOS device run was performed; whether Burnout reaches gameplay after this abort is still unverified.

Shared geometry fixture CI fix

Commit 04f25365042f applies #959 as a separate prerequisite. On 1fbf27efdd06, LLVM 23.1.4 reproduced both C lint findings in the geometry hazard fixture inherited from main. On the updated commit, LLVM 23.1.4 checked all 217 sources and matched the existing 271-finding baseline. The Mac GPU fixture passed all 65 assertions in each of three cut configurations with Metal API validation. This follow-up changes only the synthetic test. The feature validation and its limitations above still apply to the feature revision they name.

seedds added a commit that referenced this pull request Nov 3, 2026
…depth storage (#988)

Metal refuses a Depth32Float texture viewed as R32Float (and Depth16Unorm as R16Unorm) even with pixel-format views, and Burnout Paradise Remastered samples its D32F depth buffer through an R32F view (#985: validation abort in tex_by_id). The view now keeps the depth format, selects the requested mips and layers of the attachment, and presents (depth, 0, 0, 1) before the descriptor's channel swizzle, as NVN's red view does. t_view_swizzle covers both pairs through registration, GPU reads and samples, mip selection and later depth writes.

Fixes #985

Co-authored-by: Eliran Zach <4012041+thehobbit85@users.noreply.github.com>
@seedds

seedds commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Landed on main as e58e446, with you as co-author. Thank you for the precise diagnosis and the GPU test.

I took only the first commit. The geometry-hazards fixture fix is already on main (f714e13), so I dropped the cherry-picked #959 commit, which is what made this PR conflict.

Checked here: the new t_view_swizzle cases abort on main with the same Depth32Float/R32Float assertion and pass with the fix (442 checks, M4 Pro, Metal validation on). A Breath of the Wild regression run passed on shaders, startup, fps, memory and red lines. Its frame p99 moved, but that game never registers a depth-to-red view, so the run measured Mac load, not this change. Luigi's Mansion 3 couldn't be run here.

Burnout gameplay past this point is still unverified. #985 is closed by the commit, and the reporter can reopen it if the game stops somewhere else.

@seedds seedds closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Burnout Paradise Remastered (0100DBF01000A000): boots, then aborts on a Depth32Float → R32Float texture view

2 participants