Commit c7eeeb01 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Introduce unix_funcs struct.

parent 03dcb369
......@@ -39,6 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2);
DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_GPU_VULKAN_UUID, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5c, 2);
const struct unix_funcs *unix_funcs;
static HINSTANCE hinstance;
static void *wine_vk_get_global_proc_addr(const char *name);
......@@ -217,7 +219,7 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
if (!driver)
ERR("Failed to load Wine graphics driver supporting Vulkan.\n");
else
unix_vk_init(driver);
unix_funcs = unix_vk_init(driver);
return driver != NULL;
}
......
......@@ -75,6 +75,7 @@ WINE_VULKAN_JSON = "winevulkan.json"
WINE_VULKAN_SPEC = "winevulkan.spec"
WINE_VULKAN_THUNKS_C = "vulkan_thunks.c"
WINE_VULKAN_THUNKS_H = "vulkan_thunks.h"
WINE_VULKAN_LOADER_THUNKS_H = "loader_thunks.h"
# Extension enum values start at a certain offset (EXT_BASE).
# Relative to the offset each extension has a block (EXT_BLOCK_SIZE)
......@@ -151,12 +152,14 @@ class ThunkType(Enum):
# - PUBLIC means the implementation is fully auto generated.
# - PRIVATE thunks can be used in custom implementations for
# struct conversion.
# - loader_thunk sets whether to create a thunk for unix_funcs.
FUNCTION_OVERRIDES = {
# Global functions
"vkCreateInstance" : {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE},
"vkEnumerateInstanceExtensionProperties" : {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE},
"vkEnumerateInstanceLayerProperties" : {"dispatch" : False, "driver" : False, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.NONE},
"vkEnumerateInstanceVersion": {"dispatch" : False, "driver" : False, "thunk" : ThunkType.NONE},
"vkGetInstanceProcAddr": {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE},
"vkGetInstanceProcAddr": {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.NONE},
# Instance functions
"vkCreateDevice" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.NONE},
......@@ -179,7 +182,7 @@ FUNCTION_OVERRIDES = {
"vkDestroyCommandPool" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE},
"vkDestroyDevice" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.NONE},
"vkFreeCommandBuffers" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.NONE},
"vkGetDeviceProcAddr" : {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE},
"vkGetDeviceProcAddr" : {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.NONE},
"vkGetDeviceQueue" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE},
"vkGetDeviceQueue2" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE},
"vkQueueSubmit" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE},
......@@ -525,6 +528,7 @@ class VkFunction(object):
self.dispatch = func_info["dispatch"] if func_info else True
self.driver = func_info["driver"] if func_info else False
self.thunk_type = func_info["thunk"] if func_info else ThunkType.PUBLIC
self.loader_thunk_type = func_info["loader_thunk"] if func_info and "loader_thunk" in func_info else ThunkType.PUBLIC
# Required is set while parsing which APIs and types are required
# and is used by the code generation.
......@@ -2409,7 +2413,18 @@ class VkGenerator(object):
f.write(" default:\n")
f.write(" return handle;\n")
f.write(" }\n")
f.write("}\n")
f.write("}\n\n")
f.write("const struct unix_funcs loader_funcs =\n")
f.write("{\n")
for vk_func in self.registry.funcs.values():
if not vk_func.is_required():
continue
if vk_func.loader_thunk_type == ThunkType.NONE:
continue
f.write(" &{1}{0},\n".format(vk_func.name, prefix))
f.write("};\n")
def generate_thunks_h(self, f, prefix):
self._generate_copyright(f)
......@@ -2523,6 +2538,25 @@ class VkGenerator(object):
f.write("#endif /* __WINE_VULKAN_THUNKS_H */\n")
def generate_loader_thunks_h(self, f, prefix):
self._generate_copyright(f)
f.write("#ifndef __WINE_VULKAN_LOADER_THUNKS_H\n")
f.write("#define __WINE_VULKAN_LOADER_THUNKS_H\n\n")
f.write("struct unix_funcs\n")
f.write("{\n")
for vk_func in self.registry.funcs.values():
if not vk_func.is_required():
continue
if vk_func.loader_thunk_type == ThunkType.NONE:
continue
f.write(" {0};\n".format(vk_func.pfn(conv=False, call_conv="WINAPI")))
f.write("};\n\n")
f.write("#endif /* __WINE_VULKAN_LOADER_THUNKS_H */\n")
def generate_vulkan_h(self, f):
self._generate_copyright(f)
f.write("#ifndef __WINE_VULKAN_H\n")
......@@ -3341,6 +3375,9 @@ def main():
with open(WINE_VULKAN_THUNKS_C, "w") as f:
generator.generate_thunks_c(f, "wine_")
with open(WINE_VULKAN_LOADER_THUNKS_H, "w") as f:
generator.generate_loader_thunks_h(f, "wine_")
with open(WINE_VULKAN_JSON, "w") as f:
generate_vulkan_json(f)
......
......@@ -446,10 +446,11 @@ static void wine_vk_device_free(struct VkDevice_T *device)
free(device);
}
void unix_vk_init(const struct vulkan_funcs *driver)
const struct unix_funcs *unix_vk_init(const struct vulkan_funcs *driver)
{
vk_funcs = driver;
p_vkEnumerateInstanceVersion = vk_funcs->p_vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceVersion");
return &loader_funcs;
}
/* Helper function for converting between win32 and host compatible VkInstanceCreateInfo.
......
......@@ -35,6 +35,7 @@
#include "wine/vulkan_driver.h"
#include "vulkan_thunks.h"
#include "loader_thunks.h"
/* Magic value defined by Vulkan ICD / Loader spec */
#define VULKAN_ICD_MAGIC_VALUE 0x01CDC0DE
......@@ -245,7 +246,9 @@ BOOL wine_vk_instance_extension_supported(const char *name) DECLSPEC_HIDDEN;
BOOL wine_vk_is_type_wrapped(VkObjectType type) DECLSPEC_HIDDEN;
uint64_t wine_vk_unwrap_handle(VkObjectType type, uint64_t handle) DECLSPEC_HIDDEN;
void unix_vk_init(const struct vulkan_funcs *driver) DECLSPEC_HIDDEN;
extern const struct unix_funcs loader_funcs;
const struct unix_funcs *unix_vk_init(const struct vulkan_funcs *driver) DECLSPEC_HIDDEN;
VkResult WINAPI unix_vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator, VkInstance *instance) DECLSPEC_HIDDEN;
......
......@@ -36,6 +36,7 @@ void WINAPI wine_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
VkResult WINAPI wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
VkResult WINAPI wine_vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties);
VkResult WINAPI wine_vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
VkResult WINAPI wine_vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties);
VkResult WINAPI wine_vkEnumerateInstanceVersion(uint32_t *pApiVersion);
VkResult WINAPI wine_vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties);
VkResult WINAPI wine_vkEnumeratePhysicalDeviceGroupsKHR(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties) DECLSPEC_HIDDEN;
......
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