[PR] avfilter/metal: use Apple5 for 27.0 targets (PR #23994)

iSoldLeo via ffmpeg-devel <[email protected]> Mon, 03 Aug 2026 09:02:11 -0000
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178574773188.59.14635042561642092659@29965ddac10e>
PR #23994 opened by iSoldLeo
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23994
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23994.patch

The 27.0 Apple SDKs deprecate `MTLGPUFamilyCommon3` in favor of
`MTLGPUFamilyApple5`. The deprecation warning is emitted when the
minimum deployment target is 27.0 or newer.

Use Apple5 for those targets and retain Common3 for earlier deployment
targets, where it is not deprecated.

Tested on an Apple M4 Mac:

- full builds and local FATE with minimum macOS deployment targets 15.0
  and 27.0
- direct Metal dispatch tests across 40 cases
- Objective-C compile checks covering the pre-27.0 and 27.0 branches
  for macOS, iOS, tvOS, and visionOS


>From 7578c65d01460eb8227dc7723decc9f9842c66dd Mon Sep 17 00:00:00 2001
From: iSold Leo <[email protected]>
Date: Mon, 3 Aug 2026 16:49:07 +0800
Subject: [PATCH] avfilter/metal: use Apple5 for 27.0 targets

MTLGPUFamilyCommon3 is deprecated for Apple platform deployment
targets starting with version 27.0, with MTLGPUFamilyApple5 as its
replacement.

Use Apple5 for those targets and retain Common3 for earlier deployment
targets, where it is not deprecated.

Signed-off-by: iSold Leo <[email protected]>
---
 libavfilter/metal/utils.m | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavfilter/metal/utils.m b/libavfilter/metal/utils.m
index 3c28a16f60..c28761cc1e 100644
--- a/libavfilter/metal/utils.m
+++ b/libavfilter/metal/utils.m
@@ -31,7 +31,19 @@ void ff_metal_compute_encoder_dispatch(id<MTLDevice> device,
     // MAC_OS_X_VERSION_10_15 is only defined on SDKs new enough to include its functionality (including iOS, tvOS, etc)
 #ifdef MAC_OS_X_VERSION_10_15
     if (@available(macOS 10.15, iOS 13, tvOS 14.5, *)) {
-        if ([device supportsFamily:MTLGPUFamilyCommon3]) {
+#if (defined(__MAC_27_0) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
+     __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_27_0) || \
+    (defined(__IPHONE_27_0) && defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
+     __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_27_0) || \
+    (defined(__TVOS_27_0) && defined(__TV_OS_VERSION_MIN_REQUIRED) && \
+     __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_27_0) || \
+    (defined(__VISIONOS_27_0) && defined(__VISION_OS_VERSION_MIN_REQUIRED) && \
+     __VISION_OS_VERSION_MIN_REQUIRED >= __VISIONOS_27_0)
+        const MTLGPUFamily dispatch_family = MTLGPUFamilyApple5;
+#else
+        const MTLGPUFamily dispatch_family = MTLGPUFamilyCommon3;
+#endif
+        if ([device supportsFamily:dispatch_family]) {
             MTLSize threadsPerGrid = MTLSizeMake(width, height, 1);
             [encoder dispatchThreads:threadsPerGrid threadsPerThreadgroup:threadsPerThreadgroup];
             return;
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]