--- ds4_metal.m.orig +++ ds4_metal.m @@ -13,6 +13,16 @@ #include "ds4.h" #include "ds4_gpu.h" +/* + * MTLResidencySet is a macOS 15 SDK API. Runtime @available checks are not + * enough when building against older SDKs because the types are unavailable. + */ +#ifndef __MAC_15_0 +#define DS4_METAL_HAS_RESIDENCY_SETS 0 +#else +#define DS4_METAL_HAS_RESIDENCY_SETS (__MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_15_0) +#endif + /* * Objective-C Metal glue for the C engine. * @@ -356,7 +364,7 @@ } static void ds4_gpu_model_residency_clear(void) { -#if TARGET_OS_OSX +#if TARGET_OS_OSX && DS4_METAL_HAS_RESIDENCY_SETS if (@available(macOS 15.0, *)) { if (g_model_residency_set) { [g_model_residency_set endResidency]; @@ -372,7 +380,7 @@ static int ds4_gpu_model_residency_request_views(void) { if (g_model_view_count == 0 || getenv("DS4_METAL_NO_RESIDENCY") != NULL) return 1; -#if TARGET_OS_OSX +#if TARGET_OS_OSX && DS4_METAL_HAS_RESIDENCY_SETS if (@available(macOS 15.0, *)) { /* * Register all model views as one residency set before inference. This