diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h index f2f40dd7..43b45a58 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h +++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h @@ -373,7 +373,7 @@ public: const MVKMTLBufferAllocation* getTempMTLBuffer(NSUInteger length, bool isPrivate = false, bool isDedicated = false); /** Copy the bytes to a temporary MTLBuffer that will be returned to a pool after the command buffer is finished. */ - const MVKMTLBufferAllocation* copyToTempMTLBufferAllocation(const void* bytes, NSUInteger length, bool isPrivate = false, bool isDedicated = false); + const MVKMTLBufferAllocation* copyToTempMTLBufferAllocation(const void* bytes, NSUInteger length, bool isDedicated = false); /** Returns the command encoding pool. */ MVKCommandEncodingPool* getCommandEncodingPool(); diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm index 8396ea33..b7866f72 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm @@ -659,8 +659,8 @@ MVKCommandEncodingPool* MVKCommandEncoder::getCommandEncodingPool() { } // Copies the specified bytes into a temporary allocation within a pooled MTLBuffer, and returns the MTLBuffer allocation. -const MVKMTLBufferAllocation* MVKCommandEncoder::copyToTempMTLBufferAllocation(const void* bytes, NSUInteger length, bool isPrivate, bool isDedicated) { - const MVKMTLBufferAllocation* mtlBuffAlloc = getTempMTLBuffer(length, isPrivate, isDedicated); +const MVKMTLBufferAllocation* MVKCommandEncoder::copyToTempMTLBufferAllocation(const void* bytes, NSUInteger length, bool isDedicated) { + const MVKMTLBufferAllocation* mtlBuffAlloc = getTempMTLBuffer(length, false, isDedicated); void* pBuffData = mtlBuffAlloc->getContents(); mlock(pBuffData, length); memcpy(pBuffData, bytes, length); diff --git a/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.h b/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.h index e2232255..7488305d 100644 --- a/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.h +++ b/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.h @@ -75,7 +75,7 @@ protected: * To return a MVKMTLBufferAllocation retrieved from this pool, back to this pool, * call the returnToPool() function on the MVKMTLBufferAllocation instance. */ -class MVKMTLBufferAllocationPool : public MVKObjectPool { +class MVKMTLBufferAllocationPool : public MVKObjectPool, public MVKDeviceTrackingMixin { public: @@ -91,6 +91,7 @@ public: protected: friend class MVKMTLBufferAllocation; + MVKBaseObject* getBaseObject() override { return this; }; MVKMTLBufferAllocation* newObject() override; void returnAllocation(MVKMTLBufferAllocation* ba) { _isThreadSafe ? returnObjectSafely(ba) : returnObject(ba); } uint32_t calcMTLBufferAllocationCount(); @@ -101,7 +102,6 @@ protected: NSUInteger _mtlBufferLength; MTLStorageMode _mtlStorageMode; MVKSmallVector, 64> _mtlBuffers; - MVKDevice* _device; bool _isThreadSafe; }; diff --git a/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm b/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm index ff93739b..2aabbf9f 100644 --- a/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm +++ b/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm @@ -51,8 +51,10 @@ void MVKMTLBufferAllocationPool::addMTLBuffer() { MVKMTLBufferAllocationPool::MVKMTLBufferAllocationPool(MVKDevice* device, NSUInteger allocationLength, bool makeThreadSafe, - bool isDedicated, MTLStorageMode mtlStorageMode) : MVKObjectPool(true) { - _device = device; + bool isDedicated, MTLStorageMode mtlStorageMode) : + MVKObjectPool(true), + MVKDeviceTrackingMixin(device) { + _allocationLength = allocationLength; _isThreadSafe = makeThreadSafe; _mtlBufferLength = _allocationLength * (isDedicated ? 1 : calcMTLBufferAllocationCount()); diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h index adb1fbd0..60cc8e7a 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h @@ -892,6 +892,7 @@ public: protected: MVKBaseObject* getBaseObject() override { return this; }; + }; @@ -929,11 +930,10 @@ protected: /** Manages a pool of instances of a particular object type that requires an MVKDevice during construction. */ template -class MVKDeviceObjectPool : public MVKObjectPool { +class MVKDeviceObjectPool : public MVKObjectPool, public MVKDeviceTrackingMixin { public: - /** Returns the Vulkan API opaque object controlling this object. */ MVKVulkanAPIObject* getVulkanAPIObject() override { return _device; }; @@ -941,12 +941,12 @@ public: * Configures this instance for the device, and either use pooling, or not, depending * on the value of isPooling, which defaults to true if not indicated explicitly. */ - MVKDeviceObjectPool(MVKDevice* device, bool isPooling = true) : MVKObjectPool(isPooling), _device(device) {} + MVKDeviceObjectPool(MVKDevice* device, bool isPooling = true) : MVKObjectPool(isPooling), MVKDeviceTrackingMixin(device) {} protected: T* newObject() override { return new T(_device); } + MVKBaseObject* getBaseObject() override { return this; }; - MVKDevice* _device; };