23 id<MTLComputePipelineState> pipeline,
24 id<MTLComputeCommandEncoder> encoder,
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 11, 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) {