Fix API for updating MVKDeviceConfiguration::synchronousQueueSubmits.
Notify MVKQueues when MVKDeviceConfiguration::synchronousQueueSubmits changes.
MVKQueue use or not use separate dispatch queue as a result.
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
index 24ac020..b40fe42 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
@@ -266,6 +266,12 @@
/** Block the current thread until all queues in this device are idle. */
VkResult waitIdle();
+ /** Returns a pointer to the MoltenVK configuration info for this device. */
+ const MVKDeviceConfiguration* getMoltenVKConfiguration();
+
+ /** Sets the MoltenVK configuration info for this device. */
+ void setMoltenVKConfiguration(const MVKDeviceConfiguration* pConfiguration);
+
#pragma mark Object lifecycle
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
index 94ff4d8..db8fad1 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
@@ -1022,6 +1022,21 @@
return VK_SUCCESS;
}
+const MVKDeviceConfiguration* MVKDevice::getMoltenVKConfiguration() { return &_mvkConfig; }
+
+void MVKDevice::setMoltenVKConfiguration(const MVKDeviceConfiguration* pConfiguration) {
+ if ( !pConfiguration) { return; }
+
+ *(MVKDeviceConfiguration*)&_mvkConfig = *pConfiguration;
+
+ // Reconfigure the queues from the updated info
+ for (auto& queues : _queuesByQueueFamilyIndex) {
+ for (MVKQueue* q : queues) {
+ q->updateDeviceConfiguration();
+ }
+ }
+}
+
#pragma mark Object lifecycle
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKQueue.h b/MoltenVK/MoltenVK/GPUObjects/MVKQueue.h
index c8a393e..c561fae 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKQueue.h
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKQueue.h
@@ -127,6 +127,13 @@
/** Constructs an instance for the device and queue family. */
MVKQueue(MVKDevice* device, MVKQueueFamily* queueFamily, uint32_t index, float priority);
+ /**
+ * Called from MVKDevice when MVKDeviceConfiguration is updated.
+ *
+ * Updates the use of a dispatch queue based on the value of MVKDeviceConfiguration::synchronousQueueSubmits.
+ */
+ void updateDeviceConfiguration();
+
~MVKQueue() override;
/**
@@ -149,7 +156,6 @@
friend class MVKQueuePresentSurfaceSubmission;
void initName();
- void initExecQueue();
void initMTLCommandQueue();
void initGPUCaptureScopes();
void destroyExecQueue();
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKQueue.mm b/MoltenVK/MoltenVK/GPUObjects/MVKQueue.mm
index 43901a0..4f6d929 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKQueue.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKQueue.mm
@@ -193,11 +193,13 @@
_priority = priority;
_activeMTLCommandBufferCount = 0;
_nextMTLCmdBuffID = 1;
+ _execQueue = nullptr; // Before updateDeviceConfiguration()
initName();
- initExecQueue();
initMTLCommandQueue();
initGPUCaptureScopes();
+
+ updateDeviceConfiguration();
}
void MVKQueue::initName() {
@@ -207,12 +209,14 @@
_name = name;
}
-// Unless synchronous submission processing was configured,
+// If synchronous submission processing is not configured in the device,
// creates and initializes the prioritized execution dispatch queue.
-void MVKQueue::initExecQueue() {
+// If synchronous submission processing is configured in the device,
+// destroys the internal execution dispatch queue if it exists.
+void MVKQueue::updateDeviceConfiguration() {
if (_device->_mvkConfig.synchronousQueueSubmits) {
- _execQueue = nullptr;
- } else {
+ destroyExecQueue();
+ } else if ( !_execQueue ) {
// Determine the dispatch queue priority
dispatch_qos_class_t dqQOS = MVK_DISPATCH_QUEUE_QOS_CLASS;
int dqPriority = (1.0 - _priority) * QOS_MIN_RELATIVE_PRIORITY;
@@ -255,7 +259,10 @@
// Destroys the execution dispatch queue.
void MVKQueue::destroyExecQueue() {
- if (_execQueue) { dispatch_release(_execQueue); }
+ if (_execQueue) {
+ dispatch_release(_execQueue);
+ _execQueue = nullptr;
+ }
}
diff --git a/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm b/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm
index 611a280..02e2be7 100644
--- a/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm
+++ b/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm
@@ -31,7 +31,7 @@
MVKDeviceConfiguration* pConfiguration) {
MVKDevice* mvkDev = MVKDevice::getMVKDevice(device);
- if (pConfiguration) { *pConfiguration = mvkDev->_mvkConfig; }
+ if (pConfiguration) { *pConfiguration = *mvkDev->getMoltenVKConfiguration(); }
}
MVK_PUBLIC_SYMBOL VkResult vkSetMoltenVKDeviceConfigurationMVK(
@@ -39,7 +39,7 @@
MVKDeviceConfiguration* pConfiguration) {
MVKDevice* mvkDev = MVKDevice::getMVKDevice(device);
- if (pConfiguration) { *(MVKDeviceConfiguration*)&mvkDev->_mvkConfig = *pConfiguration; }
+ if (pConfiguration) { mvkDev->setMoltenVKConfiguration(pConfiguration); }
return VK_SUCCESS;
}