From 14feaf4ba8108251fcea9d4d311451a313299b65 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Sun, 29 Sep 2024 23:58:23 -0500 Subject: [PATCH 1/2] VideoBackends:Metal: Use ios_use_simdgroup_functions with SPIRV-Cross It defaults to trying to emulate simdgroup functions on iOS --- Source/Core/VideoBackends/Metal/MTLUtil.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Core/VideoBackends/Metal/MTLUtil.mm b/Source/Core/VideoBackends/Metal/MTLUtil.mm index b9a195b555..4785084e62 100644 --- a/Source/Core/VideoBackends/Metal/MTLUtil.mm +++ b/Source/Core/VideoBackends/Metal/MTLUtil.mm @@ -559,6 +559,9 @@ std::optional Metal::Util::TranslateShaderToMSL(ShaderStage stage, options.platform = spirv_cross::CompilerMSL::Options::macOS; #elif TARGET_OS_IOS options.platform = spirv_cross::CompilerMSL::Options::iOS; + // Otherwise SPIRV-Cross will try to compile subgroup ops to quad ops instead + // (And crash because there's no quad_min or quad_max) + options.ios_use_simdgroup_functions = Metal::g_features.subgroup_ops; #else #error What platform is this? #endif From 70f69c3213c144536ab328b514e96fd2f8bd5146 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Mon, 30 Sep 2024 23:38:23 -0500 Subject: [PATCH 2/2] VideoBackends:Metal: subgroup_ops requires Apple7, not Apple6 SIMD-scoped permute operations are Apple6, but reduction operations are Apple7 --- Source/Core/VideoBackends/Metal/MTLUtil.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoBackends/Metal/MTLUtil.mm b/Source/Core/VideoBackends/Metal/MTLUtil.mm index 4785084e62..de073280d7 100644 --- a/Source/Core/VideoBackends/Metal/MTLUtil.mm +++ b/Source/Core/VideoBackends/Metal/MTLUtil.mm @@ -309,7 +309,7 @@ void Metal::Util::PopulateBackendInfoFeatures(VideoConfig* config, id { // Requires SIMD-scoped reduction operations g_features.subgroup_ops = - [device supportsFamily:MTLGPUFamilyMac2] || [device supportsFamily:MTLGPUFamilyApple6]; + [device supportsFamily:MTLGPUFamilyMac2] || [device supportsFamily:MTLGPUFamilyApple7]; config->backend_info.bSupportsFramebufferFetch = [device supportsFamily:MTLGPUFamilyApple1]; } if (g_features.subgroup_ops)