Fix one validation warning

This commit is contained in:
Benau 2022-04-03 09:55:17 +08:00
parent a98a470ea8
commit 24a9c99e03
2 changed files with 9 additions and 7 deletions

View File

@ -575,9 +575,6 @@ void GEVulkanDriver::createUnicolorTextures()
// ----------------------------------------------------------------------------
void GEVulkanDriver::createInstance(SDL_Window* window)
{
#define VK_MAKE_API_VERSION(variant, major, minor, patch) \
((((uint32_t)(variant)) << 29) | (((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))
#if !defined(__APPLE__) || defined(DLOPEN_MOLTENVK)
if (gladLoadVulkanUserPtr(NULL, (GLADuserptrloadfunc)loader, NULL) == 0)
{
@ -598,10 +595,10 @@ void GEVulkanDriver::createInstance(SDL_Window* window)
PFN_vkEnumerateInstanceVersion e_ver = (PFN_vkEnumerateInstanceVersion)
vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
vulkan_1_1 = (e_ver && e_ver(&vk_version) == VK_SUCCESS &&
vk_version >= VK_MAKE_API_VERSION(0, 1, 1, 0));
vk_version >= VK_API_VERSION_1_1);
#else
vulkan_1_1 = (vkEnumerateInstanceVersion(&vk_version) == VK_SUCCESS &&
vk_version >= VK_MAKE_API_VERSION(0, 1, 1, 0));
vk_version >= VK_API_VERSION_1_1);
#endif
uint32_t layer_count = 0;
@ -621,7 +618,11 @@ void GEVulkanDriver::createInstance(SDL_Window* window)
VkInstanceCreateInfo create_info = {};
VkApplicationInfo app_info = {};
if (vulkan_1_1)
app_info.apiVersion = vk_version;
{
// From https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkApplicationInfo.html
// Implementations that support Vulkan 1.1 or later must not return VK_ERROR_INCOMPATIBLE_DRIVER for any value of apiVersion.
app_info.apiVersion = VK_API_VERSION_1_2;
}
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
create_info.enabledExtensionCount = extensions.size();
create_info.ppEnabledExtensionNames = extensions.data();

View File

@ -62,7 +62,8 @@ void GEVulkanFeatures::init(GEVulkanDriver* vk)
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES;
supported_features.pNext = &descriptor_indexing_features;
if (!vkGetPhysicalDeviceFeatures2)
if (vk->getPhysicalDeviceProperties().apiVersion < VK_API_VERSION_1_1 ||
!vkGetPhysicalDeviceFeatures2)
return;
vkGetPhysicalDeviceFeatures2(vk->getPhysicalDevice(), &supported_features);
if (supported_features.sType !=