27 [encoder setComputePipelineState:pipeline];
28 NSUInteger
w = pipeline.threadExecutionWidth;
29 NSUInteger
h = pipeline.maxTotalThreadsPerThreadgroup /
w;
30 MTLSize threadsPerThreadgroup = MTLSizeMake(
w,
h, 1);
32#ifdef MAC_OS_X_VERSION_10_15
33 if (@available(macOS 10.15, iOS 13, tvOS 14.5, *)) {
34 if ([device supportsFamily:MTLGPUFamilyCommon3]) {
35 MTLSize threadsPerGrid = MTLSizeMake(
width,
height, 1);
36 [encoder dispatchThreads:threadsPerGrid threadsPerThreadgroup:threadsPerThreadgroup];
44 MTLSize threadgroups = MTLSizeMake((
width +
w - 1) /
w,
47 [encoder dispatchThreadgroups:threadgroups threadsPerThreadgroup:threadsPerThreadgroup];
52 CVMetalTextureCacheRef textureCache,
53 CVPixelBufferRef pixbuf,
57 CVMetalTextureRef tex =
NULL;
60 ret = CVMetalTextureCacheCreateTextureFromImage(
66 CVPixelBufferGetWidthOfPlane(pixbuf, plane),
67 CVPixelBufferGetHeightOfPlane(pixbuf, plane),
71 if (ret != kCVReturnSuccess) {
void ff_metal_compute_encoder_dispatch(id< MTLDevice > device, id< MTLComputePipelineState > pipeline, id< MTLComputeCommandEncoder > encoder, NSUInteger width, NSUInteger height)
CVMetalTextureRef ff_metal_texture_from_pixbuf(void *ctx, CVMetalTextureCacheRef textureCache, CVPixelBufferRef pixbuf, int plane, MTLPixelFormat format)