Returns a Metal drawable.
- iOS 8.0+
- macOS 10.11+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- Core Animation
CAMetal object maintains an internal pool of textures for displaying layer content, each wrapped in a
CAMetal object. At any given time, one of these textures is displayed onscreen. Use this method to retrieve the next available drawable from the pool. If all drawables are in use, the layer waits up to one second for one to become available, after which it returns
allows property affects this behavior.
This method returns
nil if the layer’s
pixel or other properties are invalid.
MTLRender object to render into the drawable’s texture and present it for display (typically registered via the
present(_:) method of a command buffer). Try to minimize the time between when you fetch the drawable and when you submit the command buffer that uses it. For example, you might perform other work on the CPU, render to offscreen textures or execute compute passes, then obtain the drawable and encode a command buffer to render to it. After you submit this command buffer, release all strong references to the drawable. A texture can be reused only if it is not onscreen and all strong references to the drawable have been released. If you don’t release drawables correctly, the layer runs out of drawables to vend and future calls to
next() will return
For best results, contain any code that uses a drawable within a tight autorelease pool block, as shown in Listing 1. This ensures that the drawable is released promptly.