metal: support shader atomics for int/uint textures, on macOS 14+ and iOS 17+.

This commit is contained in:
Sasha Szpakowski
2026-07-24 17:03:15 -03:00
parent b392d21536
commit 792690b73d
2 changed files with 12 additions and 3 deletions
+5
View File
@@ -2025,6 +2025,11 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage)
case PIXELFORMAT_RGB10A2_UINT:
// If MSAA support for int formats is added this should be split up.
flags |= sample | rt | computewrite;
if (format == PIXELFORMAT_R32_INT || format == PIXELFORMAT_R32_UINT)
{
if (@available(macOS 14.0, iOS 17.0, *))
flags |= PIXELFORMATUSAGEFLAGS_SHADERATOMICS;
}
break;
case PIXELFORMAT_RGBA4_UNORM:
+6 -2
View File
@@ -537,6 +537,9 @@ void Shader::compileFromGLSLang(id<MTLDevice> device, const glslang::TProgram &p
}
CompilerMSL::Options options;
if (@available(macOS 14.0, iOS 17.0, *))
options.set_msl_version(3, 1); // For image atomics.
else
options.set_msl_version(2, 1);
options.texture_buffer_native = true;
#ifdef LOVE_IOS
@@ -556,8 +559,9 @@ void Shader::compileFromGLSLang(id<MTLDevice> device, const glslang::TProgram &p
MTLCompileOptions *opts = [MTLCompileOptions new];
// Silences warning. We already only use metal on these OS versions.
if (@available(macOS 10.14, iOS 12.0, *))
if (@available(macOS 14.0, iOS 17.0, *))
opts.languageVersion = MTLLanguageVersion3_1; // For image atomics.
else
opts.languageVersion = MTLLanguageVersion2_1;
NSError *err = nil;