Quartz/CoreGraphics is broken. What to do now?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

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.

Post

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." :D

Post

mystran wrote: Thu Mar 14, 2019 10:08 pm 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." :D
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?

Post

Urs wrote: Thu Mar 14, 2019 10:29 pm
mystran wrote: Thu Mar 14, 2019 10:08 pm 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." :D
Argh. I really wish for something a tad more permanent. I've done OpenGL 20 years ago, I know the pains.
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.

Post

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.

Post

Urs wrote: Thu Mar 14, 2019 10:48 pm 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.
Well... you CAN use legacy OpenGL with fixed-function pipeline to avoid the shader. :)

Post

Urs wrote: Thu Mar 14, 2019 10:29 pm
mystran wrote: Thu Mar 14, 2019 10:08 pm 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." :D
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?
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?

Post

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.

Post

Hmm... this change was reported to come about 9 months ago - https://appleinsider.com/articles/18/06 ... tes-opengl

Post

OpenGL was redacted. Thankfully there’s this...
https://www.phoronix.com/scan.php?page= ... ed-MVK-App

Post

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.

Post

arne wrote: Fri Mar 15, 2019 8:35 am 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.
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

Post

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.

Post

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.
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?

Post

arne wrote: Fri Mar 15, 2019 9:26 am 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.
Oi, that would be easy. I'll check this out!

Thanks!

Post Reply

Return to “DSP and Plugin Development”