Guides and Sample Code

Developer

Metal Best Practices Guide

Native Screen Scale (iOS and tvOS)

Best Practice: Render drawables at the exact pixel size of your target display.

The pixel size of your drawables should always match the exact pixel size of their target display. This is critical to avoid rendering to off-screen pixels or incurring an additional sampling stage.

The UIScreen class provides two properties that define the native size and scale factor of a physical screen: nativeBounds and nativeScale. Query the nativeBounds property to determine the native bounding rectangle of the screen, in pixels. Query the nativeScale property to determine the native scale factor used to convert points to pixels.

Use a MetalKit View to Support Native Screen Scale

The MTKView class automatically supports native screen scale. By default, the size of the view’s current drawable is always guaranteed to match the size of the view itself.