Fix API for updating MVKDeviceConfiguration::synchronousQueueSubmits.

Notify MVKQueues when MVKDeviceConfiguration::synchronousQueueSubmits changes.
MVKQueue use or not use separate dispatch queue as a result.
This commit is contained in:
Bill Hollings 2018-08-14 16:08:26 -04:00
parent 008274ba67
commit 0cbc5b086f
5 changed files with 43 additions and 9 deletions

View File

@ -266,6 +266,12 @@ public:
/** 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

View File

@ -1022,6 +1022,21 @@ VkResult MVKDevice::waitIdle() {
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

View File

@ -127,6 +127,13 @@ public:
/** 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 @@ protected:
friend class MVKQueuePresentSurfaceSubmission;
void initName();
void initExecQueue();
void initMTLCommandQueue();
void initGPUCaptureScopes();
void destroyExecQueue();

View File

@ -193,11 +193,13 @@ MVKQueue::MVKQueue(MVKDevice* device, MVKQueueFamily* queueFamily, uint32_t inde
_priority = priority;
_activeMTLCommandBufferCount = 0;
_nextMTLCmdBuffID = 1;
_execQueue = nullptr; // Before updateDeviceConfiguration()
initName();
initExecQueue();
initMTLCommandQueue();
initGPUCaptureScopes();
updateDeviceConfiguration();
}
void MVKQueue::initName() {
@ -207,12 +209,14 @@ void MVKQueue::initName() {
_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 @@ MVKQueue::~MVKQueue() {
// Destroys the execution dispatch queue.
void MVKQueue::destroyExecQueue() {
if (_execQueue) { dispatch_release(_execQueue); }
if (_execQueue) {
dispatch_release(_execQueue);
_execQueue = nullptr;
}
}

View File

@ -31,7 +31,7 @@ MVK_PUBLIC_SYMBOL void vkGetMoltenVKDeviceConfigurationMVK(
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 @@ MVK_PUBLIC_SYMBOL VkResult vkSetMoltenVKDeviceConfigurationMVK(
MVKDeviceConfiguration* pConfiguration) {
MVKDevice* mvkDev = MVKDevice::getMVKDevice(device);
if (pConfiguration) { *(MVKDeviceConfiguration*)&mvkDev->_mvkConfig = *pConfiguration; }
if (pConfiguration) { mvkDev->setMoltenVKConfiguration(pConfiguration); }
return VK_SUCCESS;
}