Fix a possible race condition around MVKMTLBufferAllocation.
I don't think a race is actually possible here, but this makes Thread Sanitizer happy.
This commit is contained in:
parent
a1be5a37d3
commit
d50e654acd
@ -452,10 +452,11 @@ void MVKCommandEncoder::setComputeBytes(id<MTLComputeCommandEncoder> mtlEncoder,
|
||||
|
||||
const MVKMTLBufferAllocation* MVKCommandEncoder::getTempMTLBuffer(NSUInteger length) {
|
||||
const MVKMTLBufferAllocation* mtlBuffAlloc = getCommandEncodingPool()->acquireMTLBufferAllocation(length);
|
||||
MVKMTLBufferAllocationPool* pool = mtlBuffAlloc->getPool();
|
||||
|
||||
// Return the MTLBuffer allocation to the pool once the command buffer is done with it
|
||||
[_mtlCmdBuffer addCompletedHandler: ^(id<MTLCommandBuffer> mcb) {
|
||||
((MVKMTLBufferAllocation*)mtlBuffAlloc)->returnToPool();
|
||||
pool->returnObjectSafely((MVKMTLBufferAllocation*)mtlBuffAlloc);
|
||||
}];
|
||||
|
||||
return mtlBuffAlloc;
|
||||
|
@ -44,6 +44,9 @@ public:
|
||||
*/
|
||||
inline void* getContents() const { return (void*)((uintptr_t)_mtlBuffer.contents + _offset); }
|
||||
|
||||
/** Returns the pool whence this object was created. */
|
||||
MVKMTLBufferAllocationPool* getPool() const { return _pool; }
|
||||
|
||||
/** Returns this object back to the pool that created it. This will reset the value of _next member. */
|
||||
void returnToPool();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user