Commit 3661194f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Pass Unix call arguments as a struct.

parent 9aef6543
......@@ -245,17 +245,24 @@ static BOOL wine_vk_init_once(void)
VkResult WINAPI vkCreateInstance(const VkInstanceCreateInfo *create_info,
const VkAllocationCallbacks *allocator, VkInstance *instance)
{
struct vkCreateInstance_params params;
TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
if(!wine_vk_init_once())
return VK_ERROR_INITIALIZATION_FAILED;
return unix_funcs->p_vkCreateInstance(create_info, allocator, instance);
params.pCreateInfo = create_info;
params.pAllocator = allocator;
params.pInstance = instance;
return unix_funcs->p_vkCreateInstance(&params);
}
VkResult WINAPI vkEnumerateInstanceExtensionProperties(const char *layer_name,
uint32_t *count, VkExtensionProperties *properties)
{
struct vkEnumerateInstanceExtensionProperties_params params;
TRACE("%p, %p, %p\n", layer_name, count, properties);
if (layer_name)
......@@ -270,11 +277,16 @@ VkResult WINAPI vkEnumerateInstanceExtensionProperties(const char *layer_name,
return VK_SUCCESS;
}
return unix_funcs->p_vkEnumerateInstanceExtensionProperties(layer_name, count, properties);
params.pLayerName = layer_name;
params.pPropertyCount = count;
params.pProperties = properties;
return unix_funcs->p_vkEnumerateInstanceExtensionProperties(&params);
}
VkResult WINAPI vkEnumerateInstanceVersion(uint32_t *version)
{
struct vkEnumerateInstanceVersion_params params;
TRACE("%p\n", version);
if (!wine_vk_init_once())
......@@ -283,7 +295,8 @@ VkResult WINAPI vkEnumerateInstanceVersion(uint32_t *version)
return VK_SUCCESS;
}
return unix_funcs->p_vkEnumerateInstanceVersion(version);
params.pApiVersion = version;
return unix_funcs->p_vkEnumerateInstanceVersion(&params);
}
static HANDLE get_display_device_init_mutex(void)
......@@ -358,18 +371,26 @@ static void fill_luid_property(VkPhysicalDeviceProperties2 *properties2)
void WINAPI vkGetPhysicalDeviceProperties2(VkPhysicalDevice phys_dev,
VkPhysicalDeviceProperties2 *properties2)
{
struct vkGetPhysicalDeviceProperties2_params params;
TRACE("%p, %p\n", phys_dev, properties2);
unix_funcs->p_vkGetPhysicalDeviceProperties2(phys_dev, properties2);
params.physicalDevice = phys_dev;
params.pProperties = properties2;
unix_funcs->p_vkGetPhysicalDeviceProperties2(&params);
fill_luid_property(properties2);
}
void WINAPI vkGetPhysicalDeviceProperties2KHR(VkPhysicalDevice phys_dev,
VkPhysicalDeviceProperties2 *properties2)
{
struct vkGetPhysicalDeviceProperties2KHR_params params;
TRACE("%p, %p\n", phys_dev, properties2);
unix_funcs->p_vkGetPhysicalDeviceProperties2KHR(phys_dev, properties2);
params.physicalDevice = phys_dev;
params.pProperties = properties2;
unix_funcs->p_vkGetPhysicalDeviceProperties2KHR(&params);
fill_luid_property(properties2);
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -627,6 +627,9 @@ class VkFunction(object):
def is_required(self):
return self.required
def returns_longlong(self):
return self.type in ["uint64_t", "VkDeviceAddress"]
def needs_conversion(self):
""" Check if the function needs any input/output type conversion.
Functions need input/output conversion if struct parameters have
......@@ -730,33 +733,40 @@ class VkFunction(object):
params = ", ".join([p.variable(conv=False, params_prefix=params_prefix) for p in self.params])
# Call the native Vulkan function.
if self.type == "void":
body += " {0}{1}.p_{2}({3});\n".format(params_prefix, self.params[0].dispatch_table(),
self.name, params)
else:
body += " return {0}{1}.p_{2}({3});\n".format(params_prefix, self.params[0].dispatch_table(),
self.name, params)
body += " "
if self.returns_longlong():
body += "{0}result = ".format(params_prefix)
elif self.type != "void":
body += "return "
body += "{0}{1}.p_{2}({3});\n".format(params_prefix, self.params[0].dispatch_table(),
self.name, params)
if self.type == "void" or self.returns_longlong():
body += " return STATUS_SUCCESS;\n"
return body
def loader_body(self):
body = ""
params = ", ".join([p.name for p in self.params])
body = " struct {0}_params params;\n".format(self.name)
for p in self.params:
body += " params.{0} = {0};\n".format(p.name)
body += " ";
# Call the function from unix_funcs.
if self.type == "void":
body += " unix_funcs->p_{0}({1});\n".format(self.name, params)
else:
body += " return unix_funcs->p_{0}({1});\n".format(self.name, params)
if self.type != "void" and not self.returns_longlong():
body += "return "
body += "unix_funcs->p_{0}(&params);\n".format(self.name)
if self.returns_longlong():
body += " return params.result;\n"
return body
def body_conversion(self, conv, params_prefix=""):
body = ""
result_prefix = ""
# Declare a variable to hold the result for non-void functions.
if self.type != "void":
if self.returns_longlong():
result_prefix = "params->"
elif self.type != "void":
body += " {0} result;\n".format(self.type)
# Declare any tmp parameters for conversion.
......@@ -789,8 +799,9 @@ class VkFunction(object):
body += " {0}{1}.p_{2}({3});\n".format(params_prefix, self.params[0].dispatch_table(),
self.name, params)
else:
body += " result = {0}{1}.p_{2}({3});\n".format(params_prefix, self.params[0].dispatch_table(),
self.name, params)
body += " {0}result = {1}{2}.p_{3}({4});\n".format(result_prefix, params_prefix,
self.params[0].dispatch_table(),
self.name, params)
body += "\n"
......@@ -807,8 +818,10 @@ class VkFunction(object):
body += p.free(prefix=params_prefix)
# Finally return the result.
if self.type != "void":
if self.type != "void" and not self.returns_longlong():
body += " return result;\n"
else:
body += " return STATUS_SUCCESS;\n"
return body
......@@ -849,22 +862,29 @@ class VkFunction(object):
return stub
def thunk(self, call_conv=None, prefix=None):
thunk = self.prototype(call_conv=call_conv, prefix=prefix)
thunk += "\n{\n"
if self.needs_private_thunk():
thunk = self.prototype(call_conv=call_conv, prefix=prefix)
thunk += "\n{\n"
params_prefix = ""
else:
thunk = "NTSTATUS {0} {1}{2}(void *args)\n".format(call_conv, prefix, self.name)
thunk += "{\n"
thunk += " struct {0}_params *params = args;\n".format(self.name)
params_prefix = "params->"
if self.needs_conversion():
thunk += "#if defined(USE_STRUCT_CONVERSION)\n"
thunk += self.body_conversion(conv=True)
thunk += self.body_conversion(conv=True, params_prefix=params_prefix)
thunk += "#else\n"
if self.needs_unwrapping():
thunk += self.body_conversion(conv=False)
thunk += self.body_conversion(conv=False, params_prefix=params_prefix)
else:
thunk += self.body()
thunk += self.body(params_prefix=params_prefix)
thunk += "#endif\n"
elif self.needs_unwrapping():
thunk += self.body_conversion(conv=False)
thunk += self.body_conversion(conv=False, params_prefix=params_prefix)
else:
thunk += self.body()
thunk += self.body(params_prefix=params_prefix)
thunk += "}\n\n"
return thunk
......@@ -1615,7 +1635,7 @@ class VkParam(object):
else:
return " convert_{0}_host_to_win(&{2}_host, {1}{2});\n".format(self.type, prefix, self.name)
def definition(self, postfix=None):
def definition(self, postfix=None, is_member=False):
""" Return prototype for the parameter. E.g. 'const char *foo' """
proto = ""
......@@ -1626,6 +1646,8 @@ class VkParam(object):
if self.is_pointer():
proto += " {0}{1}".format(self.pointer, self.name)
elif is_member and self.is_static_array():
proto += " *" + self.name
else:
proto += " " + self.name
......@@ -1634,7 +1656,7 @@ class VkParam(object):
if postfix is not None:
proto += postfix
if self.is_static_array():
if not is_member and self.is_static_array():
proto += "[{0}]".format(self.array_len)
return proto
......@@ -2821,10 +2843,7 @@ class VkGenerator(object):
if vk_func.needs_thunk() and not vk_func.needs_private_thunk():
continue
if vk_func.is_core_func():
f.write("{0};\n".format(vk_func.prototype("WINAPI", prefix=prefix)))
else:
f.write("{0};\n".format(vk_func.prototype("WINAPI", prefix=prefix, postfix="DECLSPEC_HIDDEN")))
f.write("NTSTATUS WINAPI {0}{1}(void *args) DECLSPEC_HIDDEN;\n".format(prefix, vk_func.name))
f.write("\n")
f.write("/* Private thunks */\n")
......@@ -3002,7 +3021,7 @@ class VkGenerator(object):
if vk_func.loader_thunk_type == ThunkType.NONE:
continue
f.write(" {0};\n".format(vk_func.pfn(conv=False, call_conv="WINAPI")))
f.write(" NTSTATUS (WINAPI *p_{1})(void *args);\n".format(vk_func.type, vk_func.name))
f.write("\n")
f.write(" /* winevulkan specific functions */\n")
f.write(" BOOL (WINAPI *p_is_available_instance_function)(VkInstance, const char *);\n")
......@@ -3015,6 +3034,23 @@ class VkGenerator(object):
f.write(" unix_count,\n")
f.write("};\n\n")
f.write("#include \"pshpack4.h\"\n\n")
for vk_func in self.registry.funcs.values():
if not vk_func.needs_exposing():
continue
if vk_func.loader_thunk_type == ThunkType.NONE:
continue
f.write("struct {0}_params\n".format(vk_func.name))
f.write("{\n");
for p in vk_func.params:
f.write(" {0};\n".format(p.definition(is_member=True)))
if vk_func.returns_longlong():
f.write(" {0} result;\n".format(vk_func.type))
f.write("};\n\n");
f.write("#include \"poppack.h\"\n\n")
f.write("#endif /* __WINE_VULKAN_LOADER_THUNKS_H */\n")
def generate_vulkan_h(self, f):
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -15,44 +15,44 @@
#define WINE_VK_VERSION VK_API_VERSION_1_2
/* Functions for which we have custom implementations outside of the thunks. */
VkResult WINAPI wine_vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers);
VkResult WINAPI wine_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool);
VkResult WINAPI wine_vkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) DECLSPEC_HIDDEN;
VkResult WINAPI wine_vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger) DECLSPEC_HIDDEN;
VkResult WINAPI wine_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
VkResult WINAPI wine_vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance);
VkResult WINAPI wine_vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
void WINAPI wine_vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator);
void WINAPI wine_vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator) DECLSPEC_HIDDEN;
void WINAPI wine_vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, const VkAllocationCallbacks *pAllocator) DECLSPEC_HIDDEN;
void WINAPI wine_vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator);
void WINAPI wine_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator);
void WINAPI wine_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator);
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;
VkResult WINAPI wine_vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices);
void WINAPI wine_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers);
VkResult WINAPI wine_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoEXT *pTimestampInfos, uint64_t *pTimestamps, uint64_t *pMaxDeviation) DECLSPEC_HIDDEN;
PFN_vkVoidFunction WINAPI wine_vkGetDeviceProcAddr(VkDevice device, const char *pName);
void WINAPI wine_vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue);
void WINAPI wine_vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue);
PFN_vkVoidFunction WINAPI wine_vkGetInstanceProcAddr(VkInstance instance, const char *pName);
VkResult WINAPI wine_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(VkPhysicalDevice physicalDevice, uint32_t *pTimeDomainCount, VkTimeDomainEXT *pTimeDomains) DECLSPEC_HIDDEN;
void WINAPI wine_vkGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties);
void WINAPI wine_vkGetPhysicalDeviceExternalBufferPropertiesKHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) DECLSPEC_HIDDEN;
void WINAPI wine_vkGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties);
void WINAPI wine_vkGetPhysicalDeviceExternalFencePropertiesKHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) DECLSPEC_HIDDEN;
void WINAPI wine_vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties);
void WINAPI wine_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties) DECLSPEC_HIDDEN;
VkResult WINAPI wine_vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties);
VkResult WINAPI wine_vkGetPhysicalDeviceImageFormatProperties2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties) DECLSPEC_HIDDEN;
VkResult WINAPI wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, VkSurfaceCapabilities2KHR *pSurfaceCapabilities);
VkResult WINAPI wine_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities);
NTSTATUS WINAPI wine_vkAllocateCommandBuffers(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkCreateCommandPool(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkCreateDebugReportCallbackEXT(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkCreateDebugUtilsMessengerEXT(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkCreateDevice(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkCreateInstance(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkCreateWin32SurfaceKHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkDestroyCommandPool(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkDestroyDebugReportCallbackEXT(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkDestroyDebugUtilsMessengerEXT(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkDestroyDevice(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkDestroyInstance(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkDestroySurfaceKHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumerateDeviceExtensionProperties(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumerateDeviceLayerProperties(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumerateInstanceExtensionProperties(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumerateInstanceLayerProperties(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumerateInstanceVersion(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumeratePhysicalDeviceGroups(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumeratePhysicalDeviceGroupsKHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkEnumeratePhysicalDevices(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkFreeCommandBuffers(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetCalibratedTimestampsEXT(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetDeviceProcAddr(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetDeviceQueue(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetDeviceQueue2(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetInstanceProcAddr(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceExternalBufferProperties(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceExternalBufferPropertiesKHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceExternalFenceProperties(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceExternalFencePropertiesKHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceExternalSemaphoreProperties(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceImageFormatProperties2(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceImageFormatProperties2KHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR(void *args) DECLSPEC_HIDDEN;
NTSTATUS WINAPI wine_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(void *args) DECLSPEC_HIDDEN;
/* Private thunks */
VkResult thunk_vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties) 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