diff options
author | rcombs <rcombs@rcombs.me> | 2021-12-21 02:38:18 -0600 |
---|---|---|
committer | rcombs <rcombs@rcombs.me> | 2021-12-22 18:43:34 -0600 |
commit | 8e24a8e93a9e0326967cf61a5caa243f566b3f81 (patch) | |
tree | e512ced14a91446de0c4d96501bd2d231f519c6e /libavfilter/metal | |
parent | 0f77ee9d97a9a9ed56da59a192acc616f574b932 (diff) | |
download | ffmpeg-8e24a8e93a9e0326967cf61a5caa243f566b3f81.tar.gz |
lavfi/metal: fix build with pre-10.11 deployment targets
- Ensure the yadif .metal compiles when targeting any Metal runtime version
- Use some preprocessor awkwardness to ensure Core Video's Metal-specific
functionality is exposed regardless of our deployment target (this works
around what seems to be an SDK header bug, filed as FB9816002)
- Ensure all direct references to Metal functions and classes are gated
behind runtime version checks (this satisfies clang's deployment-target
violation warnings provided by -Wunguarded-availability).
Diffstat (limited to 'libavfilter/metal')
-rw-r--r-- | libavfilter/metal/utils.h | 28 | ||||
-rw-r--r-- | libavfilter/metal/vf_yadif_videotoolbox.metal | 11 |
2 files changed, 36 insertions, 3 deletions
diff --git a/libavfilter/metal/utils.h b/libavfilter/metal/utils.h index bd0319f63c..7350d42a35 100644 --- a/libavfilter/metal/utils.h +++ b/libavfilter/metal/utils.h @@ -20,16 +20,40 @@ #define AVFILTER_METAL_UTILS_H #include <Metal/Metal.h> + +#include <AvailabilityMacros.h> + +// CoreVideo accidentally(?) preprocessor-gates Metal functionality +// on MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 (FB9816002). +// There doesn't seem to be any particular reason for this, +// so here we temporarily redefine it to at least that value +// so CV will give us CVMetalTextureRef and the related functions. + +#if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && (MAC_OS_X_VERSION_MIN_REQUIRED < 101100) +#define ORIG_MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_MIN_REQUIRED +#undef MAC_OS_X_VERSION_MIN_REQUIRED +#define MAC_OS_X_VERSION_MIN_REQUIRED 101100 +#endif + #include <CoreVideo/CoreVideo.h> +#ifdef ORIG_MAC_OS_X_VERSION_MIN_REQUIRED +#undef MAC_OS_X_VERSION_MIN_REQUIRED +#define MAC_OS_X_VERSION_MIN_REQUIRED ORIG_MAC_OS_X_VERSION_MIN_REQUIRED +#undef ORIG_MAC_OS_X_VERSION_MIN_REQUIRED +#endif + void ff_metal_compute_encoder_dispatch(id<MTLDevice> device, id<MTLComputePipelineState> pipeline, id<MTLComputeCommandEncoder> encoder, - NSUInteger width, NSUInteger height); + NSUInteger width, NSUInteger height) + API_AVAILABLE(macos(10.11), ios(8.0)); CVMetalTextureRef ff_metal_texture_from_pixbuf(void *avclass, CVMetalTextureCacheRef textureCache, CVPixelBufferRef pixbuf, int plane, - MTLPixelFormat format); + MTLPixelFormat format) + API_AVAILABLE(macos(10.11), ios(8.0)); + #endif /* AVFILTER_METAL_UTILS_H */ diff --git a/libavfilter/metal/vf_yadif_videotoolbox.metal b/libavfilter/metal/vf_yadif_videotoolbox.metal index 50783f2ffe..8a3d41a30f 100644 --- a/libavfilter/metal/vf_yadif_videotoolbox.metal +++ b/libavfilter/metal/vf_yadif_videotoolbox.metal @@ -27,6 +27,15 @@ using namespace metal; /* + * Version compat shims + */ + +#if __METAL_VERSION__ < 210 +#define max3(x, y, z) max(x, max(y, z)) +#define min3(x, y, z) min(x, min(y, z)) +#endif + +/* * Parameters */ @@ -44,7 +53,7 @@ struct deintParams { */ #define accesstype access::sample -const sampler s(coord::pixel); +constexpr sampler s(coord::pixel); template <typename T> T tex2D(texture2d<float, access::sample> tex, uint x, uint y) |