Quartz/CoreGraphics is broken. What to do now?
- u-he
- Topic Starter
- 28062 posts since 8 Aug, 2002 from Berlin
After profiling our UIs, there's only one conclusion left: Quartz Extreme is no more, Apple renders CoreGraphics paths on the CPU. That's on a decent hexacore trashcan Mac. And they do it muuuuuch slower than I can do it myself. But when I do it myself a whopping 10 times faster, the bottleneck is the offscreen graphics context which, when turned into a CGImage, Apple just can't seem to forward to the GPU in time.
So what are you guys doing these days, particularly with OpenGL dead on macOS as well? Metal? Or is there some other API which popped up over the last decade which I conveniently ignored?
Not sure if I need an answer or if I just wanted to vent, but I guess I'd be grateful for some pointers.
So what are you guys doing these days, particularly with OpenGL dead on macOS as well? Metal? Or is there some other API which popped up over the last decade which I conveniently ignored?
Not sure if I need an answer or if I just wanted to vent, but I guess I'd be grateful for some pointers.
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
Write an OpenGL code-path (deprecated or not) that resolves the pressing issues, then file a TODO item about replacing said code-path with a Metal alternative "when time permits."
- u-he
- Topic Starter
- 28062 posts since 8 Aug, 2002 from Berlin
Argh. I really wish for something a tad more permanent. I've done OpenGL 20 years ago, I know the pains.
Does anyone know if Cairo ist hardware accelerated on old Macs with recent OSes? We got Cairo foing on Linux, maybe it's time to set it up on macOS?
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
If you're drawing in software and just uploading a texture and drawing a quad, I don't think it's that bad. The main painful part is just getting the context management right, to avoid random crashes.
Keep in mind that once you require Metal, you'll also require macOS 10.11 minimum. Whether that's a concern for you, I don't know... but it's something to keep in mind.
- u-he
- Topic Starter
- 28062 posts since 8 Aug, 2002 from Berlin
True.
I guess I want neither OpenGL nor Metal. I want something that doesn't require writing a shader in order to paint a vector UI with some bitmaps thrown in.
Also, I want unicode fonts. And I don't want to parse them into paths first in order to display some text.
In other words, I want a working and viable alternative to CoreGraphics which doesn't take 50% of 3.6GHz CPU to render a path with 500 points at 25Hz.
I guess I want neither OpenGL nor Metal. I want something that doesn't require writing a shader in order to paint a vector UI with some bitmaps thrown in.
Also, I want unicode fonts. And I don't want to parse them into paths first in order to display some text.
In other words, I want a working and viable alternative to CoreGraphics which doesn't take 50% of 3.6GHz CPU to render a path with 500 points at 25Hz.
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
Well... you CAN use legacy OpenGL with fixed-function pipeline to avoid the shader.
-
- KVRian
- 755 posts since 29 Jan, 2017
There was some project like Cairo OpenGL but it was experimental/abandoned so it’s still CPU only. Bitwig is based on Cairo and they are lagging badly on MacOSes
OpenGL is deprecated...How can you not love Apple?
-
- KVRist
- 83 posts since 27 Nov, 2018
I think moving to Metal is the most future proof on MacOS.
https://moltengl.com/moltengl/
There is this which converts OpenGL ES to Metal. Not sure how hard it would be for you to convert your initial code from OpenGL to OpenGL ES.
Alternative for the future you could might use Vulcan on Windows and Linux and use MoltenVK, which converts Vulcan to Metal and is open source.
https://github.com/KhronosGroup/MoltenVK
Both SDK are quite feature complete and get update frequently. They get used by other bigger companies and seem easy to implement.
https://moltengl.com/moltengl/
There is this which converts OpenGL ES to Metal. Not sure how hard it would be for you to convert your initial code from OpenGL to OpenGL ES.
Alternative for the future you could might use Vulcan on Windows and Linux and use MoltenVK, which converts Vulcan to Metal and is open source.
https://github.com/KhronosGroup/MoltenVK
Both SDK are quite feature complete and get update frequently. They get used by other bigger companies and seem easy to implement.
-
- KVRian
- 833 posts since 21 Feb, 2006 from FI
Hmm... this change was reported to come about 9 months ago - https://appleinsider.com/articles/18/06 ... tes-opengl
- KVRian
- 872 posts since 6 Aug, 2005 from England
OpenGL was redacted. Thankfully there’s this...
https://www.phoronix.com/scan.php?page= ... ed-MVK-App
https://www.phoronix.com/scan.php?page= ... ed-MVK-App
Dave Hoskins. http://www.quikquak.com
-
- KVRist
- 184 posts since 21 Aug, 2004
Check out CALayers and its property drawsAsynchronously. CoreGraphics may use the GPU instead of the CPU when rendering into such a configured CALayer. It's not documented though, so may change anytime.
- u-he
- Topic Starter
- 28062 posts since 8 Aug, 2002 from Berlin
Thanks Arne,
I read into CALayers last night, but it seems they work best if they are immutable objects. What really slows us down on Mac are dynamic elements: Waveshape/Envelope displays, spectrum, anything that uses a lot of bezier paths and can't be cached.
But maybe I got that wrong. Maybe one can draw into a CALayer and then have it paint asynchronously later? In that case I might give it a shot!
- U
-
- KVRist
- 184 posts since 21 Aug, 2004
Yes, you can setup your NSView so that it draws into a CALayer. VSTGUI is using it. After creating the view you just call [nsView setWantsLayer:YES]; and nsView.layer.drawsAsynchronously = YES; No other code change required to check it out.
- u-he
- Topic Starter
- 28062 posts since 8 Aug, 2002 from Berlin
That sounds great! As I said, my OpenGl experience was 20 years ago and pre-dates shaders and stuff. How hard is it these days to render a full unicode set of fonts? Like, using a TrueType font for all the ordinary UI stuff and getting a fallback font from the system for user edited text which can contain *any* unicode glyph?flocked wrote: ↑Fri Mar 15, 2019 7:26 am I think moving to Metal is the most future proof on MacOS.
https://moltengl.com/moltengl/
There is this which converts OpenGL ES to Metal. Not sure how hard it would be for you to convert your initial code from OpenGL to OpenGL ES.
Alternative for the future you could might use Vulcan on Windows and Linux and use MoltenVK, which converts Vulcan to Metal and is open source.
https://github.com/KhronosGroup/MoltenVK
Both SDK are quite feature complete and get update frequently. They get used by other bigger companies and seem easy to implement.
- u-he
- Topic Starter
- 28062 posts since 8 Aug, 2002 from Berlin
Oi, that would be easy. I'll check this out!
Thanks!