oF with Metal Compute Shader, is it possible?

Hello!
Currently, macOS does not support openGL 4.3 so we can’t use compute shader.
So I came up an idea to use Metal shader for calucation and transport the result back to openGL.

Metal compute shader
https://developer.apple.com/documentation/metal/performing_calculations_on_a_gpu

Does anyone have an experience like this?
We can use OpenGL and Metal API simultaneously, but I’m not sure about the impact of video memory sharing/copying. I found ofxMetal which draws ofBoxPrimitive with Metal texture attached, so it seems possible. I haven’t tried compiling though.

It would be good to say good-bye to Ping-pong shader finally.

1 Like

my memory is hazy, but I think ofxArKit uses a metal shader internally –

some info on some of the steps of mixing gl and metal

https://developer.apple.com/documentation/metal/metal_sample_code_library/mixing_metal_and_opengl_rendering_in_a_view

2 Likes

@dimitre
Thank you for the info. Wow, didn’t know this GL on Metal exist.
It even has GLFW support. Incredible.
Negative point is that it has a lot of missing functions.
Have you managed to use GL 4.6 + oF (on macOS)?

@zach
It has a Metal shader indeed, Shader.metal is the one.
It seems very helpful as a real-world example how to use Metal together with oF.
I will look into it.
Thank you!

Hey @hrs no I never tried.

Hey thanks all for posting about this! I’ve been wondering about it for quite a while and its been a low priority so I haven’t had a chance to look at it. But its really fun to know that this exists in case I need it some day!

1 Like