<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLTextureUsage/shaderWrite",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:@E@MTLTextureUsage@MTLTextureUsageShaderWrite"
  },
  "title" : "shaderWrite"
}
-->

# shaderWrite

An option for writing to the texture in a shader.

```
static var shaderWrite: MTLTextureUsage { get }
```

## Discussion

Set this option if you access the given texture with a `write()` function in any shader. This option enables the `access::write` attribute for the texture. For more information about texture functions and access attributes, see [Metal Shading Language Guide](https://developer.apple.com/library/archive/documentation/Metal/Reference/MetalShadingLanguageGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40014364).

If the texture is a read-write texture that you also access with a `read()` function in the same shader, set the [`shaderRead`](/documentation/Metal/MTLTextureUsage/shaderRead) option to enable the `access::read_write` attribute.

In iOS devices with GPU family 5, Metal doesn’t apply lossless compression to the given texture if you set this option.

> Important:
> Rendering and writing to a texture are different operations, and you don’t need to combine their usage options. Set the ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage/renderTarget`` option if you render to a given texture, but don’t set the ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage/shaderWrite`` option if you don’t write to the texture. The ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage/renderTarget`` and ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage/shaderWrite`` options aren’t equivalent, and setting ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage/renderTarget`` doesn’t require you to also set ``doc://com.apple.metal/documentation/Metal/MTLTextureUsage/shaderWrite``.

---

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)