From 69446d122d99fa9d28dbc15d8ea88b777b9f8650 Mon Sep 17 00:00:00 2001 From: Jan Sikorski Date: Wed, 6 Mar 2024 11:35:47 +0100 Subject: [PATCH 1/2] MVKBuffer: Only set MTLTextureUsageShaderAtomic on views with supported pixel format. --- MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm b/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm index a8a9b38b9..7a7922457 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKBuffer.mm @@ -292,7 +292,7 @@ if ( mvkIsAnyFlagEnabled(_buffer->getUsage(), VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT) ) { usage |= MTLTextureUsageShaderWrite; #if MVK_XCODE_15 - if (getPhysicalDevice()->useNativeTextureAtomics()) + if (getPhysicalDevice()->useNativeTextureAtomics() && (_mtlPixelFormat == MTLPixelFormatR32Sint || _mtlPixelFormat == MTLPixelFormatR32Uint || _mtlPixelFormat == MTLPixelFormatRG32Uint)) usage |= MTLTextureUsageShaderAtomic; #endif } From e388a0e3af500702d0442c472d9a638ad7fce9a6 Mon Sep 17 00:00:00 2001 From: Jan Sikorski Date: Wed, 6 Mar 2024 12:08:58 +0100 Subject: [PATCH 2/2] MVKPixelFormats: Only set MTLTextureUsageShaderAtomic for supported pixel format. --- MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm index cf96c2ad1..857c85b76 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm @@ -722,7 +722,7 @@ } #if MVK_XCODE_15 - if (supportAtomics) { + if (supportAtomics && (mtlFormat == MTLPixelFormatR32Uint || mtlFormat == MTLPixelFormatR32Sint || mtlFormat == MTLPixelFormatRG32Uint)) { mvkEnableFlags(mtlUsage, MTLTextureUsageShaderAtomic); } #endif