From 92ebe87b74f1f7e80fb0e2133c9976715c1b6d46 Mon Sep 17 00:00:00 2001 From: Xinghua Cao Date: Mon, 20 Jul 2020 08:44:29 +0000 Subject: [PATCH] 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 Commit-Queue: Xinghua Cao --- src/dawn_native/vulkan/BackendVk.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dawn_native/vulkan/BackendVk.cpp b/src/dawn_native/vulkan/BackendVk.cpp index 0a68231e7b..613f0a0126 100644 --- a/src/dawn_native/vulkan/BackendVk.cpp +++ b/src/dawn_native/vulkan/BackendVk.cpp @@ -231,7 +231,17 @@ namespace dawn_native { namespace vulkan { appInfo.applicationVersion = 0; appInfo.pEngineName = nullptr; appInfo.engineVersion = 0; - appInfo.apiVersion = mGlobalInfo.apiVersion; + // 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; + } else { + appInfo.apiVersion = VK_MAKE_VERSION(1, 2, 0); + } VkInstanceCreateInfo createInfo; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;