diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 232b4cee32594..fc071759cd750 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -159,6 +159,24 @@ * and reasonable to implement across several platforms and underlying APIs. * So while these things are not in the "never" category, they are definitely * not "near future" items either. + * + * ## System Requirements + * + * **Vulkan:** Supported on Windows, Linux, Nintendo Switch, and certain Android devices. Requires Vulkan 1.0 with the following extensions and device features: + * - `VK_KHR_swapchain` + * - `VK_KHR_maintenance1` + * - `independentBlend` + * - `imageCubeArray` + * - `depthClamp` + * - `shaderClipDistance` + * - `drawIndirectFirstInstance` + * + * **D3D12:** Supported on Windows 10 or newer, Xbox One (GDK), and Xbox Series X|S (GDK). Requires a GPU that supports DirectX 12 Feature Level 11_1. + * + * **Metal:** Supported on macOS 10.14+ and iOS/tvOS 13.0+. Hardware requirements vary by operating system: + * - macOS requires an Apple Silicon or [Intel Mac2 family](https://developer.apple.com/documentation/metal/mtlfeatureset/mtlfeatureset_macos_gpufamily2_v1?language=objc) GPU + * - iOS/tvOS requires an A9 GPU or newer + * - iOS Simulator and tvOS Simulator are unsupported */ #ifndef SDL_gpu_h_ diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index 028e18a438633..d2a970a18b1a1 100644 --- a/src/gpu/metal/SDL_gpu_metal.m +++ b/src/gpu/metal/SDL_gpu_metal.m @@ -4180,7 +4180,7 @@ static bool METAL_SupportsTextureFormat( static bool METAL_PrepareDriver(SDL_VideoDevice *this) { - if (@available(macOS 10.13, iOS 13.0, tvOS 13.0, *)) { + if (@available(macOS 10.14, iOS 13.0, tvOS 13.0, *)) { return (this->Metal_CreateView != NULL); } return false; @@ -4342,6 +4342,7 @@ static void METAL_INTERNAL_DestroyBlitResources( @autoreleasepool { MetalRenderer *renderer; id device = NULL; + bool hasHardwareSupport = false; if (debugMode) { /* Due to a Metal driver quirk, once a MTLDevice has been created @@ -4372,6 +4373,23 @@ static void METAL_INTERNAL_DestroyBlitResources( } } +#ifdef SDL_PLATFORM_MACOS + if (@available(macOS 10.15, *)) { + hasHardwareSupport = [device supportsFamily:MTLGPUFamilyMac2]; + } else if (@available(macOS 10.14, *)) { + hasHardwareSupport = [device supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1]; + } +#else + if (@available(iOS 13.0, tvOS 13.0, *)) { + hasHardwareSupport = [device supportsFamily:MTLGPUFamilyApple3]; + } +#endif + + if (!hasHardwareSupport) { + SDL_SetError("Device does not meet the hardware requirements for SDL_GPU Metal"); + return NULL; + } + // Allocate and zero out the renderer renderer = (MetalRenderer *)SDL_calloc(1, sizeof(MetalRenderer));