SDL: gpu: Add SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1 property

From 16f2037efddd57222b8ab707e6222d9e57ceab2e Mon Sep 17 00:00:00 2001
From: Ethan Lee <[EMAIL REDACTED]>
Date: Sun, 25 Jan 2026 11:35:22 -0500
Subject: [PATCH] gpu: Add SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1
 property

---
 include/SDL3/SDL_gpu.h        | 10 ++++++++++
 src/gpu/metal/SDL_gpu_metal.m | 12 ++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h
index 10b132b9835e5..a3b7a5077c176 100644
--- a/include/SDL3/SDL_gpu.h
+++ b/include/SDL3/SDL_gpu.h
@@ -2321,6 +2321,15 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDevice(
  *   increasing the API version and opting into extensions aside from the
  *   minimal set SDL requires.
  *
+ * With the Metal backend:
+ * - `SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1`: By default, macOS
+ *   support requires what Apple calls "MTLGPUFamilyMac2" hardware or newer.
+ *   However, an application can set this property to true to enable support
+ *   for "MTLGPUFamilyMac1" hardware, if (and only if) the application does
+ *   not write to sRGB textures. (For history's sake: MacFamily1 also does not
+ *   support indirect command buffers, MSAA depth resolve, and stencil
+ *   resolve/feedback, but these are not exposed features in SDL_GPU.)
+ *
  * \param props the properties to use.
  * \returns a GPU context on success or NULL on failure; call SDL_GetError()
  *          for more information.
@@ -2353,6 +2362,7 @@ extern SDL_DECLSPEC SDL_GPUDevice * SDLCALL SDL_CreateGPUDeviceWithProperties(
 #define SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING                   "SDL.gpu.device.create.d3d12.semantic"
 #define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_REQUIRE_HARDWARE_ACCELERATION_BOOLEAN         "SDL.gpu.device.create.vulkan.requirehardwareacceleration"
 #define SDL_PROP_GPU_DEVICE_CREATE_VULKAN_OPTIONS_POINTER                       "SDL.gpu.device.create.vulkan.options"
+#define SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1                       "SDL.gpu.device.create.metal.allowmacfamily1"
 
 
 /**
diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m
index d6c48f65962b0..3c80bac9f7333 100644
--- a/src/gpu/metal/SDL_gpu_metal.m
+++ b/src/gpu/metal/SDL_gpu_metal.m
@@ -4527,10 +4527,18 @@ static void METAL_INTERNAL_DestroyBlitResources(
 
 #ifdef SDL_PLATFORM_MACOS
         hasHardwareSupport = true;
+        bool allowMacFamily1 = SDL_GetBooleanProperty(
+            props,
+            SDL_PROP_GPU_DEVICE_CREATE_METAL_ALLOW_MACFAMILY1,
+            false);
         if (@available(macOS 10.15, *)) {
-            hasHardwareSupport = [device supportsFamily:MTLGPUFamilyMac2];
+            hasHardwareSupport = allowMacFamily1 ?
+                [device supportsFamily:MTLGPUFamilyMac1] :
+                [device supportsFamily:MTLGPUFamilyMac2];
         } else if (@available(macOS 10.14, *)) {
-            hasHardwareSupport = [device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1];
+            hasHardwareSupport = allowMacFamily1 ?
+                [device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v4] :
+                [device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1];
         }
 #elif defined(SDL_PLATFORM_VISIONOS)
         hasHardwareSupport = true;