<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLHazardTrackingMode",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:@E@MTLHazardTrackingMode"
  },
  "title" : "MTLHazardTrackingMode"
}
-->

# MTLHazardTrackingMode

Options that control whether Metal automatically tracks and prevents memory hazards for resources.

```
enum MTLHazardTrackingMode
```

## Overview

Hazard tracking helps prevent race conditions by managing memory dependencies between commands.
When you enable tracking for a resource, Metal automatically delays write operations until previous read operations finish, and prevents subsequent commands from running until write operations complete.

Metal applies hazard tracking to resources you create with [`MTLHazardTrackingMode.tracked`](/documentation/Metal/MTLHazardTrackingMode/tracked), but only when you submit commands that use those resources to an [`MTLCommandQueue`](/documentation/Metal/MTLCommandQueue). Metal doesn’t track resources you create with [`MTLHazardTrackingMode.untracked`](/documentation/Metal/MTLHazardTrackingMode/untracked).

Metal doesn’t apply hazard tracking to commands you submit to an [`MTL4CommandQueue`](/documentation/Metal/MTL4CommandQueue), even when those commands use tracked resources.

### Enable hazard tracking for a resource

You can create individual resources with tracking by calling the appropriate
[`MTLDevice`](/documentation/Metal/MTLDevice) factory method (see [Resource creation](/documentation/Metal/resource-creation)), or a factory method
of an [`MTLHeap`](/documentation/Metal/MTLHeap) instance that you create with hazard tracking.
Enable hazard tracking for an individual resource or heap by adding [`MTLHazardTrackingMode.tracked`](/documentation/Metal/MTLHazardTrackingMode/tracked)
to an [`MTLResourceOptions`](/documentation/Metal/MTLResourceOptions) instance.

Some factory methods have a parameter for resource options, such as
[`makeBuffer(length:options:)`](/documentation/Metal/MTLDevice/makeBuffer(length:options:)).
Other factory methods have a parameter for a descriptor type, which has
an [`MTLResourceOptions`](/documentation/Metal/MTLResourceOptions) property.
For example, to create an [`MTLTexture`](/documentation/Metal/MTLTexture) instance with hazard tracking:

1. Create an [`MTLTextureDescriptor`](/documentation/Metal/MTLTextureDescriptor) instance.
2. Add the [`MTLHazardTrackingMode.tracked`](/documentation/Metal/MTLHazardTrackingMode/tracked) option to that descriptor’s [`resourceOptions`](/documentation/Metal/MTLTextureDescriptor/resourceOptions) property.

### Choose between automatic safety and manual optimization

Hazard tracking provides automatic safety at the cost of some runtime overhead.
You can improve the runtime performance of commands you send to an [`MTLCommandQueue`](/documentation/Metal/MTLCommandQueue)
by creating resources with [`MTLHazardTrackingMode.untracked`](/documentation/Metal/MTLHazardTrackingMode/untracked) and synchronizing access to those resources yourself.

For more information about synchronizing resources, see [Resource synchronization](/documentation/Metal/resource-synchronization).

## Topics

### Selecting the tracking mode

[`MTLHazardTrackingMode.default`](/documentation/Metal/MTLHazardTrackingMode/default)

An option that applies the default tracking behavior in Metal based on the resource or heap type you’re creating.

[`MTLHazardTrackingMode.untracked`](/documentation/Metal/MTLHazardTrackingMode/untracked)

An option that disables automatic memory hazard tracking in Metal for a resource at runtime.

[`MTLHazardTrackingMode.tracked`](/documentation/Metal/MTLHazardTrackingMode/tracked)

An option that directs Metal to apply runtime safeguards that prevent memory hazards when commands access a resource.



---

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)