【发布时间】:2019-04-19 21:39:53
【问题描述】:
例如,如果我要进行灰度转换,我需要通过以下方式设置我的threadsPerGroup和线程组。
NSUInteger maxTotalThreadsPerThreadgroup = [self.computePipelineState maxTotalThreadsPerThreadgroup];
MTLSize threadgroupCounts = MTLSizeMake(threadExecutionWidth * 2, threadExecutionWidth * 2, 1);
MTLSize threadsPerThreadGroup = MTLSizeMake([self.texutre width] / threadgroupCounts.width + 1,
[self.texutre height] / threadgroupCounts.height + 1,
1);
我知道图像会被分割成不同的块,每个块将由一个线程组处理。但好像在内核中,我们只会读取二维纹理,然后输出处理后的纹理。
但问题是如何将图像切成不同的 2d 纹理?我们如何知道每个图像块是否被分配给一个线程来处理?这是由 Metal 自己完成的吗?或者我们需要使用 gid 手动将每个块分配给每个线程组?
【问题讨论】:
标签: metal