Commit 19326ff9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Wrap VkCommandPool on PE side.

parent ab747c6e
......@@ -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, &params);
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, &params);
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,
......
......@@ -1999,16 +1999,6 @@ VkResult WINAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo
return vk_unix_call(unix_vkCreateBufferView, &params);
}
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, &params);
}
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, &params);
}
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, &params);
}
void WINAPI vkDestroyCuFunctionNVX(VkDevice device, VkCuFunctionNVX function, const VkAllocationCallbacks *pAllocator)
{
struct vkDestroyCuFunctionNVX_params params;
......
......@@ -2066,6 +2066,7 @@ struct vkCreateCommandPool_params
const VkCommandPoolCreateInfo *pCreateInfo;
const VkAllocationCallbacks *pAllocator;
VkCommandPool *pCommandPool;
void *client_ptr;
};
struct vkCreateComputePipelines_params
......
......@@ -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},
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
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