Commit a45b0427 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

winevulkan: Implement vkEnumerateInstanceVersion().

The current version of Vulkan Loader returns VK_API_VERSION_1_1. Signed-off-by: 's avatarJózef Kucia <jkucia@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent fae21831
......@@ -114,6 +114,27 @@ static VkResult create_device(VkPhysicalDevice vk_physical_device,
return vkCreateDevice(vk_physical_device, &create_info, NULL, vk_device);
}
static void test_instance_version(void)
{
PFN_vkEnumerateInstanceVersion pfn_vkEnumerateInstanceVersion;
uint32_t version;
VkResult vr;
pfn_vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion)vkGetInstanceProcAddr(
NULL, "vkEnumerateInstanceVersion");
if (!pfn_vkEnumerateInstanceVersion)
{
skip("vkEnumerateInstanceVersion() is not available.\n");
return;
}
vr = pfn_vkEnumerateInstanceVersion(&version);
ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr);
ok(version >= VK_API_VERSION_1_0, "Invalid version %#x.\n", version);
trace("Vulkan version %u.%u.%u.\n",
VK_VERSION_MAJOR(version), VK_VERSION_MINOR(version), VK_VERSION_PATCH(version));
}
static void enumerate_physical_device(VkPhysicalDevice vk_physical_device)
{
VkPhysicalDeviceProperties properties;
......@@ -225,6 +246,7 @@ static void for_each_device(void (*test_func)(VkPhysicalDevice))
START_TEST(vulkan)
{
test_instance_version();
for_each_device(enumerate_physical_device);
test_physical_device_groups();
}
......@@ -148,7 +148,7 @@
@ stdcall vkEnumerateDeviceLayerProperties(ptr ptr ptr) winevulkan.wine_vkEnumerateDeviceLayerProperties
@ stdcall vkEnumerateInstanceExtensionProperties(str ptr ptr)
@ stdcall vkEnumerateInstanceLayerProperties(ptr ptr)
@ stub vkEnumerateInstanceVersion
@ stdcall vkEnumerateInstanceVersion(ptr)
@ stdcall vkEnumeratePhysicalDeviceGroups(ptr ptr ptr) winevulkan.wine_vkEnumeratePhysicalDeviceGroups
@ stdcall vkEnumeratePhysicalDevices(ptr ptr ptr) winevulkan.wine_vkEnumeratePhysicalDevices
@ stdcall vkFlushMappedMemoryRanges(ptr long ptr) winevulkan.wine_vkFlushMappedMemoryRanges
......
......@@ -29,12 +29,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *, uint32_t *, VkExtensionProperties *);
VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *);
PFN_vkVoidFunction WINAPI wine_vkGetInstanceProcAddr(VkInstance, const char *);
VkResult WINAPI vkEnumerateInstanceExtensionProperties(const char *layer_name,
uint32_t *count, VkExtensionProperties *properties)
{
TRACE("%p %p %p\n", layer_name, count, properties);
TRACE("%p, %p, %p\n", layer_name, count, properties);
if (layer_name)
return VK_ERROR_LAYER_NOT_PRESENT;
......@@ -42,6 +43,13 @@ VkResult WINAPI vkEnumerateInstanceExtensionProperties(const char *layer_name,
return wine_vkEnumerateInstanceExtensionProperties(NULL, count, properties);
}
VkResult WINAPI vkEnumerateInstanceVersion(uint32_t *version)
{
TRACE("%p\n", version);
return wine_vkEnumerateInstanceVersion(version);
}
VkResult WINAPI vkEnumerateInstanceLayerProperties(uint32_t *count,
VkLayerProperties *properties)
{
......@@ -54,7 +62,7 @@ VkResult WINAPI vkEnumerateInstanceLayerProperties(uint32_t *count,
PFN_vkVoidFunction WINAPI vkGetInstanceProcAddr(VkInstance instance, const char *name)
{
TRACE("%p %s\n", instance, debugstr_a(name));
TRACE("%p, %s\n", instance, debugstr_a(name));
if (!strcmp(name, "vkEnumerateInstanceExtensionProperties"))
return (PFN_vkVoidFunction)vkEnumerateInstanceExtensionProperties;
......@@ -70,7 +78,7 @@ PFN_vkVoidFunction WINAPI vkGetInstanceProcAddr(VkInstance instance, const char
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved)
{
TRACE("(%p, %u, %p)\n", hinst, reason, reserved);
TRACE("%p, %u, %p\n", hinst, reason, reserved);
switch (reason)
{
......
......@@ -65,6 +65,7 @@ LOGGER = logging.Logger("vulkan")
LOGGER.addHandler(logging.StreamHandler())
VK_XML_VERSION = "1.1.76"
WINE_VK_VERSION = (1, 0)
# Filenames to create.
WINE_VULKAN_H = "../../include/wine/vulkan.h"
......@@ -129,7 +130,7 @@ CORE_EXTENSIONS = [
# Functions part of our winevulkan graphics driver interface.
# DRIVER_VERSION should be bumped on any change to driver interface
# in FUNCTION_OVERRIDES
DRIVER_VERSION = 4
DRIVER_VERSION = 5
# Table of functions for which we have a special implementation.
# These are regular device / instance functions for which we need
......@@ -143,6 +144,7 @@ FUNCTION_OVERRIDES = {
# Global functions
"vkCreateInstance" : {"dispatch" : False, "driver" : True, "thunk" : False},
"vkEnumerateInstanceExtensionProperties" : {"dispatch" : False, "driver" : True, "thunk" : False},
"vkEnumerateInstanceVersion": {"dispatch" : False, "driver" : True, "thunk" : False},
"vkGetInstanceProcAddr": {"dispatch" : False, "driver" : True, "thunk" : False},
# Instance functions
......@@ -2030,6 +2032,8 @@ class VkGenerator(object):
f.write("#ifndef __WINE_VULKAN_THUNKS_H\n")
f.write("#define __WINE_VULKAN_THUNKS_H\n\n")
f.write("#define WINE_VK_VERSION VK_API_VERSION_{0}_{1}\n\n".format(WINE_VK_VERSION[0], WINE_VK_VERSION[1]))
# Generate prototypes for device and instance functions requiring a custom implementation.
f.write("/* Functions for which we have custom implementations outside of the thunks. */\n")
for vk_func in self.registry.funcs.values():
......
......@@ -831,6 +831,19 @@ VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *layer_na
return *count < num_properties ? VK_INCOMPLETE : VK_SUCCESS;
}
VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *version)
{
VkResult res;
TRACE("%p\n", version);
res = vk_funcs->p_vkEnumerateInstanceVersion(version);
TRACE("API version %u.%u.%u.\n",
VK_VERSION_MAJOR(*version), VK_VERSION_MINOR(*version), VK_VERSION_PATCH(*version));
*version = min(WINE_VK_VERSION, *version);
return res;
}
VkResult WINAPI wine_vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *count,
VkPhysicalDevice *devices)
{
......@@ -1086,6 +1099,7 @@ static const struct vulkan_func vk_global_dispatch_table[] =
{
{"vkCreateInstance", &wine_vkCreateInstance},
{"vkEnumerateInstanceExtensionProperties", &wine_vkEnumerateInstanceExtensionProperties},
{"vkEnumerateInstanceVersion", &wine_vkEnumerateInstanceVersion},
{"vkGetInstanceProcAddr", &wine_vkGetInstanceProcAddr},
};
......
......@@ -38,6 +38,8 @@
#ifndef __WINE_VULKAN_THUNKS_H
#define __WINE_VULKAN_THUNKS_H
#define WINE_VK_VERSION VK_API_VERSION_1_0
/* Functions for which we have custom implementations outside of the thunks. */
VkResult WINAPI wine_vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers);
void WINAPI wine_vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers);
......
......@@ -149,7 +149,7 @@
@ stdcall wine_vkEnumerateDeviceExtensionProperties(ptr str ptr ptr)
@ stdcall wine_vkEnumerateDeviceLayerProperties(ptr ptr ptr)
@ stdcall wine_vkEnumerateInstanceExtensionProperties(str ptr ptr)
@ stub vkEnumerateInstanceVersion
@ stdcall wine_vkEnumerateInstanceVersion(ptr)
@ stdcall wine_vkEnumeratePhysicalDeviceGroups(ptr ptr ptr)
@ stdcall wine_vkEnumeratePhysicalDevices(ptr ptr ptr)
@ stdcall wine_vkFlushMappedMemoryRanges(ptr long ptr)
......
......@@ -79,6 +79,7 @@ static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *);
static void (*pvkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *);
static void (*pvkDestroySwapchainKHR)(VkDevice, VkSwapchainKHR, const VkAllocationCallbacks *);
static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *);
static VkResult (*pvkEnumerateInstanceVersion)(uint32_t *);
static VkResult (*pvkGetDeviceGroupSurfacePresentModesKHR)(VkDevice, VkSurfaceKHR, VkDeviceGroupPresentModeFlagsKHR *);
static void * (*pvkGetDeviceProcAddr)(VkDevice, const char *);
static void * (*pvkGetInstanceProcAddr)(VkInstance, const char *);
......@@ -128,6 +129,7 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
LOAD_FUNCPTR(vkGetPhysicalDeviceXlibPresentationSupportKHR)
LOAD_FUNCPTR(vkGetSwapchainImagesKHR)
LOAD_FUNCPTR(vkQueuePresentKHR)
LOAD_OPTIONAL_FUNCPTR(vkEnumerateInstanceVersion)
LOAD_OPTIONAL_FUNCPTR(vkGetDeviceGroupSurfacePresentModesKHR)
LOAD_OPTIONAL_FUNCPTR(vkGetPhysicalDevicePresentRectanglesKHR)
#undef LOAD_FUNCPTR
......@@ -421,6 +423,19 @@ static VkResult X11DRV_vkEnumerateInstanceExtensionProperties(const char *layer_
return res;
}
static VkResult X11DRV_vkEnumerateInstanceVersion(uint32_t *version)
{
TRACE("%p\n", version);
if (!pvkEnumerateInstanceVersion)
{
*version = VK_API_VERSION_1_0;
return VK_SUCCESS;
}
return pvkEnumerateInstanceVersion(version);
}
static VkResult X11DRV_vkGetDeviceGroupSurfacePresentModesKHR(VkDevice device,
VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR *flags)
{
......@@ -537,6 +552,7 @@ static const struct vulkan_funcs vulkan_funcs =
X11DRV_vkDestroySurfaceKHR,
X11DRV_vkDestroySwapchainKHR,
X11DRV_vkEnumerateInstanceExtensionProperties,
X11DRV_vkEnumerateInstanceVersion,
X11DRV_vkGetDeviceGroupSurfacePresentModesKHR,
X11DRV_vkGetDeviceProcAddr,
X11DRV_vkGetInstanceProcAddr,
......@@ -593,6 +609,8 @@ static void *get_vulkan_driver_instance_proc_addr(const struct vulkan_funcs *vul
return vulkan_funcs->p_vkCreateInstance;
if (!strcmp(name, "EnumerateInstanceExtensionProperties"))
return vulkan_funcs->p_vkEnumerateInstanceExtensionProperties;
if (!strcmp(name, "EnumerateInstanceVersion"))
return vulkan_funcs->p_vkEnumerateInstanceVersion;
if (!instance)
return NULL;
......
......@@ -4299,6 +4299,7 @@ typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysica
typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice, uint32_t *, VkLayerProperties *);
typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *);
typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t *, VkLayerProperties *);
typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t *);
typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance, uint32_t *, VkPhysicalDeviceGroupProperties *);
typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroupsKHR)(VkInstance, uint32_t *, VkPhysicalDeviceGroupProperties *);
typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance, uint32_t *, VkPhysicalDevice *);
......@@ -4516,6 +4517,7 @@ VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physic
VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties);
VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties);
VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t *pApiVersion);
VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties);
VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroupsKHR(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties);
VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices);
......
......@@ -39,7 +39,7 @@
#define __WINE_VULKAN_DRIVER_H
/* Wine internal vulkan driver version, needs to be bumped upon vulkan_funcs changes. */
#define WINE_VULKAN_DRIVER_VERSION 4
#define WINE_VULKAN_DRIVER_VERSION 5
struct vulkan_funcs
{
......@@ -55,6 +55,7 @@ struct vulkan_funcs
void (*p_vkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *);
void (*p_vkDestroySwapchainKHR)(VkDevice, VkSwapchainKHR, const VkAllocationCallbacks *);
VkResult (*p_vkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *);
VkResult (*p_vkEnumerateInstanceVersion)(uint32_t *);
VkResult (*p_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice, VkSurfaceKHR, VkDeviceGroupPresentModeFlagsKHR *);
void * (*p_vkGetDeviceProcAddr)(VkDevice, const char *);
void * (*p_vkGetInstanceProcAddr)(VkInstance, const char *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment