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);
33 #ifdef MAC_OS_X_VERSION_10_15
34 if (@
available(macOS 10.15, iOS 11, tvOS 14.5, *)) {
35 if ([device supportsFamily:MTLGPUFamilyCommon3]) {
36 MTLSize threadsPerGrid = MTLSizeMake(
width,
height, 1);
37 [encoder dispatchThreads:threadsPerGrid threadsPerThreadgroup:threadsPerThreadgroup];
43 MTLSize threadgroups = MTLSizeMake((
width +
w - 1) /
w,
46 [encoder dispatchThreadgroups:threadgroups threadsPerThreadgroup:threadsPerThreadgroup];
51 CVMetalTextureCacheRef textureCache,
52 CVPixelBufferRef pixbuf,
56 CVMetalTextureRef tex =
NULL;
59 ret = CVMetalTextureCacheCreateTextureFromImage(
65 CVPixelBufferGetWidthOfPlane(pixbuf, plane),
66 CVPixelBufferGetHeightOfPlane(pixbuf, plane),
70 if (
ret != kCVReturnSuccess) {