A game's Mac shaders are compiled for the Mac host's minimum macOS, so one chain version gives the same result on every Mac: the Mac compile named no deployment target, and Metal's language version follows it, so the compiler took the build Mac's system. 0662f9d8's blend helper took its output as a reference with no address space, which the macOS 27 language accepts and the macOS 26 and iOS 18 languages refuse: it compiled where it was written, and 22,296 of Ocarina of Time's 42,848 Mac shaders failed on two Macs with macOS 26 (issue #2272; 8fb5ffeb added the thread qualifier, found on the iOS build). Measured with Metal front end 32023.922 on macOS 27.2, a shader with that signature: it compiles with no minimum and with iOS 27.0, and fails with -mmacosx-version-min=26.0, 15.0 and -mios-version-min=18.0. Every Mac compile now passes -mmacosx-version-min=MACOS_MIN (dm/mac/min_os.mk, 26.6, read as dmsh_chain.MAC_MIN): dmsh_build.py's MAC_METAL, vk_shaders.py, gl_shaders.py and dmsh_dryrun.py, as the host's own Metal libraries already did. min_os.mk is part of the chain version, and the flag is in each shader's cache key through the compile record; DMSH_CHAIN is 1fa63cf7c7ae, so every game's Mac shaders rebuild once. test_dmsh_blend_zero and test_shader_pch compile with the flag, and test_nsp_chain's temporary repository links dm/mac. The reference entry (The blend helper's output reference on iOS) said the Mac libraries compile, which held on macOS 27 only: it now gives the measured cases and the pin, and Ocarina's note links it. Checked: with the old signature put back, the six Mac compile cases of test_dmsh_blend_zero fail on macOS 27.2 (they passed before); test_dmsh_blend_zero, test_nsp_chain, test_docs, test_shader_pch and test_host_msl pass. regress.py check on Bastion (full route, baseline 8fb5ffeb, Apple M6): 72 of 72 shaders build on both chains, no MSL changed (the 72 libraries differ, as expected), 59.4 -> 59.6 fps, p99 18.01 -> 17.72 ms, no new red line; its two screenshots differ slightly (6 dHash bits, RGB 5) with one run a side, not looked into. Not run: a large game with the flag (the reporters' macOS 26 builds of Ocarina suggest its language accepts the chain's output, if their compiler took macOS 26 as its target), a Vulkan or OpenGL game, the full gfx suite, lint_python.py, iOS (its compile line is unchanged)

Fixes #2272
This commit is contained in:
seedds committed 2026-11-11 19:39:48 +08:00
1 parent 352e4a6e91
commit f75ac06e85
12 files changed
+28 -16

No files matched your search

+1
View File
@@ -126,6 +126,7 @@ Its 37 kernels that correct samples, NDSR's network among them, gave about 0.25
## Found on this game
- [Reads past a uniform binding's size](../../../docs/reference/shaders.md#reads-past-a-uniform-bindings-size): open ([GitHub issue #2218](https://github.com/seedds/nxnative/issues/2218)), long white streaks from the horses at Lon Lon Ranch and from Link's slingshot, and flickering parts of the slingshot and of the ReDeads' faces, reported with the uniform read bound on. The bound now takes the size the driver gives the GPU, rounded up to 256 bytes; the game binds sizes that are not multiples of 256. Not reproduced here before or after (the slingshot at Link's house, the ReDeads of adult Castle Town), so the reporters' retest decides.
- [The blend helper's output reference on iOS](../../../docs/reference/shaders.md#the-blend-helpers-output-reference-on-ios): resolved, 22,296 of 42,848 Mac shaders failed to compile on macOS 26 ([GitHub issue #2272](https://github.com/seedds/nxnative/issues/2272)); the Mac compile now names the host's minimum macOS.
- [A NaN colour under a zero blend weight](../../../docs/reference/shaders.md#a-nan-colour-under-a-zero-blend-weight): resolved, white clouds over the ground mist between Kokiri Forest and Hyrule Field and over the ferns at the camera in Kokiri Forest ([issue #1839](https://github.com/seedds/nxnative/issues/1839)). The mist shader `5ad65c0eefd09c7f` writes NaN at alpha 0 where its layer has density 0; NVIDIA's blender, with the option NVN's driver sets, adds nothing there, Apple's stored the NaN.
- [The 60 Hz link at 40 fps in fullscreen on a ProMotion screen](../../../docs/reference/frame-rate.md#the-60-hz-link-at-40-fps-in-fullscreen-on-a-promotion-screen): 40 fps in fullscreen on an M5 Pro MacBook Pro with the GPU at 10 ms of the 16.7, every present one 120 Hz refresh late and every other display-link tick skipped; the screen's fixed 60 Hz mode held 60.0 fps there and fullscreen now switches to it, with the 120 Hz link (59 fps) for screens with no such mode.
- [The shader package and the shader map come from different splits](../../../docs/reference/packing.md#the-shader-package-and-the-shader-map-come-from-different-splits): resolved, a black screen with sound in a build through NX2Apple ([issue #1841](https://github.com/seedds/nxnative/issues/1841)); the present pass was translated from a terrain shader's record. Records now carry their keys, and the shader build finds them by key.
+1 -1
View File
@@ -1,3 +1,3 @@
// Generated file (dm/gfx/tools/dmsh_chain.py --header): the B shader library translation chain version this source tree expects (default options), one for every game;
// the host loads only <library dir>/b-<V>/. Run dmsh_chain.py --header after changing the chain's tools and commit this file with the change
#define DMSH_CHAIN "5ee7c6407a57"
#define DMSH_CHAIN "1fa63cf7c7ae"
+2 -1
View File
@@ -13,6 +13,7 @@ import unittest
TOOLS = Path(__file__).resolve().parents[1] / 'tools'
sys.path.insert(0, str(TOOLS))
import dmsh_abi # noqa: E402
import dmsh_chain # noqa: E402
import dmsh_entry # noqa: E402
import dmsh_fetch # noqa: E402
import dmsh_rewrite # noqa: E402
@@ -164,7 +165,7 @@ class BlendZero(unittest.TestCase):
u, info = dmsh_side.unit(text)
f, meta = dmsh_fetch.fold(u, [], om_only_ok=True)
texts += [(name, text), (name + '_unit', u), (name + '_fold', f)] # each text a library is compiled from
for sdk, flags in (('macosx', ()), ('iphoneos', ('-mios-version-min=18.0', '-fmetal-math-mode=relaxed'))):
for sdk, flags in (('macosx', (dmsh_chain.MAC_MIN_FLAG,)), ('iphoneos', ('-mios-version-min=18.0', '-fmetal-math-mode=relaxed'))):
for name, out in texts:
with self.subTest(sdk=sdk, variant=name), tempfile.TemporaryDirectory() as d:
p = Path(d) / f'{name}.metal'; p.write_text(out)
+2 -1
View File
@@ -64,7 +64,8 @@ PRE_STATS = collections.Counter()
# 35785cddc971290c sign-extends a packed 16-bit vertex field as a = w * 65536, then (a >> 31) << 16 | uint(a) >> 16; without the flag the compiler took the sign bits from bits 15-30 of w,
# so the lightmap / probe UV's x came out far too large and models drawn with mesh shaders took their ambient light from the wrong texels (the bright band on the Deku Tree's walls).
# The flag also drops inbounds from pointer arithmetic (Metal's clang has no -fwrapv-pointer) and keeps loop bounds that may wrap (test_dmsh_wrapv.py)
MAC_METAL = ['xcrun', '-sdk', 'macosx', 'metal', '-c', '-O1', '-fpreserve-invariance', '-fwrapv']
# The deployment target (dmsh_chain.MAC_MIN_FLAG, the Mac host's minimum macOS) fixes the Metal language version, which otherwise follows the build Mac's system
MAC_METAL = ['xcrun', '-sdk', 'macosx', 'metal', '-c', '-O1', dmsh_chain.MAC_MIN_FLAG, '-fpreserve-invariance', '-fwrapv']
MAC_RECORD = ' '.join(MAC_METAL) + '; xcrun -sdk macosx metallib'
# The compiles run the tools xcrun names, found once: each xcrun launch looks them up again, about 4 ms of a compile's two launches (8 ms a shader). -isysroot is what xcrun -sdk passes
# (as SDKROOT), and the outputs are the same bytes (.air and .metallib, checked on Odyssey's shaders); without it the driver targets the running macOS, not the SDK, and they differ.
+8 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# Translation chain version of the B shader library: one version for every game, which the host is compiled with (dm/gfx/nvn/dmsh_chain.h). The build result must be determined by source alone.
# Chain version V = first 12 digits of the sha256 of the contents of the following in-repo files + the translation options: this script, dmsh_build.py, dmsh_fetch.py (readable-tile version), dmsh_vin.py (shadow vertex inputs), dmsh_pull.py and dmsh_pull.metal (pulling vertex inputs),
# dmsh_geometry.py, dmsh_facts.py, dmsh_rewrite.py, dmsh_reflect.py and dmsh_entry.py (a shader's MSL rewrites, reflection and entry points), the library ABI dm/gfx/nvn/dmsh_abi.h with its reader dmsh_abi.py, the dmsh_xlate sources (Program.cs, csproj), the iOS compile convention ios_metal.py, and the tool lock dmsh_chain.lock (measured fingerprints of the native translator, which holds the Ryujinx shader library / spirv-cross / metal compiler).
# dmsh_geometry.py, dmsh_facts.py, dmsh_rewrite.py, dmsh_reflect.py and dmsh_entry.py (a shader's MSL rewrites, reflection and entry points), the library ABI dm/gfx/nvn/dmsh_abi.h with its reader dmsh_abi.py, the dmsh_xlate sources (Program.cs, csproj), the iOS compile convention ios_metal.py, the Mac host's minimum macOS dm/mac/min_os.mk (MAC_MIN), and the tool lock dmsh_chain.lock (measured fingerprints of the native translator, which holds the Ryujinx shader library / spirv-cross / metal compiler).
# A game's own inputs are not part of V: its profile's shader tables and nvn_* / shader_* keys are in each shader's cache key (dmsh_build.py shader_key), so a change rebuilds the shaders it affects,
# and their digest (inputs below) stamps the library: <cache dir>/b-<V>/inputs.tsv says which game and which inputs it was built from. c1_full.tsv / cb_extent.tsv name V and that digest in their
# header (table_head), and the host takes them only when both match its library; build_ipa.sh packs a library only when its digest is the profile's.
@@ -23,6 +23,13 @@ FILES += ['../third_party/ryujinx/src/Ryujinx.Graphics.Shader/' + f for f in (
'Translation/Transforms/GeometryToCompute.cs', 'Translation/TranslatorContext.cs', 'Translation/Translator.cs', 'Translation/EmitterContext.cs', 'Translation/ShaderDefinitions.cs', 'CodeGen/Spirv/Instructions.cs',
'StructuredIr/ShaderProperties.cs', 'Translation/Optimizations/BindlessElimination.cs', 'Translation/Optimizations/Optimizer.cs',
'Translation/Optimizations/GlobalToStorage.cs', 'CodeGen/Spirv/SpirvGenerator.cs')]
FILES += ['../mac/min_os.mk'] # MAC_MIN below
# The Mac libraries are compiled for the Mac host's minimum macOS (dm/mac/min_os.mk), as the host's own Metal libraries are (dm/host/Makefile MSL_MIN_macosx). The deployment target
# sets the Metal language version: with none the compiler takes the build Mac's system, so one source compiled on macOS 27 and failed on macOS 26 (a reference parameter with no address
# space, which the newer language accepts: GitHub issue #2272), and a library made on the newer system names a language version the older one does not load. The NVN chain
# (dmsh_build.py MAC_METAL), vk_shaders.py and gl_shaders.py pass this flag on every Mac compile; the iPhone's is ios_metal.py's
MAC_MIN = open(os.path.join(GFX, '../mac/min_os.mk')).read().split('MACOS_MIN := ')[1].split()[0]
MAC_MIN_FLAG = f'-mmacosx-version-min={MAC_MIN}'
INPUT_TABLES = ['shader_facts.tsv', 'shader_map.tsv', 'shader_map.tsv.conflicts.tsv', 'shader_pairs.tsv', 'pso_pairs.tsv', 'bf_want.tsv', 'geo_mesh.tsv', 'dual_want.tsv'] # in the game profile folder
LOCK = os.path.join(HERE, 'dmsh_chain.lock'); HEADER = os.path.join(GFX, 'nvn/dmsh_chain.h')
STAMP = 'inputs.tsv' # in the library directory b-<V>/
+2 -2
View File
@@ -3,7 +3,7 @@
# Records pass/fail and the first error line at each stage, and summarizes the success rate and the distribution of failure reasons. The dry run uses ShaderTools' default queries (texture types etc. are not answered truthfully) and only measures "can it be converted".
# Usage: dmsh_dryrun.py <Switch package dir> <ShaderTools executable> <output dir> Environment J=concurrency
import os, re, sys, json, hashlib, subprocess, struct, tempfile, collections, concurrent.futures as cf
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))); from dmsh_chain import SPIRV_CROSS # the in-repo spirv-cross build
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))); from dmsh_chain import SPIRV_CROSS, MAC_MIN_FLAG # the in-repo spirv-cross build
dm_dir, shtools, out = sys.argv[1:4]
os.makedirs(out, exist_ok=True)
XC = ['--msl', '--msl-version', '20300', '--msl-argument-buffers', '--msl-texture-buffer-native']
@@ -26,7 +26,7 @@ def one(job):
if r.returncode or not os.path.exists(spv) or os.path.getsize(spv) == 0: return key, name, 'spirv', first_err(r.stdout + r.stderr)
r = subprocess.run([SPIRV_CROSS, *XC, spv, '--output', msl], capture_output=True, text=True)
if r.returncode: return key, name, 'msl', first_err(r.stdout + r.stderr)
r = subprocess.run(['xcrun', '-sdk', 'macosx', 'metal', '-c', msl, '-o', air], capture_output=True, text=True)
r = subprocess.run(['xcrun', '-sdk', 'macosx', 'metal', '-c', MAC_MIN_FLAG, msl, '-o', air], capture_output=True, text=True)
if r.returncode: return key, name, 'metal', first_err(r.stdout + r.stderr)
return key, name, 'ok', ''
+2 -2
View File
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../tools'))
from romfs import os, open
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import mvgl
from dmsh_chain import SPIRV_CROSS # the in-repo spirv-cross build the NVN chain uses too (spirv_cross_bin)
from dmsh_chain import SPIRV_CROSS, MAC_MIN_FLAG # the in-repo spirv-cross build the NVN chain uses too (spirv_cross_bin)
VEC_TYPES = {'float', 'vec2', 'vec3', 'vec4', 'int', 'ivec2', 'ivec3', 'ivec4', 'uint', 'uvec2', 'uvec3', 'uvec4', 'bool', 'mat2', 'mat3', 'mat4'}
@@ -223,7 +223,7 @@ def main():
'# ' + ' '.join(subprocess.run(['glslangValidator', '--version'], capture_output=True, text=True).stdout.split()[:3]) + '; spirv-cross '
+ ' '.join((lambda r: r.stdout + r.stderr)(subprocess.run([SPIRV_CROSS, '--revision'], capture_output=True, text=True)).split())]
tsv += [f'{k[0]}\t{v[0]}\t{" ".join(v[1])}\t{v[3]}' for k, v in sorted(seen.items())]
dirs = [(os.path.join(out, 'gl'), 'macosx', [])]
dirs = [(os.path.join(out, 'gl'), 'macosx', [MAC_MIN_FLAG])] # the Mac host's minimum macOS, as the NVN chain's libraries (dmsh_chain.py MAC_MIN)
if ios: dirs.append((os.path.join(ios, 'gl'), 'iphoneos', ['-mios-version-min=18.0', '-fmetal-math-mode=relaxed'])) # relaxed as in vk_shaders.py and ios_metal.py: no NaN / Inf assumption on the iPhone's GPU compiler
msls = [v[2] for v in seen.values()]
for d, sdk, extra in dirs:
+2 -2
View File
@@ -25,7 +25,7 @@ import concurrent.futures as cf, hashlib, json, os, re, struct, subprocess, sys,
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../tools'))
from romfs import os, open
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from dmsh_chain import SPIRV_CROSS # the in-repo spirv-cross build the NVN chain uses too (spirv_cross_bin)
from dmsh_chain import SPIRV_CROSS, MAC_MIN_FLAG # the in-repo spirv-cross build the NVN chain uses too (spirv_cross_bin)
MAGIC = 0x07230203
OP_DECORATE, OP_MEMBER_DECORATE, OP_TYPE_ARRAY, OP_TYPE_RTARRAY, OP_TYPE_STRUCT = 71, 72, 28, 29, 30
@@ -179,7 +179,7 @@ def main():
tsv = ['# Vulkan shaders (dm/gfx/tools/vk_shaders.py): key = sha256(SPIR-V)[:16], Metal function vk_<key>; resources kind:set.binding=slot (u uniform buffer, b storage buffer, t image, s sampler, c combined, p push constants)',
'# spirv-cross ' + ' '.join((lambda r: r.stdout + r.stderr)(subprocess.run([SPIRV_CROSS, '--revision'], capture_output=True, text=True)).split())]
tsv += [f'{k}\t{v[0]}\t{" ".join(v[1])}\t{v[3]}' for k, v in sorted(seen.items())]
dirs = [(os.path.join(out, 'vk'), 'macosx', [])]
dirs = [(os.path.join(out, 'vk'), 'macosx', [MAC_MIN_FLAG])] # the Mac host's minimum macOS, as the NVN chain's libraries (dmsh_chain.py MAC_MIN)
# The iPhone library is compiled with -fmetal-math-mode=relaxed, as the NVN chain's (dm/ios/tools/ios_metal.py): the default fast mode lets the GPU compiler assume there is
# no NaN / Inf, which would let it drop the NaN handling of the precise:: functions above
if ios: dirs.append((os.path.join(ios, 'vk'), 'iphoneos', ['-mios-version-min=18.0', '-fmetal-math-mode=relaxed']))
+1
View File
@@ -36,6 +36,7 @@ class Header(Base):
(self.repo / 'dm/gfx/nvn').mkdir(parents=True)
(self.repo / 'dm/gfx/tools').symlink_to(REPO / 'dm/gfx/tools'); (self.repo / 'dm/ios').symlink_to(REPO / 'dm/ios')
(self.repo / 'dm/third_party').symlink_to(REPO / 'dm/third_party')
(self.repo / 'dm/mac').symlink_to(REPO / 'dm/mac') # min_os.mk, the Mac libraries' deployment target
(self.repo / 'dm/gfx/nvn/dmsh_abi.h').symlink_to(REPO / 'dm/gfx/nvn/dmsh_abi.h') # the shader library ABI, a chain input beside the header
self.h = self.repo / nsp.CHAIN_H
shutil.copy(REPO / nsp.CHAIN_H, self.h)
+2 -1
View File
@@ -15,10 +15,11 @@ from unittest import mock
REPO = Path(__file__).resolve().parents[3]
sys.path.insert(0, str(REPO / 'dm/gfx/tools'))
sys.path.insert(0, str(REPO / 'dm/ios/tools'))
import dmsh_chain # noqa: E402
import dmsh_pch # noqa: E402
import ios_metal # noqa: E402
MAC = ['xcrun', '-sdk', 'macosx', 'metal', '-c', '-O1', '-fpreserve-invariance', '-fwrapv'] # dmsh_build.py MAC_METAL (that file is a script that runs a build when imported)
MAC = ['xcrun', '-sdk', 'macosx', 'metal', '-c', '-O1', dmsh_chain.MAC_MIN_FLAG, '-fpreserve-invariance', '-fwrapv'] # dmsh_build.py MAC_METAL (that file is a script that runs a build when imported)
SHADERS = {
'vertex': 'vertex float4 main0(uint v [[vertex_id]], constant float4* c [[buffer(0)]]) { return c[v]; }\n',
'fragment_many': dmsh_pch.PROBE.split('using namespace metal;\n')[1],
+1 -1
View File
@@ -930,7 +930,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
- a simulation or filter that reads neighbouring texels misbehaves though every constant is right. In the translated MSL a variable is declared with no value and read at once (`int _139; int _141 = _139;`), used as a coordinate. On Ocarina of Time: grass whose blades shift at 10 Hz, with a 6-frame cycle in the depth buffer and a wind velocity texture of strong stripes. → [Dead-code removal dropped a coordinate of a multi-output instruction](../reference/shaders.md#dead-code-removal-dropped-a-coordinate-of-a-multi-output-instruction)
- the ground kept stale 32×32 blocks where the G-buffer draw failed the depth test: blocks of a stale image where a depth pre-pass and a later pass with other vertex shaders meet (Odyssey: 32×32 blocks on every fourth frame). With mesh shaders: white shapes on plants for single frames, at other places each frame while the leaves move (Ocarina of Time). → [Position invariance across shaders](../reference/shaders.md#position-invariance-across-shaders)
- white clouds over the ground, coming and going (Ocarina of Time: over the ground mist between Kokiri Forest and Hyrule Field, and over the ferns at the camera in Kokiri Forest while they sway). The scene target holds NaN pixels after a fog or lighting pass and bloom spreads each into a white blot; dropping that pass removes them. → [A NaN colour under a zero blend weight](../reference/shaders.md#a-nan-colour-under-a-zero-blend-weight)
- iOS pixel shader compilation fails with `reference type must have explicit address space qualifier` at `dm_blend0(main0_out& dm_o, ...)`. The Mac libraries compile. → [The blend helper's output reference on iOS](../reference/shaders.md#the-blend-helpers-output-reference-on-ios)
- pixel shader compilation fails with `reference type must have explicit address space qualifier` at `dm_blend0(main0_out& dm_o, ...)`: every iOS build, and a Mac build made on macOS 26. A Mac build made on macOS 27 compiled, so the fault passed where it was written. → [The blend helper's output reference on iOS](../reference/shaders.md#the-blend-helpers-output-reference-on-ios)
- dark specks flickering in a ground mist, a few pixels each, at different places every frame (Ocarina of Time in Kokiri Forest; the console shows none). Dropping the mist removes them, as does dropping its depth-only pass. → [gl_FragCoord.z against the depth stored for its own surface](../reference/shaders.md#gl_fragcoordz-against-the-depth-stored-for-its-own-surface)
- making a pipeline archive prints `Max Unstruct ID 758 in function agc.main in shader 13941 exceeds supported limit`, and one pipeline takes many minutes, in `metal-tt` offline or in the host's prebuild on the device (`Preparing pipelines` holding one count for minutes). The line is a note, not an error: `metal-tt` goes on, exits 0 and writes that pipeline into the archive. → [Front end at -O1: Apple's control-flow lowering](../reference/shaders.md#front-end-at--o1-apples-control-flow-lowering)
- the shader build prints `fatal error: bracket nesting level exceeded maximum of 256` and `<key>.metal: does not compile`, and the shader is left out. → [Bracket nesting past the front end's 256](../reference/shaders.md#bracket-nesting-past-the-front-ends-256)
+4 -4
View File
@@ -775,10 +775,10 @@ Finding, keying and translating shaders (`dm/gfx/tools/shader_split.py`, `dmsh_b
### The blend helper's output reference on iOS
- **Symptom:** iOS pixel shader compilation fails with `reference type must have explicit address space qualifier` at `dm_blend0(main0_out& dm_o, ...)`. The Mac libraries compile.
- **Cause:** `blend_zero` generated a reference without an address space. The iOS build targets Metal's iOS 18 language mode, which requires one; the Mac compiler's newer default accepts a generic reference. The output is a local variable of the fragment function.
- **Fix:** `dmsh_rewrite.py` declares the helper's output parameter `thread main0_out&`. The helper's behavior is unchanged. `test_dmsh_blend_zero.py` compiles the plain, integer-output, side and readable-tile variants for both macOS and the packing script's iOS 18 target.
- **Found on:** [The Binding of Isaac: Rebirth](../../dm/games/01009BC00C38A000/README.md): all 10 pixel shaders failed on iOS, while its 9 vertex shaders and all 19 Mac shaders compiled.
- **Symptom:** pixel shader compilation fails with `reference type must have explicit address space qualifier` at `dm_blend0(main0_out& dm_o, ...)`: every iOS build, and a Mac build made on macOS 26. A Mac build made on macOS 27 compiled, so the fault passed where it was written.
- **Cause:** `blend_zero` generated a reference without an address space (the output is a local variable of the fragment function). Metal's language version follows the deployment target: the iOS build names iOS 18, whose language requires the qualifier, and the Mac compile named none, so it took the build Mac's system. Measured with Metal front end 32023.922 on macOS 27.2, a shader with that signature: it compiles with no minimum and with iOS 27.0, and fails with `-mmacosx-version-min=26.0`, `15.0` and `-mios-version-min=18.0`. One chain version therefore gave different results on two Macs.
- **Fix:** `dmsh_rewrite.py` declares the helper's output parameter `thread main0_out&`; the helper's behavior is unchanged. Every Mac compile of a game's shaders now names the Mac host's minimum macOS (`MACOS_MIN` in `dm/mac/min_os.mk`, read as `dmsh_chain.MAC_MIN`): `dmsh_build.py`'s `MAC_METAL`, `vk_shaders.py` and `gl_shaders.py`, as the host's own libraries already did ([The host's own shaders compiled from source at run time](#the-hosts-own-shaders-compiled-from-source-at-run-time)). The file is part of the chain version and the flag is in each shader's cache key. `test_dmsh_blend_zero.py` compiles the plain, integer-output, side and readable-tile variants with both targets' flags, so the Mac case fails on any Mac.
- **Found on:** [The Binding of Isaac: Rebirth](../../dm/games/01009BC00C38A000/README.md): all 10 pixel shaders failed on iOS, while its 9 vertex shaders and all 19 Mac shaders compiled (macOS 27). [Ocarina of Time](../../dm/games/0400486024DEC000/README.md): 22,296 of 42,848 Mac shaders failed on two Macs with macOS 26 ([GitHub issue #2272](https://github.com/seedds/nxnative/issues/2272)); 42,848 built there with the qualifier (a reporter's run).
### gl_FragCoord.z against the depth stored for its own surface