I'm working in Objective-C, but this question is ubiquitous to swift too (I think). If I have buffer id<MTLBuffer> my_buffer and a render command currently queued on the GPU that reads from my_buffer. If I set my_buffer's purgeable state to be empty, i.e.
[my_buffer setPurgeableState:MTLPurgeableStateEmpty];
BEFORE or DURING the command being processed on the GPU, what will happen? Will the GPU still use the resource without a problem and then discard it once it is done? Or will it not know that that buffer exists anymore? Does purgeableState even affect the device's allocation of memory?
If this is not the case, how do I set a buffer to discard it's memory when there are no outstanding render command queued that reference it (but the program is oblivious to whether or not there are outstanding render commands referencing it)?