<!--
{
  "documentType" : "article",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/storing-data-a-pass-makes-with-custom-sample-positions-for-a-subsequent-pass",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Storing data a pass makes with custom sample positions for a subsequent pass"
}
-->

# Storing data a pass makes with custom sample positions for a subsequent pass

Inform Metal when your app uses programmable sample positions for its depth render targets or copies MSAA depth data.

## Discussion

A render or compute pass usually stores its target’s depth data in a compressed format. Any subsequent pass has to use the correct sample positions to decompress the data before reading it. You can store depth data in a representation that uses arbitrary sample positions (see [Positioning samples programmatically](/documentation/Metal/positioning-samples-programmatically)).

> Important:
> You can sample depth positions programmatically only on devices that support programmable sample positions (see ``doc://com.apple.metal/documentation/Metal/MTLDevice/areProgrammableSamplePositionsSupported``).

When your app uses custom sampling positions, inform Metal by setting the [`MTLRenderPassColorAttachmentDescriptor`](/documentation/Metal/MTLRenderPassColorAttachmentDescriptor) or [`MTLRenderPassDepthAttachmentDescriptor`](/documentation/Metal/MTLRenderPassDepthAttachmentDescriptor) instance’s [`storeActionOptions`](/documentation/Metal/MTLRenderPassAttachmentDescriptor/storeActionOptions) property to [`customSamplePositions`](/documentation/Metal/MTLStoreActionOptions/customSamplePositions). This setting tells Metal that any subsequent pass that reads the attachment may not know the sample positions the current pass uses to generate the data. Examples of a pass that can use custom sample positions include the following:

- A fragment shader that uses unique, programmable sample positions
- A blit pass that copies MSAA depth data to another resource

In this scenario, Metal may decompress the depth render target and store the uncompressed data.

> Tip:
> Improve the performance of a pass if its programmable sample positions are the same for the next pass by setting the descriptor’s ``doc://com.apple.metal/documentation/Metal/MTLRenderPassAttachmentDescriptor/storeAction`` property to ``doc://com.apple.metal/documentation/Metal/MTLStoreAction/store`` and clearing the ``doc://com.apple.metal/documentation/Metal/MTLStoreActionOptions/customSamplePositions`` option from the ``doc://com.apple.metal/documentation/Metal/MTLRenderPassAttachmentDescriptor/storeActionOptions`` property.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)