Skip to content

Write resolution-family image textures uncompressed - #1936

Closed
TheGoldfish11 wants to merge 1 commit into
seedds:mainfrom
TheGoldfish11:family-nocompress
Closed

TheGoldfish11 wants to merge 1 commit into
seedds:mainfrom
TheGoldfish11:family-nocompress

Conversation

@TheGoldfish11

Copy link
Copy Markdown
Contributor

Fixes #1935.

Problem

c484b13 places textures that share storage at different sizes (a "resolution family") in one placement heap. They keep the default allowGPUOptimizedContents = YES, so when one size reads bytes another size wrote, it decodes the other's losslessly compressed blocks as garbage.

In ASTRAL CHAIN, the 1600x900 HDR targets (format 92, ser=13/14) share storage with the 1440x810 pause-menu targets. On the first frame after the menu, the 1600x900 target is loaded, not cleared, and comes back with 1,115,523 of 1,440,000 pixels non-finite. The game never clears it, so the bad pixels persist under transparent surfaces, and bloom spreads them into a strobing pink/white glow. Details and per-frame scan data are in #1935.

Change

In image_texture, family members are created with allowGPUOptimizedContents = NO, and so is the largest descriptor used to zero a new heap. Inherited bytes are then only misplaced texels of the same format, as on the console.

  • Single-resolution storage keeps the ordinary path and keeps compression.
  • DM_NVN_FAMILY_NOCOMPRESS=0 restores the old behaviour. The switch is documented in docs/env_switches.tsv.

Testing

  • ASTRAL CHAIN 1.0.1 on Apple Silicon: opening and closing the pause menu repeatedly in the spots that reproduced the glow no longer shows it.
  • DM_NVN_MAGSCAN (a non-finite scan of every pass, every frame) reports zero non-finite pixels with the change. Before the change, every reproduction showed ~1.1M.
  • Not tested with Luigi's Mansion 3, the original family case.

🤖 Generated with Claude Code

…COMPRESS, on unless =0)

ASTRAL CHAIN's 1600x900 HDR targets share storage with the 1440x810 pause-menu
targets (resolution-family heap, c484b13). With lossless compression, the
1600x900 texture decoded the menu's compressed blocks as ~1.1M non-finite
pixels; the targets are loaded, never cleared, so bloom spread them into a
strobing pink/white glow. Uncompressed, inherited bytes are only misplaced
texels of the same format, as on the console. Fixes seedds#1935.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation labels Nov 9, 2026
seedds added a commit that referenced this pull request Nov 9, 2026
…s lossless compression a size that read bytes another size wrote decoded that size's compressed blocks as garbage, so ASTRAL CHAIN's 1600x900 HDR targets came back from the 1440x810 pause menu with 1.1M non-finite pixels, which bloom spread into a strobing pink / white glow; uncompressed, they read the other size's texels, misplaced, as on the console. Ocarina of Time's 215 family heaps cost at most about 0.3 ms of GPU a frame (22.07 -> 22.38 ms median on an M4 Pro, within the runs' spread). DM_NVN_FAMILY_NOCOMPRESS=0 turns compression back on; t_image_alias checks a cross-size read (PR #1936)

Fixes #1935.

Co-authored-by: TheGoldfish11 <40026350+TheGoldfish11@users.noreply.github.com>
@seedds

seedds commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Landed as b001c49 with your fix unchanged and you as co-author. Thank you for the diagnosis and the scan data.

Added on top:

  • A regression test in t_image_alias: it clears a 1440x810 RGBA16F member of a family through the host's clear path, then reads the 1600x900 member back. Uncompressed, every texel is the clear colour or zero. With compression (DM_NVN_FAMILY_NOCOMPRESS=0), 6,144 of 1,440,000 texels were garbage on an M4 Pro.
  • What it costs: Ocarina of Time makes 215 family heaps in Kokiri Forest (202 Depth32F). On its kokiri-deck route, with one host and the switch on and off, median GPU time a frame was 22.07 ms compressed (4 runs) and 22.38 ms uncompressed (5 runs), within the spread of the runs.
  • A reference entry (rendering.md, "A resolution family member reads another size's compressed blocks as garbage"), a symptom index line and a line in ASTRAL CHAIN's note.

Not run: Luigi's Mansion 3 and the iPhone. #1935 is closed by the commit; please reopen it if the glow comes back on main.

@seedds seedds closed this Nov 9, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…s lossless compression a size that read bytes another size wrote decoded that size's compressed blocks as garbage, so ASTRAL CHAIN's 1600x900 HDR targets came back from the 1440x810 pause menu with 1.1M non-finite pixels, which bloom spread into a strobing pink / white glow; uncompressed, they read the other size's texels, misplaced, as on the console. Ocarina of Time's 215 family heaps cost at most about 0.3 ms of GPU a frame (22.07 -> 22.38 ms median on an M4 Pro, within the runs' spread). DM_NVN_FAMILY_NOCOMPRESS=0 turns compression back on; t_image_alias checks a cross-size read (PR seedds#1936)

Fixes seedds#1935.

Co-authored-by: TheGoldfish11 <40026350+TheGoldfish11@users.noreply.github.com>
nobz226 pushed a commit to nobz226/nxnative that referenced this pull request Nov 10, 2026
…s lossless compression a size that read bytes another size wrote decoded that size's compressed blocks as garbage, so ASTRAL CHAIN's 1600x900 HDR targets came back from the 1440x810 pause menu with 1.1M non-finite pixels, which bloom spread into a strobing pink / white glow; uncompressed, they read the other size's texels, misplaced, as on the console. Ocarina of Time's 215 family heaps cost at most about 0.3 ms of GPU a frame (22.07 -> 22.38 ms median on an M4 Pro, within the runs' spread). DM_NVN_FAMILY_NOCOMPRESS=0 turns compression back on; t_image_alias checks a cross-size read (PR seedds#1936)

Fixes seedds#1935.

Co-authored-by: TheGoldfish11 <40026350+TheGoldfish11@users.noreply.github.com>
(cherry picked from commit b001c49)
Fasen24-AI added a commit to Fasen24-AI/swordboiMacNative that referenced this pull request Nov 10, 2026
…ctions compiled out, DMSH_BORDER_FC), seedds#1930 (native float atomic add), seedds#1920 (GPU-written sliver does not own a texture: terrain tiles), seedds#1917 (depth attachment sampled by a depth-writing draw reads a copy), seedds#1928 (enc_thread on), seedds#1942 (idle-GPU late frames do not step the hold up), seedds#1940 (prewarm lines after the first frame), seedds#1936 (resolution families uncompressed)

Hand-resolved: image_texture keeps the virtual pools we admit; fb_prepare keeps our pass split and local dread flag after the depth snapshot; the compute key keeps the NDVE direct draw before the border constant.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014eD437mxrMnW2UwLZhpwc7

Upstream pull requests applied in this commit (their authors' work, brought onto this tree with a three-way merge; the description is in each PR):
- seedds#1774 by uncraftablexd (closed): Compute threads that exit before a barrier keep arriving at it, and every shader loop has a cap (GPU hang defences), chain change
- seedds#1917 by FifteenPen (closed): A draw that writes depth and samples its own depth attachment reads a copy of it: Ocarina of Time's light-blue dashes over the rock at Death Mountain Trail's cave entrance are gone
- seedds#1920 by nawangwe (closed): A GPU-written span's sliver inside a texture does not make it the GPU's: Ocarina of Time's terrain tiles no longer vanish or show another tile's surface (seedds#1566)
- seedds#1928 by FeReuss (open): Ocarina of Time: enc_thread on, the replay encodes on a thread of its own
- seedds#1929 by FeReuss (open): Unused border corrections are compiled out of pipelines that bind no sampler with a twin (function constant DMSH_BORDER_FC)
- seedds#1930 by FeReuss (open): A float add to storage memory with no result read is one native atomic add instead of a compare-and-swap loop
- seedds#1936 by TheGoldfish11 (closed): Write resolution-family image textures uncompressed
- seedds#1940 by uncraftablexd (open): A prewarm list's lines after its #@after_first_frame line are built after the first frame, in the background, instead of in the prepare step (issue seedds#1747)
- seedds#1942 by uncraftablexd (open): Frame step: late frames with the GPU idle do not step up, and a longer hold the GPU does not explain is probed
Fasen24-AI added a commit to Fasen24-AI/swordboiMacNative that referenced this pull request Nov 10, 2026
…1909 seedds#1897 seedds#1917 seedds#1920 seedds#1936) and seedds#1902, ahead of merging main

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014eD437mxrMnW2UwLZhpwc7

Upstream pull requests applied in this commit (their authors' work, brought onto this tree with a three-way merge; the description is in each PR):
- seedds#1897 by Know-It-All-Brother (closed): HMMA with an f16 accumulator rounds once per 8 products, as Ampere does (chain change)
- seedds#1902 by fxd0h (open): HFMA2 rounds once to half, as Ampere does (chain change)
- seedds#1909 by oz-rinkliff (open): Bound translated fragment uniform reads to the NVN binding length
- seedds#1917 by FifteenPen (closed): A draw that writes depth and samples its own depth attachment reads a copy of it: Ocarina of Time's light-blue dashes over the rock at Death Mountain Trail's cave entrance are gone
- seedds#1920 by nawangwe (closed): A GPU-written span's sliver inside a texture does not make it the GPU's: Ocarina of Time's terrain tiles no longer vanish or show another tile's surface (seedds#1566)
- seedds#1936 by TheGoldfish11 (closed): Write resolution-family image textures uncompressed
rafaeliga pushed a commit to rafaeliga/kid-with-sword-remake that referenced this pull request Nov 11, 2026
…resolution-family textures made uncompressed

Ocarina of Time's profile had tex_release 2, which also gives back the guest copies of CPU-visible textures. A texture the game makes again over released pages reads zeros, so the ground, cliffs, sky and doors turned magenta after area changes in Kokiri Forest, Hyrule Field and Hyrule Castle (seedds/nxnative issues seedds#1641 and seedds#1972, both reported on this fork, where level 1 fixed it). Level 1 keeps the CPU_NO_ACCESS releases; DM_TEX_RELEASE=2 brings the rest back.

From nxnative b001c49 (PR seedds#1936): textures of a resolution family are created uncompressed. With Metal's lossless compression, a size that read bytes another size wrote decoded its compressed blocks as garbage, which shows as pink. The render scale slider and the dynamic resolution make such families. DM_NVN_FAMILY_NOCOMPRESS=0 turns compression back on. t_image_alias's cross-size test builds its textures by V's family rule (exactly COMPRESSIBLE|IMAGE) and sizes the heap uncompressed: 321 checks pass, and with compression on it finds 6,144 garbage texels.

Co-authored-by: seedds <seedds@gmail.com>
Co-authored-by: TheGoldfish11 <40026350+TheGoldfish11@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASTRAL CHAIN: strobing pink/white glow after the pause menu (resolution-family textures read compressed data from another resolution)

2 participants