Created
September 26, 2021 18:10
-
-
Save MasDennis/e9fb5ad11739389be9d9279fc2cc1d2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func setupComputePipeline(targetTexture: MTLTexture) { | |
guard let device = MTLCreateSystemDefaultDevice(), | |
let library = device.makeDefaultLibrary(), | |
let postProcessingKernel = library.makeFunction(name: "inverseColorKernel"), | |
let pipelineState = try? device.makeComputePipelineState(function: postProcessingKernel) | |
else { | |
assertionFailure() | |
return | |
} | |
computePipelineState = pipelineState | |
threadsPerThreadgroup = MTLSize(width: pipelineState.threadExecutionWidth, | |
height: pipelineState.maxTotalThreadsPerThreadgroup / pipelineState.threadExecutionWidth, | |
depth: 1) | |
threadgroupsPerGrid = MTLSize(width: (targetTexture.width + threadsPerThreadgroup.width - 1) / threadsPerThreadgroup.width, | |
height: (targetTexture.height + threadsPerThreadgroup.height - 1) / threadsPerThreadgroup.height, | |
depth: 1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment