mirror of
https://github.com/love2d/love.git
synced 2026-08-12 00:20:52 +02:00
metal: support shader atomics for int/uint textures, on macOS 14+ and iOS 17+.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user