Merge pull request #1331 from billhollings/resume-device

Add MVKConfiguration::resumeLostDevice and MVK_CONFIG_RESUME_LOST_DEVICE env var.
This commit is contained in:
Bill Hollings 2021-04-13 13:41:33 -04:00 committed by GitHub
commit 897e375bbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 0 deletions

View File

@ -776,6 +776,31 @@ typedef struct {
*/
MVKConfigAdvertiseExtensions advertiseExtensions;
/**
* Controls whether MoltenVK should treat a lost VkDevice as resumable, unless the
* corresponding VkPhysicalDevice has also been lost. The VK_ERROR_DEVICE_LOST error has
* a broad definitional range, and can mean anything from a GPU hiccup on the current
* command buffer submission, to a phyically removed GPU. In the case where this error does
* not impact the VkPhysicalDevice, Vulkan requires that the app destroy and re-create a new
* VkDevice. However, not all apps (including CTS) respect that requirement, leading to what
* might be a transient command submission failure causing an unexpected catastophic app failure.
* If this setting is enabled, in the case of a VK_ERROR_DEVICE_LOST error that does not
* impact the VkPhysicalDevice, MoltenVK will remove the error condition on the VkDevice after
* the current queue submission is finished, allowing the VkDevice to continue to be used.
* If this setting is disabled, MoltenVK will maintain the VK_ERROR_DEVICE_LOST error condition
* on the VkDevice, and subsequent use of that VkDevice will be reduced or prohibited.
*
* The value of this parameter should be changed before creating a VkDevice
* that will use it, for the change to take effect.
*
* The initial value or this parameter is set by the
* MVK_CONFIG_RESUME_LOST_DEVICE
* runtime environment variable or MoltenVK compile-time build setting.
* If neither is set, this setting is disabled by default, and MoltenVK will not
* resume a VkDevice that enters the VK_ERROR_DEVICE_LOST error state.
*/
VkBool32 resumeLostDevice;
} MVKConfiguration;
/**

View File

@ -338,6 +338,9 @@ void MVKQueueCommandBufferSubmission::commitActiveMTLCommandBuffer(bool signalCo
#endif
mvkDev->getPhysicalDevice()->setConfigurationResult(VK_ERROR_DEVICE_LOST);
break;
default:
if (mvkConfig()->resumeLostDevice) { mvkDev->clearConfigurationResult(); }
break;
}
#if MVK_XCODE_12
if (mvkConfig()->debugMode) {

View File

@ -60,6 +60,7 @@ static void mvkInitConfigFromEnvVars() {
MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.useMTLHeap, MVK_CONFIG_USE_MTLHEAP);
MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.apiVersionToAdvertise, MVK_CONFIG_API_VERSION_TO_ADVERTISE);
MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.advertiseExtensions, MVK_CONFIG_ADVERTISE_EXTENSIONS);
MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.resumeLostDevice, MVK_CONFIG_RESUME_LOST_DEVICE);
mvkSetConfig(&evCfg);
}

View File

@ -272,3 +272,8 @@ void mvkSetConfig(MVKConfiguration* pMVKConfig);
#ifndef MVK_CONFIG_ADVERTISE_EXTENSIONS
# define MVK_CONFIG_ADVERTISE_EXTENSIONS MVK_CONFIG_ADVERTISE_EXTENSIONS_ALL
#endif
/** Resume MVKDevice VK_ERROR_DEVICE_LOST errors that do not cause MVKPhysicalDevice errors. Disabled by default. */
#ifndef MVK_CONFIG_RESUME_LOST_DEVICE
# define MVK_CONFIG_RESUME_LOST_DEVICE 0
#endif