Search code examples
iosswifttexturesmetalmetalkit

Sample Count In Metal


I am drawing texture in a quad with 4. then I am drawing a triangle with sample count 4. I feel there is no need to draw texture in a quad with 4 sample count. It affect performance. Is it possible use different sample count in a single program.


Solution

  • It's not possible to use different MSAA sample counts with a single render pipeline state or within a single render pass (render command encoder), because each of these objects is immutably configured with the sample count. In order to achieve MSAA, the render pass has one or more attachments which must be resolved to produce a final image. If you need different sample counts for different draw calls (i.e., you want to draw some MSAA passes and some non-MSAA passes), you should first perform your multisample passes, then load the resolveTextures of the final MSAA pass as the textures of the corresponding attachments in subsequent passes, using a loadAction of .load, then perform your non-MSAA drawing.