Tracking the resource residency of argument buffers
Optimize resource performance within an argument buffer.
Overview
The Metal driver can’t automatically track the residency of argument buffer resources, but you can track it manually.
Track argument buffer resource residency manually
Call an MTLRenderCommandEncoder or MTLComputeCommandEncoder method:
For individual resources, call useResource(_:usage:stages:) or useResource(_:usage:).
For all resources in a heap, call useHeap(_:stages:) or useHeap(_:).
These methods perform two important functions:
They add argument buffer resources to the set of resources that the render or compute pass needs resident.
They ensure that argument buffer resources are in a format that’s compatible with the required function operation, as an MTLResourceUsage value specifies.
The methods with a stages parameter also insert dependency hazards, similar to MTLFence instances for that stage.
Call these methods before issuing any draw or dispatch calls that may access the specified resources.
See Also
Argument buffers
Improving CPU performance by using argument buffersManaging groups of resources with argument buffersIndexing argument buffersRendering terrain dynamically with argument buffersEncoding argument buffers on the GPUUsing argument buffers with resource heapsMTLArgumentDescriptorMTLArgumentEncoderMTLAttributeStrideStatic