widl: Properly align name table entries.
[wine.git] / dlls / winevulkan / vulkan_private.h
blobf5109aa637779f762e247acd71d584e920339b16
1 /* Wine Vulkan ICD private data structures
3 * Copyright 2017 Roderick Colenbrander
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __WINE_VULKAN_PRIVATE_H
21 #define __WINE_VULKAN_PRIVATE_H
23 #define WINE_VK_HOST
24 #define VK_NO_PROTOTYPES
26 #include <pthread.h>
28 #include "vulkan_loader.h"
29 #include "vulkan_thunks.h"
30 #include "wine/rbtree.h"
32 #include "wine/rbtree.h"
34 /* Some extensions have callbacks for those we need to be able to
35 * get the wine wrapper for a host handle
37 struct wrapper_entry
39 struct rb_entry entry;
40 uint64_t host_handle;
41 uint64_t client_handle;
44 struct wine_cmd_buffer
46 struct wine_device *device; /* parent */
48 VkCommandBuffer handle; /* client command buffer */
49 VkCommandBuffer host_command_buffer;
51 struct wrapper_entry wrapper_entry;
54 static inline struct wine_cmd_buffer *wine_cmd_buffer_from_handle(VkCommandBuffer handle)
56 return (struct wine_cmd_buffer *)(uintptr_t)handle->base.unix_handle;
59 struct wine_queue
61 struct wine_device *device; /* parent */
63 VkQueue handle; /* client queue */
64 VkQueue host_queue;
66 uint32_t family_index;
67 uint32_t queue_index;
68 VkDeviceQueueCreateFlags flags;
70 struct wrapper_entry wrapper_entry;
73 static inline struct wine_queue *wine_queue_from_handle(VkQueue handle)
75 return (struct wine_queue *)(uintptr_t)handle->base.unix_handle;
78 struct wine_device
80 struct vulkan_device_funcs funcs;
81 struct wine_phys_dev *phys_dev; /* parent */
83 VkDevice handle; /* client device */
84 VkDevice host_device;
86 struct wrapper_entry wrapper_entry;
88 uint32_t queue_count;
89 struct wine_queue queues[];
92 C_ASSERT(sizeof(struct wine_device) == offsetof(struct wine_device, queues[0]));
94 static inline struct wine_device *wine_device_from_handle(VkDevice handle)
96 return (struct wine_device *)(uintptr_t)handle->base.unix_handle;
99 struct wine_debug_utils_messenger;
101 struct wine_debug_report_callback
103 struct wine_instance *instance; /* parent */
104 VkDebugReportCallbackEXT host_debug_callback;
106 /* application callback + data */
107 PFN_vkDebugReportCallbackEXT user_callback;
108 void *user_data;
110 struct wrapper_entry wrapper_entry;
113 struct wine_phys_dev
115 struct wine_instance *instance; /* parent */
117 VkPhysicalDevice handle; /* client physical device */
118 VkPhysicalDevice host_physical_device;
120 VkPhysicalDeviceMemoryProperties memory_properties;
121 VkExtensionProperties *extensions;
122 uint32_t extension_count;
124 uint32_t external_memory_align;
125 uint32_t map_placed_align;
127 struct wrapper_entry wrapper_entry;
130 static inline struct wine_phys_dev *wine_phys_dev_from_handle(VkPhysicalDevice handle)
132 return (struct wine_phys_dev *)(uintptr_t)handle->base.unix_handle;
135 struct wine_debug_report_callback;
137 struct wine_instance
139 struct vulkan_instance_funcs funcs;
141 VkInstance handle; /* client instance */
142 VkInstance host_instance;
144 VkBool32 enable_win32_surface;
145 VkBool32 enable_wrapper_list;
146 struct rb_tree wrappers;
147 pthread_rwlock_t wrapper_lock;
149 struct wine_debug_utils_messenger *utils_messengers;
150 uint32_t utils_messenger_count;
152 struct wine_debug_report_callback default_callback;
154 unsigned int quirks;
156 struct wrapper_entry wrapper_entry;
158 /* We cache devices as we need to wrap them as they are dispatchable objects. */
159 uint32_t phys_dev_count;
160 struct wine_phys_dev phys_devs[];
163 C_ASSERT(sizeof(struct wine_instance) == offsetof(struct wine_instance, phys_devs[0]));
165 static inline struct wine_instance *wine_instance_from_handle(VkInstance handle)
167 return (struct wine_instance *)(uintptr_t)handle->base.unix_handle;
170 struct wine_cmd_pool
172 VkCommandPool handle;
173 VkCommandPool host_command_pool;
175 struct wrapper_entry wrapper_entry;
178 static inline struct wine_cmd_pool *wine_cmd_pool_from_handle(VkCommandPool handle)
180 struct vk_command_pool *client_ptr = command_pool_from_handle(handle);
181 return (struct wine_cmd_pool *)(uintptr_t)client_ptr->unix_handle;
184 struct wine_device_memory
186 VkDeviceMemory host_memory;
187 VkDeviceSize size;
188 void *vm_map;
190 struct wrapper_entry wrapper_entry;
193 static inline struct wine_device_memory *wine_device_memory_from_handle(VkDeviceMemory handle)
195 return (struct wine_device_memory *)(uintptr_t)handle;
198 struct wine_debug_utils_messenger
200 struct wine_instance *instance; /* parent */
201 VkDebugUtilsMessengerEXT host_debug_messenger;
203 /* application callback + data */
204 PFN_vkDebugUtilsMessengerCallbackEXT user_callback;
205 void *user_data;
207 struct wrapper_entry wrapper_entry;
210 static inline struct wine_debug_utils_messenger *wine_debug_utils_messenger_from_handle(
211 VkDebugUtilsMessengerEXT handle)
213 return (struct wine_debug_utils_messenger *)(uintptr_t)handle;
216 static inline VkDebugUtilsMessengerEXT wine_debug_utils_messenger_to_handle(
217 struct wine_debug_utils_messenger *debug_messenger)
219 return (VkDebugUtilsMessengerEXT)(uintptr_t)debug_messenger;
222 static inline struct wine_debug_report_callback *wine_debug_report_callback_from_handle(
223 VkDebugReportCallbackEXT handle)
225 return (struct wine_debug_report_callback *)(uintptr_t)handle;
228 static inline VkDebugReportCallbackEXT wine_debug_report_callback_to_handle(
229 struct wine_debug_report_callback *debug_messenger)
231 return (VkDebugReportCallbackEXT)(uintptr_t)debug_messenger;
234 struct wine_surface
236 VkSurfaceKHR host_surface;
237 VkSurfaceKHR driver_surface;
238 HWND hwnd;
240 struct rb_entry window_entry;
241 struct wrapper_entry wrapper_entry;
244 static inline struct wine_surface *wine_surface_from_handle(VkSurfaceKHR handle)
246 return (struct wine_surface *)(uintptr_t)handle;
249 static inline VkSurfaceKHR wine_surface_to_handle(struct wine_surface *surface)
251 return (VkSurfaceKHR)(uintptr_t)surface;
254 struct wine_swapchain
256 VkSwapchainKHR host_swapchain;
258 struct wrapper_entry wrapper_entry;
261 static inline struct wine_swapchain *wine_swapchain_from_handle(VkSwapchainKHR handle)
263 return (struct wine_swapchain *)(uintptr_t)handle;
266 static inline VkSwapchainKHR wine_swapchain_to_handle(struct wine_swapchain *surface)
268 return (VkSwapchainKHR)(uintptr_t)surface;
271 BOOL wine_vk_device_extension_supported(const char *name);
272 BOOL wine_vk_instance_extension_supported(const char *name);
273 BOOL wine_vk_is_host_surface_extension(const char *name);
275 BOOL wine_vk_is_type_wrapped(VkObjectType type);
277 NTSTATUS init_vulkan(void *args);
279 NTSTATUS vk_is_available_instance_function(void *arg);
280 NTSTATUS vk_is_available_device_function(void *arg);
281 NTSTATUS vk_is_available_instance_function32(void *arg);
282 NTSTATUS vk_is_available_device_function32(void *arg);
284 struct conversion_context
286 char buffer[2048];
287 uint32_t used;
288 struct list alloc_entries;
291 static inline void init_conversion_context(struct conversion_context *pool)
293 pool->used = 0;
294 list_init(&pool->alloc_entries);
297 static inline void free_conversion_context(struct conversion_context *pool)
299 struct list *entry, *next;
300 LIST_FOR_EACH_SAFE(entry, next, &pool->alloc_entries)
301 free(entry);
304 static inline void *conversion_context_alloc(struct conversion_context *pool, size_t size)
306 if (pool->used + size <= sizeof(pool->buffer))
308 void *ret = pool->buffer + pool->used;
309 pool->used += (size + sizeof(UINT64) - 1) & ~(sizeof(UINT64) - 1);
310 return ret;
312 else
314 struct list *entry;
315 if (!(entry = malloc(sizeof(*entry) + size)))
316 return NULL;
317 list_add_tail(&pool->alloc_entries, entry);
318 return entry + 1;
322 struct wine_deferred_operation
324 VkDeferredOperationKHR host_deferred_operation;
325 struct conversion_context ctx; /* to keep params alive. */
326 struct wrapper_entry wrapper_entry;
329 static inline struct wine_deferred_operation *wine_deferred_operation_from_handle(
330 VkDeferredOperationKHR handle)
332 return (struct wine_deferred_operation *)(uintptr_t)handle;
335 static inline VkDeferredOperationKHR wine_deferred_operation_to_handle(
336 struct wine_deferred_operation *deferred_operation)
338 return (VkDeferredOperationKHR)(uintptr_t)deferred_operation;
341 typedef UINT32 PTR32;
343 typedef struct
345 VkStructureType sType;
346 PTR32 pNext;
347 } VkBaseInStructure32;
349 typedef struct
351 VkStructureType sType;
352 PTR32 pNext;
353 } VkBaseOutStructure32;
355 static inline void *find_next_struct32(void *s, VkStructureType t)
357 VkBaseOutStructure32 *header;
359 for (header = s; header; header = UlongToPtr(header->pNext))
361 if (header->sType == t)
362 return header;
365 return NULL;
368 static inline void *find_next_struct(const void *s, VkStructureType t)
370 VkBaseOutStructure *header;
372 for (header = (VkBaseOutStructure *)s; header; header = header->pNext)
374 if (header->sType == t)
375 return header;
378 return NULL;
381 #endif /* __WINE_VULKAN_PRIVATE_H */