An option for writing to the texture in a shader.
SDKs
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- Metal
Declaration
static var shaderWrite: MTLTexture Usage { get }
Discussion
Set this option if you access the given texture with a write()
function in any shader. This option enables the access::
attribute for the texture. For more information about texture functions and access attributes, see Metal Shading Language Guide.
If the texture is a read-write texture that you also access with a read()
function in the same shader, set the shader
option to enable the access::
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 render
option if you render to a given texture, but don’t set the shader
option if you don’t write to the texture. The render
and shader
options aren’t equivalent, and setting render
doesn’t require you to also set shader
.