GPUImage3 icon indicating copy to clipboard operation
GPUImage3 copied to clipboard

Will custom kernel support be integrated in the future?

Open ZkHaider opened this issue 5 years ago • 4 comments

Just wondering if there will be support for custom kernels.

ZkHaider avatar Feb 20 '19 10:02 ZkHaider

What specifically do you mean by custom kernels? The framework is built to allow custom Metal shaders, and you can do that right now using BasicOperation or your own subclass. All the code should be exposed to provide for this, and the previous versions of GPUImage both were used by many people who had their own custom shaders.

If you're speaking specifically about convolution kernels, we recently migrated over the Convolution3x3 operation that lets you specify custom 3x3 convolution kernels easily. I have it on my list to do the same for other convolution sizes, but again you can write your own Metal shader to do this right now.

BradLarson avatar Feb 20 '19 16:02 BradLarson

What specifically do you mean by custom kernels?

Right to be more specific what I meant is that will you make it easier to write out custom kernels with GPUImage3. Just like with BasicOperation you can load your own custom fragmentShaderFunction, maybe something like GPUKernel(withKernelFunction: "my_kernel_function", libraryURL: url) to load your own custom kernel functions. You can obviously do this manually but I was just wondering if you will make that process more abstract and simpler to function with GPUImage3

ZkHaider avatar Feb 21 '19 20:02 ZkHaider

Oh right, you're talking about Metal compute kernels. I'm so used to dealing with OpenGL I didn't think about that.

This is definitely something we'd like to explore, and to benchmark render fragment shaders vs. compute kernels for similar operations (as we've started to do for Metal Performance Shaders vs. handwritten shaders). Being able to slot the latter in to give more flexibility on what you can do in a pipeline would also potentially open up other applications.

From an architectural standpoint, I don't think we'd have a problem with this, because while we use render command encoders in the stages of a pipeline, you should be able to inject compute ones in between that. We'll think about it, once we get everything ported across from the older frameworks.

BradLarson avatar Feb 21 '19 22:02 BradLarson

Awesome! That would make GPUImage even more extensible. Currently I am using MetalPetal to allow me to write out compute and rendering pipelines in a simplified way.

Metal Petal

☝️ That's why I brought up support for Compute Kernels in GPUImage3 something like that would make this framework much more powerful.

ZkHaider avatar Feb 21 '19 22:02 ZkHaider