Remove private flag from MVKCommandEncoder::copyToTempMTLBufferAllocation().
MVKMTLBufferAllocationPool subclass from MVKDeviceTrackingMixin.
MVKDeviceObjectPool subclass from MVKDeviceTrackingMixin.
diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
index f2f40dd..43b45a5 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
+++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
@@ -373,7 +373,7 @@
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 8396ea3..b7866f7 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
@@ -659,8 +659,8 @@
}
// 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 e223225..7488305 100644
--- a/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.h
+++ b/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.h
@@ -75,7 +75,7 @@
* To return a MVKMTLBufferAllocation retrieved from this pool, back to this pool,
* call the returnToPool() function on the MVKMTLBufferAllocation instance.
*/
-class MVKMTLBufferAllocationPool : public MVKObjectPool<MVKMTLBufferAllocation> {
+class MVKMTLBufferAllocationPool : public MVKObjectPool<MVKMTLBufferAllocation>, public MVKDeviceTrackingMixin {
public:
@@ -91,6 +91,7 @@
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 @@
NSUInteger _mtlBufferLength;
MTLStorageMode _mtlStorageMode;
MVKSmallVector<id<MTLBuffer>, 64> _mtlBuffers;
- MVKDevice* _device;
bool _isThreadSafe;
};
diff --git a/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm b/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm
index ff93739..2aabbf9 100644
--- a/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm
@@ -51,8 +51,10 @@
MVKMTLBufferAllocationPool::MVKMTLBufferAllocationPool(MVKDevice* device, NSUInteger allocationLength, bool makeThreadSafe,
- bool isDedicated, MTLStorageMode mtlStorageMode) : MVKObjectPool<MVKMTLBufferAllocation>(true) {
- _device = device;
+ bool isDedicated, MTLStorageMode mtlStorageMode) :
+ MVKObjectPool<MVKMTLBufferAllocation>(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 adb1fbd..60cc8e7 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
@@ -892,6 +892,7 @@
protected:
MVKBaseObject* getBaseObject() override { return this; };
+
};
@@ -929,11 +930,10 @@
/** Manages a pool of instances of a particular object type that requires an MVKDevice during construction. */
template <class T>
-class MVKDeviceObjectPool : public MVKObjectPool<T> {
+class MVKDeviceObjectPool : public MVKObjectPool<T>, public MVKDeviceTrackingMixin {
public:
-
/** Returns the Vulkan API opaque object controlling this object. */
MVKVulkanAPIObject* getVulkanAPIObject() override { return _device; };
@@ -941,12 +941,12 @@
* 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<T>(isPooling), _device(device) {}
+ MVKDeviceObjectPool(MVKDevice* device, bool isPooling = true) : MVKObjectPool<T>(isPooling), MVKDeviceTrackingMixin(device) {}
protected:
T* newObject() override { return new T(_device); }
+ MVKBaseObject* getBaseObject() override { return this; };
- MVKDevice* _device;
};