Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU: Document system requirements, add upfront Metal hardware support checks #11695

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/SDL3/SDL_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`
TheSpydog marked this conversation as resolved.
Show resolved Hide resolved
* - `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_
Expand Down
20 changes: 19 additions & 1 deletion src/gpu/metal/SDL_gpu_metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4342,6 +4342,7 @@ static void METAL_INTERNAL_DestroyBlitResources(
@autoreleasepool {
MetalRenderer *renderer;
id<MTLDevice> device = NULL;
bool hasHardwareSupport = false;

if (debugMode) {
/* Due to a Metal driver quirk, once a MTLDevice has been created
Expand Down Expand Up @@ -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));

Expand Down
Loading