shlogg · Early preview
Keaukraine @keaukraine

Exploring Memoryless MSAA In Metal

Optimize Metal app memory usage by using memoryless render targets. Set `resourceOptions` to `.storageModeMemoryless` and substitute auto-created in-memory color render target. Reduce memory usage & improve performance.

The easiest and fastest way to use Metal in MacOS app is to use MTKView. It is a handy wrapper which initializes all low-level stuff under the hood so you can get right to the fun part — implementing actual rendering.
However, because of its simplicity it does have a couple of shortcomings and for some reasons doesn’t provide access to all internal things under its hood. One of these minor inconveniences is the way it initializes multisampled render targets.
To understand why this is important let’s explain how Metal handles MSAA. It supports multiple ways of implementing it:

You can have a m...