From: Jacek Caban jacek@codeweavers.com
--- dlls/winevulkan/loader.c | 34 ++++++++++++++++++++++++++++++++ dlls/winevulkan/loader_thunks.c | 19 ------------------ dlls/winevulkan/loader_thunks.h | 1 + dlls/winevulkan/make_vulkan | 4 ++-- dlls/winevulkan/vulkan.c | 18 ++++++++++------- dlls/winevulkan/vulkan_loader.h | 10 ++++++++++ dlls/winevulkan/vulkan_private.h | 9 +++------ 7 files changed, 61 insertions(+), 34 deletions(-)
diff --git a/dlls/winevulkan/loader.c b/dlls/winevulkan/loader.c index 221a62a5680..ce5d2314169 100644 --- a/dlls/winevulkan/loader.c +++ b/dlls/winevulkan/loader.c @@ -491,6 +491,40 @@ void WINAPI vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *alloca free(device); }
+VkResult WINAPI vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *create_info, + const VkAllocationCallbacks *allocator, VkCommandPool *ret) +{ + struct vkCreateCommandPool_params params; + struct vk_command_pool *cmd_pool; + VkResult result; + + if (!(cmd_pool = malloc(sizeof(*cmd_pool)))) + return VK_ERROR_OUT_OF_HOST_MEMORY; + cmd_pool->unix_handle = 0; + + params.device = device; + params.pCreateInfo = create_info; + params.pAllocator = allocator; + params.pCommandPool = ret; + params.client_ptr = cmd_pool; + result = vk_unix_call(unix_vkCreateCommandPool, ¶ms); + if (!cmd_pool->unix_handle) + free(cmd_pool); + return result; +} + +void WINAPI vkDestroyCommandPool(VkDevice device, VkCommandPool handle, const VkAllocationCallbacks *allocator) +{ + struct vk_command_pool *cmd_pool = command_pool_from_handle(handle); + struct vkDestroyCommandPool_params params; + + params.device = device; + params.commandPool = handle; + params.pAllocator = allocator; + vk_unix_call(unix_vkDestroyCommandPool, ¶ms); + free(cmd_pool); +} + static BOOL WINAPI call_vulkan_debug_report_callback( struct wine_vk_debug_report_params *params, ULONG size ) { return params->user_callback(params->flags, params->object_type, params->object_handle, params->location, diff --git a/dlls/winevulkan/loader_thunks.c b/dlls/winevulkan/loader_thunks.c index cb4ea68a8b4..32626c27eab 100644 --- a/dlls/winevulkan/loader_thunks.c +++ b/dlls/winevulkan/loader_thunks.c @@ -1999,16 +1999,6 @@ VkResult WINAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo return vk_unix_call(unix_vkCreateBufferView, ¶ms); }
-VkResult WINAPI vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) -{ - struct vkCreateCommandPool_params params; - params.device = device; - params.pCreateInfo = pCreateInfo; - params.pAllocator = pAllocator; - params.pCommandPool = pCommandPool; - return vk_unix_call(unix_vkCreateCommandPool, ¶ms); -} - VkResult WINAPI vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { struct vkCreateComputePipelines_params params; @@ -2441,15 +2431,6 @@ void WINAPI vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const vk_unix_call(unix_vkDestroyBufferView, ¶ms); }
-void WINAPI vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) -{ - struct vkDestroyCommandPool_params params; - params.device = device; - params.commandPool = commandPool; - params.pAllocator = pAllocator; - vk_unix_call(unix_vkDestroyCommandPool, ¶ms); -} - void WINAPI vkDestroyCuFunctionNVX(VkDevice device, VkCuFunctionNVX function, const VkAllocationCallbacks *pAllocator) { struct vkDestroyCuFunctionNVX_params params; diff --git a/dlls/winevulkan/loader_thunks.h b/dlls/winevulkan/loader_thunks.h index b42496e3655..410041ef51c 100644 --- a/dlls/winevulkan/loader_thunks.h +++ b/dlls/winevulkan/loader_thunks.h @@ -2066,6 +2066,7 @@ struct vkCreateCommandPool_params const VkCommandPoolCreateInfo *pCreateInfo; const VkAllocationCallbacks *pAllocator; VkCommandPool *pCommandPool; + void *client_ptr; };
struct vkCreateComputePipelines_params diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index a1cb6452f25..068e140a738 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -201,10 +201,10 @@ FUNCTION_OVERRIDES = {
# Device functions "vkAllocateCommandBuffers" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.NONE}, - "vkCreateCommandPool" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE}, + "vkCreateCommandPool" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.PRIVATE, "extra_param" : "client_ptr"}, "vkCreateComputePipelines" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.PRIVATE}, "vkCreateGraphicsPipelines" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.PRIVATE}, - "vkDestroyCommandPool" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE}, + "vkDestroyCommandPool" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.PRIVATE}, "vkDestroyDevice" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.PRIVATE}, "vkFreeCommandBuffers" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.NONE}, "vkGetDeviceProcAddr" : {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.NONE}, diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 558b09c310a..652beb7b4e0 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -63,8 +63,8 @@ static const struct vulkan_funcs *vk_funcs;
#define WINE_VK_ADD_DISPATCHABLE_MAPPING(instance, client_handle, native_handle, object) \ wine_vk_add_handle_mapping((instance), (uintptr_t)(client_handle), (uintptr_t)(native_handle), &(object)->mapping) -#define WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, native_handle) \ - wine_vk_add_handle_mapping((instance), (uint64_t) (uintptr_t) (object), (uint64_t) (native_handle), &(object)->mapping) +#define WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, client_handle, native_handle, object) \ + wine_vk_add_handle_mapping((instance), (uintptr_t)(client_handle), (native_handle), &(object)->mapping) static void wine_vk_add_handle_mapping(struct wine_instance *instance, uint64_t wrapped_handle, uint64_t native_handle, struct wine_vk_mapping *mapping) { @@ -1148,6 +1148,7 @@ NTSTATUS wine_vkCreateCommandPool(void *args) const VkCommandPoolCreateInfo *info = params->pCreateInfo; const VkAllocationCallbacks *allocator = params->pAllocator; VkCommandPool *command_pool = params->pCommandPool; + struct vk_command_pool *handle = params->client_ptr; struct wine_cmd_pool *object; VkResult res;
@@ -1165,8 +1166,11 @@ NTSTATUS wine_vkCreateCommandPool(void *args)
if (res == VK_SUCCESS) { - WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(device->phys_dev->instance, object, object->command_pool); - *command_pool = wine_cmd_pool_to_handle(object); + object->handle = (uintptr_t)handle; + handle->unix_handle = (uintptr_t)object; + WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(device->phys_dev->instance, object->handle, + object->command_pool, object); + *command_pool = object->handle; } else { @@ -1575,7 +1579,7 @@ NTSTATUS wine_vkCreateWin32SurfaceKHR(void *args)
object->surface = vk_funcs->p_wine_get_native_surface(object->driver_surface);
- WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->surface); + WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->surface, object);
*surface = wine_surface_to_handle(object);
@@ -1689,7 +1693,7 @@ NTSTATUS wine_vkCreateDebugUtilsMessengerEXT(void *args) return res; }
- WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->debug_messenger); + WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->debug_messenger, object); *messenger = wine_debug_utils_messenger_to_handle(object);
return VK_SUCCESS; @@ -1753,7 +1757,7 @@ NTSTATUS wine_vkCreateDebugReportCallbackEXT(void *args) return res; }
- WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->debug_callback); + WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(instance, object, object->debug_callback, object); *callback = wine_debug_report_callback_to_handle(object);
return VK_SUCCESS; diff --git a/dlls/winevulkan/vulkan_loader.h b/dlls/winevulkan/vulkan_loader.h index bf99cf57694..fdf6d3d1699 100644 --- a/dlls/winevulkan/vulkan_loader.h +++ b/dlls/winevulkan/vulkan_loader.h @@ -78,6 +78,16 @@ struct VkDevice_T struct VkQueue_T queues[1]; };
+struct vk_command_pool +{ + UINT64 unix_handle; +}; + +static inline struct vk_command_pool *command_pool_from_handle(VkCommandPool handle) +{ + return (struct vk_command_pool *)(uintptr_t)handle; +} + struct vulkan_func { const char *name; diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 99907252e2d..5f7642d5f6d 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -157,6 +157,7 @@ static inline struct wine_queue *wine_queue_from_handle(VkQueue handle)
struct wine_cmd_pool { + VkCommandPool handle; VkCommandPool command_pool;
struct list command_buffers; @@ -166,12 +167,8 @@ struct wine_cmd_pool
static inline struct wine_cmd_pool *wine_cmd_pool_from_handle(VkCommandPool handle) { - return (struct wine_cmd_pool *)(uintptr_t)handle; -} - -static inline VkCommandPool wine_cmd_pool_to_handle(struct wine_cmd_pool *cmd_pool) -{ - return (VkCommandPool)(uintptr_t)cmd_pool; + struct vk_command_pool *client_ptr = command_pool_from_handle(handle); + return (struct wine_cmd_pool *)(uintptr_t)client_ptr->unix_handle; }
struct wine_debug_utils_messenger