From 3fe8a52e3c794e1884c212d7585e9844876fe23c Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 9 Oct 2016 21:28:43 +0200 Subject: [PATCH] vulkan-Vulkan_Implementation: Enumerate VK_KHR_win32_surface only once in vkEnumerateInstanceExtensionProperties. --- patches/patchinstall.sh | 2 + ...-VK_KHR_win32_surface-only-one-time-.patch | 101 ++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 patches/vulkan-Vulkan_Implementation/0005-vulkan-Enumerate-VK_KHR_win32_surface-only-one-time-.patch diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index c7164656..ae5d2394 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -7096,11 +7096,13 @@ if test "$enable_vulkan_Vulkan_Implementation" -eq 1; then patch_apply vulkan-Vulkan_Implementation/0002-vulkan-Implement-vkGetPhysicalDeviceWin32Presentatio.patch patch_apply vulkan-Vulkan_Implementation/0003-vulkan-Use-binary-search-to-lookup-function-in-is_nu.patch patch_apply vulkan-Vulkan_Implementation/0004-vulkan-Try-to-load-libvulkan.so.1.patch + patch_apply vulkan-Vulkan_Implementation/0005-vulkan-Enumerate-VK_KHR_win32_surface-only-one-time-.patch ( echo '+ { "Sebastian Lackner", "vulkan: Initial implementation.", 2 },'; echo '+ { "Michael Müller", "vulkan: Implement vkGetPhysicalDeviceWin32PresentationSupportKHR.", 1 },'; echo '+ { "Sebastian Lackner", "vulkan: Use binary search to lookup function in is_null_func.", 1 },'; echo '+ { "Michael Müller", "vulkan: Try to load libvulkan.so.1.", 1 },'; + echo '+ { "Michael Müller", "vulkan: Enumerate VK_KHR_win32_surface only one time in vkEnumerateInstanceExtensionProperties.", 1 },'; ) >> "$patchlist" fi diff --git a/patches/vulkan-Vulkan_Implementation/0005-vulkan-Enumerate-VK_KHR_win32_surface-only-one-time-.patch b/patches/vulkan-Vulkan_Implementation/0005-vulkan-Enumerate-VK_KHR_win32_surface-only-one-time-.patch new file mode 100644 index 00000000..704eeed5 --- /dev/null +++ b/patches/vulkan-Vulkan_Implementation/0005-vulkan-Enumerate-VK_KHR_win32_surface-only-one-time-.patch @@ -0,0 +1,101 @@ +From 99d6f01e7887519a6567e36a87e0dac936ee199a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Sun, 9 Oct 2016 21:11:57 +0200 +Subject: vulkan: Enumerate VK_KHR_win32_surface only one time in + vkEnumerateInstanceExtensionProperties. + +--- + dlls/vulkan/vulkan_main.c | 56 +++++++++++++++++++++++++++++++++++--------- + dlls/vulkan/vulkan_private.h | 1 + + 2 files changed, 46 insertions(+), 11 deletions(-) + +diff --git a/dlls/vulkan/vulkan_main.c b/dlls/vulkan/vulkan_main.c +index 1ede8c8..55361a4 100644 +--- a/dlls/vulkan/vulkan_main.c ++++ b/dlls/vulkan/vulkan_main.c +@@ -353,25 +353,59 @@ VkResult WINAPI vkCreateInstance( const VkInstanceCreateInfo *pCreateInfo, + VkResult WINAPI vkEnumerateInstanceExtensionProperties( const char *pLayerName, + uint32_t *pPropertyCount, VkExtensionProperties *pProperties ) + { ++ VkExtensionProperties *native_props; ++ uint32_t native_prop_count; ++ BOOL found = FALSE; + VkResult res; +- int i; ++ int i, j; + + TRACE( "(%p, %p, %p)\n", pLayerName, pPropertyCount, pProperties ); + +- res = p_vkEnumerateInstanceExtensionProperties( pLayerName, pPropertyCount, pProperties ); +- if ((res == VK_SUCCESS || res == VK_INCOMPLETE) && pProperties) ++ res = p_vkEnumerateInstanceExtensionProperties( pLayerName, &native_prop_count, NULL ); ++ if (res != VK_SUCCESS) ++ return res; ++ ++ native_props = HeapAlloc( GetProcessHeap(), 0, sizeof(*native_props) * native_prop_count ); ++ if (!native_props) ++ return VK_ERROR_OUT_OF_HOST_MEMORY; ++ ++ res = p_vkEnumerateInstanceExtensionProperties( pLayerName, &native_prop_count, native_props ); ++ if (res != VK_SUCCESS) ++ { ++ HeapFree( GetProcessHeap(), 0, native_props ); ++ return res; ++ } ++ ++ for (i = 0, j = 0; i < native_prop_count; i++) + { +- for (i = 0; i < *pPropertyCount; i++) ++ if (!strcmp( native_props[i].extensionName, "VK_KHR_xcb_surface" ) || ++ !strcmp( native_props[i].extensionName, "VK_KHR_xlib_surface" )) + { +- if (!strcmp( pProperties[i].extensionName, "VK_KHR_xcb_surface" ) || +- !strcmp( pProperties[i].extensionName, "VK_KHR_xlib_surface" )) +- { +- TRACE( "replacing %s -> VK_KHR_win32_surface\n", debugstr_a(pProperties[i].extensionName) ); +- strcpy( pProperties[i].extensionName, "VK_KHR_win32_surface" ); +- pProperties[i].specVersion = 6; +- } ++ TRACE( "found %s for VK_KHR_win32_surface support\n", debugstr_a(native_props[i].extensionName) ); ++ ++ if (found) ++ continue; ++ ++ strcpy( native_props[i].extensionName, "VK_KHR_win32_surface" ); ++ native_props[i].specVersion = 6; ++ found = TRUE; ++ } ++ ++ if (!pProperties) ++ { ++ j++; ++ continue; ++ } ++ ++ if (j >= *pPropertyCount) ++ { ++ res = VK_INCOMPLETE; ++ break; + } ++ pProperties[j++] = native_props[i]; + } + ++ *pPropertyCount = j; ++ HeapFree( GetProcessHeap(), 0, native_props ); + return res; + } +diff --git a/dlls/vulkan/vulkan_private.h b/dlls/vulkan/vulkan_private.h +index 1d5767a..6fb3ed6 100644 +--- a/dlls/vulkan/vulkan_private.h ++++ b/dlls/vulkan/vulkan_private.h +@@ -38,6 +38,7 @@ + + #define VK_SUCCESS 0 + #define VK_INCOMPLETE 5 ++#define VK_ERROR_OUT_OF_HOST_MEMORY (-1) + #define VK_ERROR_EXTENSION_NOT_PRESENT (-7) + #define VK_ERROR_INCOMPATIBLE_DRIVER (-9) + #define VK_FALSE 0 +-- +2.9.0 +