Bump generated MSL version to that used on macOS 14

This commit is contained in:
Kovid Goyal 2026-11-04 20:53:27 +05:30
parent b09c6d7b04
commit 3b2d4e7e37
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
5 changed files with 14 additions and 10 deletions

View file

@ -124,7 +124,7 @@ connect_to_display(void *driver, const GPUNativeWindow *display) {
set_error(d, "No Metal capable GPU found");
return false;
}
// MSL 2.4 needs macOS 12, every Mac that can run it supports the Mac2 or Apple7 GPU families.
// MSL 3.1 needs macOS 14, every Mac that can run it supports the Mac2 or Apple7 GPU families.
// Mac2 is deprecated from macOS 27, which no longer supports the Intel Macs that need it.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

View file

@ -16,7 +16,7 @@
#include "version.h"
// The language version passed to the MSL compiler, see compile_library()
_Static_assert(MSL_VERSION == 24, "Update the MTLLanguageVersion used for compiling shaders");
_Static_assert(MSL_VERSION == 31, "Update the MTLLanguageVersion used for compiling shaders");
#define AS_PIPELINE(handle) ((Pipeline *)(uintptr_t)(handle))
#define AS_LAYOUT(handle) ((VertexLayout *)(uintptr_t)(handle))
@ -127,7 +127,7 @@ compile_library(Driver *d, const GPUShaderSource *s) {
return nil;
}
MTLCompileOptions *opts = [[[MTLCompileOptions alloc] init] autorelease];
[opts setLanguageVersion:MTLLanguageVersion2_4];
[opts setLanguageVersion:MTLLanguageVersion3_1];
// OpenGL on Apple GPUs is implemented on top of Metal and uses fast
// math, so that is needed for rendering to match it exactly, for
// example in the pow() of the gamma adjustments of text. Relaxed math

View file

@ -8,5 +8,6 @@
#pragma once
// The version of the Metal Shading Language shaders are compiled to, as
// major * 10 + minor. MSL 2.4 is supported from macOS 12, kitty requires macOS 14.
#define MSL_VERSION 24
// major * 10 + minor. MSL 3.1 is the version supported by macOS 14, the
// minimum macOS version required by kitty.
#define MSL_VERSION 31

View file

@ -208,7 +208,7 @@ def variant_name(variant: dict[str, str], default: dict[str, str]) -> str:
class ShaderTarget(NamedTuple):
# The shader target consumed by a GPU driver, identified by strings of the
# form family-version, for example glsl-140, spirv-16 (SPIR-V 1.6) or
# msl-24 (Metal Shading Language 2.4). Built-in shaders are compiled for
# msl-31 (Metal Shading Language 3.1). Built-in shaders are compiled for
# the targets of the drivers being built, at build time, and custom
# shaders for the target of the loaded driver, at runtime. GLSL targets
# produce one text file per stage, SPIR-V and MSL targets a single module,
@ -1208,9 +1208,12 @@ def metal_compiler_available() -> bool:
def msl_validation_command(target: ShaderTarget, path: str) -> list[str]:
# Compile the MSL with the Metal compiler, discarding the output
# Compile the MSL with the Metal compiler, discarding the output. From
# Metal 3.0 the language standard is shared by all platforms and so has no
# platform prefix.
major, minor = divmod(target.version, 10)
return ['xcrun', '-sdk', 'macosx', 'metal', f'-std=macos-metal{major}.{minor}', '-c', path, '-o', os.devnull]
std = f'metal{major}.{minor}' if major >= 3 else f'macos-metal{major}.{minor}'
return ['xcrun', '-sdk', 'macosx', 'metal', f'-std={std}', '-c', path, '-o', os.devnull]
# }}}

View file

@ -162,7 +162,7 @@ struct vertex_main_Result_0
# Slang assigns Metal argument table indices itself, they are passed
# as native names, while the slots remain those of SHADER_BINDING_SLOTS
target = ShaderTarget.parse('msl-24')
target = ShaderTarget.parse('msl-31')
self.assertTrue(target.is_msl and target.is_single_module)
scalar = {'kind': 'scalar', 'scalarType': 'float32'}
@ -197,7 +197,7 @@ struct vertex_main_Result_0
'entryPoints': [{'name': 'vertex_main', 'stage': 'vertex', 'parameters': []}, {'name': 'fragment_main', 'stage': 'fragment', 'parameters': []}],
}
m = program_metadata(target, [refl], GLSLMetadata())
self.ae(m['target'], 'msl-24')
self.ae(m['target'], 'msl-31')
self.ae(m['entry_points'], {'vertex': 'vertex_main', 'fragment': 'fragment_main'})
self.ae(m['textures'], {'sprites': 0})
self.ae(m['blocks']['CellRenderData']['slot'], 6)