Instance Property


The number of times a temporary image may be read by a CNN kernel before its contents become undefined.


@property(readwrite, nonatomic) NSUInteger readCount;


Temporary images must release their underlying textures for reuse immediately after last use. In order to facilitate prompt and convenient memory recycling, each time a MPSTemporaryImage object is read by an encode method of an MPSCNNKernel object, the value of its readCount property is automatically decremented. When the value of readCount reaches 0, the underlying texture is automatically made available and reusable to the framework for its own needs (and for other MPSTemporaryImage objects prior to return from the encode method). The contents of the underlying texture become undefined at this time.

By default, the value of readCount is initialized to 1, indicating a temporary image that may be overwritten any number of times, but read only once.

You may change the value of readCount as desired to allow MPSCNNKernel objects to read the MPSTemporaryImage object additional times. However, it is an error to change the value of readCount once it reaches 0 (it is also an error to read or write to a temporary image with a readCount value of 0). You may set the value of readCount to 0 yourself to cause the underlying texture to be returned to the framework. Writing to a temporary image does not adjust the value of readCount.

The Metal API Validation layer will assert if a temporary image is deallocated with a non-zero readCount value to help identify cases when resources are not returned promptly.