Vulkan: Set apiVersion dawn targets

Set apiVersion to Vulkan 1.0 if the instance only supports
Vulkan 1.0. Otherwise set apiVersion to Vulkan 1.2, treat
1.2 as the highest API version dawn targets.

Bug: dawn:426
Change-Id: I322eaa0a93a518df36b86717c2ed5a98c5d056ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25065
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Xinghua Cao <xinghua.cao@intel.com>
This commit is contained in:
Xinghua Cao 2020-07-20 08:44:29 +00:00 committed by Commit Bot service account
parent d0dd661f18
commit 92ebe87b74

View File

@ -231,7 +231,17 @@ namespace dawn_native { namespace vulkan {
appInfo.applicationVersion = 0; appInfo.applicationVersion = 0;
appInfo.pEngineName = nullptr; appInfo.pEngineName = nullptr;
appInfo.engineVersion = 0; appInfo.engineVersion = 0;
// Vulkan 1.0 implementations were required to return VK_ERROR_INCOMPATIBLE_DRIVER if
// apiVersion was larger than 1.0. Meanwhile, as long as the instance supports at least
// Vulkan 1.1, an application can use different versions of Vulkan with an instance than
// it does with a device or physical device. So we should set apiVersion to Vulkan 1.0
// if the instance only supports Vulkan 1.0. Otherwise we set apiVersion to Vulkan 1.2,
// treat 1.2 as the highest API version dawn targets.
if (mGlobalInfo.apiVersion == VK_MAKE_VERSION(1, 0, 0)) {
appInfo.apiVersion = mGlobalInfo.apiVersion; appInfo.apiVersion = mGlobalInfo.apiVersion;
} else {
appInfo.apiVersion = VK_MAKE_VERSION(1, 2, 0);
}
VkInstanceCreateInfo createInfo; VkInstanceCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;