Commit a875c185 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winevulkan: Remove now unnecessary vkCreateInstance driver entry.

parent c7da2450
......@@ -78,6 +78,7 @@ static void d3dkmt_init_vulkan(void)
.enabledExtensionCount = ARRAY_SIZE( extensions ),
.ppEnabledExtensionNames = extensions,
};
PFN_vkCreateInstance p_vkCreateInstance;
VkResult vr;
if (!(vulkan_funcs = __wine_get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION )))
......@@ -86,7 +87,8 @@ static void d3dkmt_init_vulkan(void)
return;
}
if ((vr = vulkan_funcs->p_vkCreateInstance( &create_info, NULL, &d3dkmt_vk_instance )))
p_vkCreateInstance = vulkan_funcs->p_vkGetInstanceProcAddr( NULL, "vkCreateInstance" );
if ((vr = p_vkCreateInstance( &create_info, NULL, &d3dkmt_vk_instance )))
{
WARN( "Failed to create a Vulkan instance, vr %d.\n", vr );
vulkan_funcs = NULL;
......
......@@ -63,8 +63,6 @@ static void *win32u_vkGetInstanceProcAddr( VkInstance instance, const char *name
{
TRACE( "instance %p, name %s\n", instance, debugstr_a(name) );
if (!strcmp( name, "vkCreateInstance" )) return vulkan_funcs.p_vkCreateInstance;
if (!instance) return p_vkGetInstanceProcAddr( instance, name );
if (!strcmp( name, "vkCreateWin32SurfaceKHR" )) return vulkan_funcs.p_vkCreateWin32SurfaceKHR;
......
......@@ -77,7 +77,6 @@ typedef struct VkMetalSurfaceCreateInfoEXT
const void *pLayer; /* CAMetalLayer */
} VkMetalSurfaceCreateInfoEXT;
static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *);
static VkResult (*pvkCreateSwapchainKHR)(VkDevice, const VkSwapchainCreateInfoKHR *, const VkAllocationCallbacks *, VkSwapchainKHR *);
static VkResult (*pvkCreateMacOSSurfaceMVK)(VkInstance, const VkMacOSSurfaceCreateInfoMVK*, const VkAllocationCallbacks *, VkSurfaceKHR *);
static VkResult (*pvkCreateMetalSurfaceEXT)(VkInstance, const VkMetalSurfaceCreateInfoEXT*, const VkAllocationCallbacks *, VkSurfaceKHR *);
......@@ -95,54 +94,6 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle)
return (struct wine_vk_surface *)(uintptr_t)handle;
}
/* Helper function for converting between win32 and MoltenVK compatible VkInstanceCreateInfo.
* Caller is responsible for allocation and cleanup of 'dst'.
*/
static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src,
VkInstanceCreateInfo *dst)
{
unsigned int i;
const char **enabled_extensions = NULL;
dst->sType = src->sType;
dst->flags = src->flags;
dst->pApplicationInfo = src->pApplicationInfo;
dst->pNext = src->pNext;
dst->enabledLayerCount = 0;
dst->ppEnabledLayerNames = NULL;
dst->enabledExtensionCount = 0;
dst->ppEnabledExtensionNames = NULL;
if (src->enabledExtensionCount > 0)
{
enabled_extensions = calloc(src->enabledExtensionCount, sizeof(*src->ppEnabledExtensionNames));
if (!enabled_extensions)
{
ERR("Failed to allocate memory for enabled extensions\n");
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
for (i = 0; i < src->enabledExtensionCount; i++)
{
/* Substitute extension with MoltenVK ones else copy. Long-term, when we
* support more extensions, we should store these in a list.
*/
if (!strcmp(src->ppEnabledExtensionNames[i], "VK_KHR_win32_surface"))
{
enabled_extensions[i] = pvkCreateMetalSurfaceEXT ? "VK_EXT_metal_surface" : "VK_MVK_macos_surface";
}
else
{
enabled_extensions[i] = src->ppEnabledExtensionNames[i];
}
}
dst->ppEnabledExtensionNames = enabled_extensions;
dst->enabledExtensionCount = src->enabledExtensionCount;
}
return VK_SUCCESS;
}
static void wine_vk_surface_destroy(VkInstance instance, struct wine_vk_surface *surface)
{
pvkDestroySurfaceKHR(instance, surface->host_surface, NULL /* allocator */);
......@@ -156,33 +107,6 @@ static void wine_vk_surface_destroy(VkInstance instance, struct wine_vk_surface
free(surface);
}
static VkResult macdrv_vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator, VkInstance *instance)
{
VkInstanceCreateInfo create_info_host;
VkResult res;
TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
if (allocator)
FIXME("Support for allocation callbacks not implemented yet\n");
/* Perform a second pass on converting VkInstanceCreateInfo. Winevulkan
* performed a first pass in which it handles everything except for WSI
* functionality such as VK_KHR_win32_surface. Handle this now.
*/
res = wine_vk_instance_convert_create_info(create_info, &create_info_host);
if (res != VK_SUCCESS)
{
ERR("Failed to convert instance create info, res=%d\n", res);
return res;
}
res = pvkCreateInstance(&create_info_host, NULL /* allocator */, instance);
free((void *)create_info_host.ppEnabledExtensionNames);
return res;
}
static VkResult macdrv_vkCreateSwapchainKHR(VkDevice device,
const VkSwapchainCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator, VkSwapchainKHR *swapchain)
......@@ -377,7 +301,6 @@ static VkSurfaceKHR macdrv_wine_get_host_surface(VkSurfaceKHR surface)
static const struct vulkan_funcs vulkan_funcs =
{
macdrv_vkCreateInstance,
macdrv_vkCreateSwapchainKHR,
macdrv_vkCreateWin32SurfaceKHR,
macdrv_vkDestroyInstance,
......@@ -402,7 +325,6 @@ UINT macdrv_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *d
}
#define LOAD_FUNCPTR(f) if ((p##f = dlsym(vulkan_handle, #f)) == NULL) return STATUS_PROCEDURE_NOT_FOUND;
LOAD_FUNCPTR(vkCreateInstance)
LOAD_FUNCPTR(vkCreateSwapchainKHR)
LOAD_FUNCPTR(vkCreateMacOSSurfaceMVK)
LOAD_FUNCPTR(vkCreateMetalSurfaceEXT)
......
......@@ -196,7 +196,6 @@ FUNCTION_OVERRIDES = {
# functions for which a user driver entry must be generated
USER_DRIVER_FUNCS = {
"vkCreateInstance",
"vkCreateSwapchainKHR",
"vkCreateWin32SurfaceKHR",
"vkDestroyInstance",
......
......@@ -32,6 +32,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
static PFN_vkCreateInstance p_vkCreateInstance;
static PFN_vkEnumerateInstanceVersion p_vkEnumerateInstanceVersion;
static PFN_vkEnumerateInstanceExtensionProperties p_vkEnumerateInstanceExtensionProperties;
......@@ -548,6 +549,7 @@ NTSTATUS init_vulkan(void *args)
return STATUS_UNSUCCESSFUL;
}
p_vkCreateInstance = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkCreateInstance");
p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
p_vkEnumerateInstanceExtensionProperties = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
......@@ -880,7 +882,7 @@ VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *create_info,
init_conversion_context(&ctx);
res = wine_vk_instance_convert_create_info(&ctx, create_info, &create_info_host, object);
if (res == VK_SUCCESS)
res = vk_funcs->p_vkCreateInstance(&create_info_host, NULL /* allocator */, &object->host_instance);
res = p_vkCreateInstance(&create_info_host, NULL /* allocator */, &object->host_instance);
free_conversion_context(&ctx);
if (res != VK_SUCCESS)
{
......
......@@ -53,7 +53,6 @@ typedef struct VkWaylandSurfaceCreateInfoKHR
struct wl_surface *surface;
} VkWaylandSurfaceCreateInfoKHR;
static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *);
static VkResult (*pvkCreateSwapchainKHR)(VkDevice, const VkSwapchainCreateInfoKHR *, const VkAllocationCallbacks *, VkSwapchainKHR *);
static VkResult (*pvkCreateWaylandSurfaceKHR)(VkInstance, const VkWaylandSurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *);
static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *);
......@@ -144,49 +143,6 @@ static struct wine_vk_swapchain *wine_vk_swapchain_from_handle(VkSwapchainKHR ha
return NULL;
}
/* Helper function for converting between win32 and Wayland compatible VkInstanceCreateInfo.
* Caller is responsible for allocation and cleanup of 'dst'. */
static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src,
VkInstanceCreateInfo *dst)
{
unsigned int i;
const char **enabled_extensions = NULL;
dst->sType = src->sType;
dst->flags = src->flags;
dst->pApplicationInfo = src->pApplicationInfo;
dst->pNext = src->pNext;
dst->enabledLayerCount = 0;
dst->ppEnabledLayerNames = NULL;
dst->enabledExtensionCount = 0;
dst->ppEnabledExtensionNames = NULL;
if (src->enabledExtensionCount > 0)
{
enabled_extensions = calloc(src->enabledExtensionCount,
sizeof(*src->ppEnabledExtensionNames));
if (!enabled_extensions)
{
ERR("Failed to allocate memory for enabled extensions\n");
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
for (i = 0; i < src->enabledExtensionCount; i++)
{
/* Substitute extension with Wayland ones else copy. Long-term, when we
* support more extensions, we should store these in a list. */
if (!strcmp(src->ppEnabledExtensionNames[i], "VK_KHR_win32_surface"))
enabled_extensions[i] = "VK_KHR_wayland_surface";
else
enabled_extensions[i] = src->ppEnabledExtensionNames[i];
}
dst->ppEnabledExtensionNames = enabled_extensions;
dst->enabledExtensionCount = src->enabledExtensionCount;
}
return VK_SUCCESS;
}
static void vk_result_update_out_of_date(VkResult *res)
{
/* If the current result is less severe than out_of_date, which for
......@@ -250,34 +206,6 @@ static VkResult check_queue_present(const VkPresentInfoKHR *present_info,
return res;
}
static VkResult wayland_vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator,
VkInstance *instance)
{
VkInstanceCreateInfo create_info_host;
VkResult res;
TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
if (allocator)
FIXME("Support for allocation callbacks not implemented yet\n");
/* Perform a second pass on converting VkInstanceCreateInfo. Winevulkan
* performed a first pass in which it handles everything except for WSI
* functionality such as VK_KHR_win32_surface. Handle this now. */
res = wine_vk_instance_convert_create_info(create_info, &create_info_host);
if (res != VK_SUCCESS)
{
ERR("Failed to convert instance create info, res=%d\n", res);
return res;
}
res = pvkCreateInstance(&create_info_host, NULL /* allocator */, instance);
free((void *)create_info_host.ppEnabledExtensionNames);
return res;
}
static VkResult wayland_vkCreateSwapchainKHR(VkDevice device,
const VkSwapchainCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator,
......@@ -481,7 +409,6 @@ static VkSurfaceKHR wayland_wine_get_host_surface(VkSurfaceKHR surface)
static const struct vulkan_funcs vulkan_funcs =
{
.p_vkCreateInstance = wayland_vkCreateInstance,
.p_vkCreateSwapchainKHR = wayland_vkCreateSwapchainKHR,
.p_vkCreateWin32SurfaceKHR = wayland_vkCreateWin32SurfaceKHR,
.p_vkDestroyInstance = wayland_vkDestroyInstance,
......@@ -506,7 +433,6 @@ UINT WAYLAND_VulkanInit(UINT version, void *vulkan_handle, struct vulkan_funcs *
}
#define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) return STATUS_PROCEDURE_NOT_FOUND;
LOAD_FUNCPTR(vkCreateInstance);
LOAD_FUNCPTR(vkCreateSwapchainKHR);
LOAD_FUNCPTR(vkCreateWaylandSurfaceKHR);
LOAD_FUNCPTR(vkDestroyInstance);
......
......@@ -76,7 +76,6 @@ typedef struct VkXlibSurfaceCreateInfoKHR
Window window;
} VkXlibSurfaceCreateInfoKHR;
static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *);
static VkResult (*pvkCreateSwapchainKHR)(VkDevice, const VkSwapchainCreateInfoKHR *, const VkAllocationCallbacks *, VkSwapchainKHR *);
static VkResult (*pvkCreateXlibSurfaceKHR)(VkInstance, const VkXlibSurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *);
static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *);
......@@ -93,54 +92,6 @@ static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle)
return (struct wine_vk_surface *)(uintptr_t)handle;
}
/* Helper function for converting between win32 and X11 compatible VkInstanceCreateInfo.
* Caller is responsible for allocation and cleanup of 'dst'.
*/
static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src,
VkInstanceCreateInfo *dst)
{
unsigned int i;
const char **enabled_extensions = NULL;
dst->sType = src->sType;
dst->flags = src->flags;
dst->pApplicationInfo = src->pApplicationInfo;
dst->pNext = src->pNext;
dst->enabledLayerCount = 0;
dst->ppEnabledLayerNames = NULL;
dst->enabledExtensionCount = 0;
dst->ppEnabledExtensionNames = NULL;
if (src->enabledExtensionCount > 0)
{
enabled_extensions = calloc(src->enabledExtensionCount, sizeof(*src->ppEnabledExtensionNames));
if (!enabled_extensions)
{
ERR("Failed to allocate memory for enabled extensions\n");
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
for (i = 0; i < src->enabledExtensionCount; i++)
{
/* Substitute extension with X11 ones else copy. Long-term, when we
* support more extensions, we should store these in a list.
*/
if (!strcmp(src->ppEnabledExtensionNames[i], "VK_KHR_win32_surface"))
{
enabled_extensions[i] = "VK_KHR_xlib_surface";
}
else
{
enabled_extensions[i] = src->ppEnabledExtensionNames[i];
}
}
dst->ppEnabledExtensionNames = enabled_extensions;
dst->enabledExtensionCount = src->enabledExtensionCount;
}
return VK_SUCCESS;
}
static struct wine_vk_surface *wine_vk_surface_grab(struct wine_vk_surface *surface)
{
InterlockedIncrement(&surface->ref);
......@@ -198,33 +149,6 @@ void vulkan_thread_detach(void)
pthread_mutex_unlock(&vulkan_mutex);
}
static VkResult X11DRV_vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator, VkInstance *instance)
{
VkInstanceCreateInfo create_info_host;
VkResult res;
TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
if (allocator)
FIXME("Support for allocation callbacks not implemented yet\n");
/* Perform a second pass on converting VkInstanceCreateInfo. Winevulkan
* performed a first pass in which it handles everything except for WSI
* functionality such as VK_KHR_win32_surface. Handle this now.
*/
res = wine_vk_instance_convert_create_info(create_info, &create_info_host);
if (res != VK_SUCCESS)
{
ERR("Failed to convert instance create info, res=%d\n", res);
return res;
}
res = pvkCreateInstance(&create_info_host, NULL /* allocator */, instance);
free((void *)create_info_host.ppEnabledExtensionNames);
return res;
}
static VkResult X11DRV_vkCreateSwapchainKHR(VkDevice device,
const VkSwapchainCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator, VkSwapchainKHR *swapchain)
......@@ -412,7 +336,6 @@ static VkSurfaceKHR X11DRV_wine_get_host_surface( VkSurfaceKHR surface )
static const struct vulkan_funcs vulkan_funcs =
{
X11DRV_vkCreateInstance,
X11DRV_vkCreateSwapchainKHR,
X11DRV_vkCreateWin32SurfaceKHR,
X11DRV_vkDestroyInstance,
......@@ -439,7 +362,6 @@ UINT X11DRV_VulkanInit( UINT version, void *vulkan_handle, struct vulkan_funcs *
init_recursive_mutex( &vulkan_mutex );
#define LOAD_FUNCPTR( f ) if (!(p##f = dlsym( vulkan_handle, #f ))) return STATUS_PROCEDURE_NOT_FOUND;
LOAD_FUNCPTR( vkCreateInstance );
LOAD_FUNCPTR( vkCreateSwapchainKHR );
LOAD_FUNCPTR( vkCreateXlibSurfaceKHR );
LOAD_FUNCPTR( vkDestroyInstance );
......
......@@ -648,6 +648,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid
VkPhysicalDevice *vk_physical_devices = NULL;
VkPhysicalDeviceProperties2 properties2;
VkPhysicalDeviceMemoryProperties mem_properties;
PFN_vkCreateInstance pvkCreateInstance;
VkInstanceCreateInfo create_info;
VkPhysicalDeviceIDProperties id;
VkInstance vk_instance = NULL;
......@@ -664,13 +665,6 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid
create_info.enabledExtensionCount = ARRAY_SIZE(extensions);
create_info.ppEnabledExtensionNames = extensions;
vr = vulkan_funcs->p_vkCreateInstance( &create_info, NULL, &vk_instance );
if (vr != VK_SUCCESS)
{
WARN("Failed to create a Vulkan instance, vr %d.\n", vr);
goto done;
}
#define LOAD_VK_FUNC(f) \
if (!(p##f = (void *)vulkan_funcs->p_vkGetInstanceProcAddr( vk_instance, #f ))) \
{ \
......@@ -678,6 +672,15 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid
goto done; \
}
LOAD_VK_FUNC( vkCreateInstance )
vr = pvkCreateInstance( &create_info, NULL, &vk_instance );
if (vr != VK_SUCCESS)
{
WARN( "Failed to create a Vulkan instance, vr %d.\n", vr );
goto done;
}
LOAD_VK_FUNC(vkEnumeratePhysicalDevices)
LOAD_VK_FUNC(vkGetPhysicalDeviceProperties2KHR)
LOAD_VK_FUNC(vkGetRandROutputDisplayEXT)
......
......@@ -21,7 +21,7 @@
#define __WINE_VULKAN_DRIVER_H
/* Wine internal vulkan driver version, needs to be bumped upon vulkan_funcs changes. */
#define WINE_VULKAN_DRIVER_VERSION 20
#define WINE_VULKAN_DRIVER_VERSION 21
struct vulkan_funcs
{
......@@ -29,7 +29,6 @@ struct vulkan_funcs
* needs to provide. Other function calls will be provided indirectly by dispatch
* tables part of dispatchable Vulkan objects such as VkInstance or vkDevice.
*/
VkResult (*p_vkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *);
VkResult (*p_vkCreateSwapchainKHR)(VkDevice, const VkSwapchainCreateInfoKHR *, const VkAllocationCallbacks *, VkSwapchainKHR *);
VkResult (*p_vkCreateWin32SurfaceKHR)(VkInstance, const VkWin32SurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *);
void (*p_vkDestroyInstance)(VkInstance, const VkAllocationCallbacks *);
......
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