1

I have 3 questions relating to something from Apple WWDC 2015, more precisely Session 610, "Metal performance optimisation techniques", slide 125 (or minute 33:56 in the video), to be found at https://developer.apple.com/videos/play/wwdc2015/610.

Here is a screenshot from the slide I am referring to:

WWDC 2015, Session 610, Metal performance optimization techniques (slide 125, Drawable Surfaces)

It says there about the drawables (CAMetalDrawable) that they may be used by (3rd bullet) "Core Animation (IF COMPOSITING ENABLED)".

So "if compositing enabled" is a thing, that suggests that the compositor can be DISABLED as well (?).

I want to see if it makes sense for me to disable the compositor in my App for performance reasons. My App is an iOS (iPadOS actually) Metal (Swift) App and I want to control the entire* screen. Indeed, I have just one single view in the entire App, an MTKView, which covers the entire screen at all times).

*If the device uses split mode in multitasking (so the screen is shared between mine and another App), I of course only control my 'half' of the screen.

My questions:

  1. How can I DISABLE the compositor?

  2. About the 'status bar' in the top of the screen (with time, data, battery icons): Is it a necessary condition to hide it to achieve the DISABLING of the compositor? Or what do I have to do about it in case it affects the disabling?

  3. If the device uses split mode in multitasking, the compositor can not be disabled or can it?

Any pointers to (Apple) documentation about this topic would also be useful!

Thank you very much for help!

Céline
  • 185
  • 7

1 Answers1

2

The compositor is there to basically compose different screen elements from OS and different applications together, while maintaining color management, HDR, all that jazz. The only time you don't need the compositor is when you are "fullscreen", meaning that you have a layer that's fullscreen.

CAMetalLayer can have two "modes": direct and composited. Direct means that display hardware basically takes whatever you wrote into the texture and shows it on screen. Composited means that compositor uses the drawable to "composite" it into a bigger full screen view. You can see which mode the CAMetalLayer is in by using Metal HUD in Xcode 14 beta.

With that said,

  1. You can't disable the compositor. The OS decides if the CAMetalLayer you have is direct
  2. I'm not sure, but it probably is. Status bar is drawn by other parts of OS so it would need to get the output from status bar and your app into a single picture, which is compositing.
  3. Same here.
JustSomeGuy
  • 3,677
  • 1
  • 23
  • 31
  • Thank you very much for your swift answer! I did not even know about the new Metal HUD, so thank you for making me aware of that as well! There is this new property on CAMetalLayer, .developerHUDProperties (in the iOS16 beta), wondered already what this is... – Céline Jul 12 '22 at 16:48
  • You can have the ability to turn HUD on and off with either a plist key or an environment variable. `developerHUDProperties` is there to be able to show and hide it programmatically, when it's "enabled" by that env var or plist. – JustSomeGuy Jul 12 '22 at 17:52
  • For testing purposes, just enable it in Xcode scheme settings and it should show up – JustSomeGuy Jul 12 '22 at 17:53
  • I should also add that as far as I know, it's not possible to "force" the system to always draw your `CAMetalLayer` directly. It may at any point decide to composite you. – JustSomeGuy Jul 12 '22 at 20:34
  • Great, will do! Thank you!!! Also good to know about the 'can not force'! – Céline Jul 12 '22 at 20:34
  • @JustSomeGuy Do you know what parameters are available for `developerHUDProperties`? I'd love to know if there is a way to reposition the HUD on the view. – Oskar Aug 25 '22 at 11:16
  • It's not possible to reposition it, but you can hide or show it with that dictionary. Just set a pair `"mode": "default"` to show it or `"mode": "none"` to hided it. Keep in mind though that it needs to be enabled in some way, either through a plist or from Xcode scheme. – JustSomeGuy Aug 25 '22 at 17:00