From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/vulkan.c | 30 +++++++++++++++--------------- dlls/winevulkan/vulkan_private.h | 5 ----- include/wine/vulkan_driver.h | 5 +++++ 3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index ac93931092b..c0d341d6d53 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -341,7 +341,7 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy vulkan_object_init_ptr(&object->obj.obj, (UINT_PTR)host_physical_device, &client_physical_device->obj); object->obj.instance = instance;
- instance->p_vkGetPhysicalDeviceMemoryProperties(host_physical_device, &object->memory_properties); + instance->p_vkGetPhysicalDeviceMemoryProperties(host_physical_device, &object->obj.memory_properties);
res = instance->p_vkEnumerateDeviceExtensionProperties(host_physical_device, NULL, &num_host_properties, NULL); @@ -434,12 +434,12 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy };
instance->p_vkGetPhysicalDeviceProperties2(host_physical_device, &props); - object->map_placed_align = map_placed_props.minPlacedMemoryMapAlignment; - TRACE( "Using placed map with alignment %u\n", object->map_placed_align ); + object->obj.map_placed_align = map_placed_props.minPlacedMemoryMapAlignment; + TRACE( "Using placed map with alignment %u\n", object->obj.map_placed_align ); } }
- if (zero_bits && have_external_memory_host && !object->map_placed_align) + if (zero_bits && have_external_memory_host && !object->obj.map_placed_align) { VkPhysicalDeviceExternalMemoryHostPropertiesEXT host_mem_props = { @@ -451,10 +451,10 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy .pNext = &host_mem_props, }; instance->p_vkGetPhysicalDeviceProperties2KHR(host_physical_device, &props); - object->external_memory_align = host_mem_props.minImportedHostPointerAlignment; - if (object->external_memory_align) + object->obj.external_memory_align = host_mem_props.minImportedHostPointerAlignment; + if (object->obj.external_memory_align) TRACE("Using VK_EXT_external_memory_host for memory mapping with alignment: %u\n", - object->external_memory_align); + object->obj.external_memory_align); }
free(host_properties); @@ -568,7 +568,7 @@ static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physi } }
- if (phys_dev->map_placed_align) + if (phys_dev->obj.map_placed_align) { VkPhysicalDeviceMapMemoryPlacedFeaturesEXT *map_placed_features; map_placed_features = conversion_context_alloc(ctx, sizeof(*map_placed_features)); @@ -584,7 +584,7 @@ static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physi if (!find_extension(extensions, extensions_count, "VK_KHR_map_memory2")) extra_extensions[extra_count++] = "VK_KHR_map_memory2"; } - else if (phys_dev->external_memory_align) + else if (phys_dev->obj.external_memory_align) { if (!find_extension(extensions, extensions_count, "VK_KHR_external_memory")) extra_extensions[extra_count++] = "VK_KHR_external_memory"; @@ -1652,7 +1652,7 @@ VkResult wine_vkAllocateMemory(VkDevice client_device, const VkMemoryAllocateInf const VkAllocationCallbacks *allocator, VkDeviceMemory *ret) { struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct wine_phys_dev *physical_device = CONTAINING_RECORD(device->physical_device, struct wine_phys_dev, obj); + struct vulkan_physical_device *physical_device = device->physical_device; struct vulkan_instance *instance = device->physical_device->instance; struct wine_device_memory *memory; VkMemoryAllocateInfo info = *alloc_info; @@ -1752,7 +1752,7 @@ VkResult wine_vkAllocateMemory(VkDevice client_device, const VkMemoryAllocateInf void wine_vkFreeMemory(VkDevice client_device, VkDeviceMemory memory_handle, const VkAllocationCallbacks *allocator) { struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct wine_phys_dev *physical_device = CONTAINING_RECORD(device->physical_device, struct wine_phys_dev, obj); + struct vulkan_physical_device *physical_device = device->physical_device; struct vulkan_instance *instance = device->physical_device->instance; struct wine_device_memory *memory;
@@ -1801,7 +1801,7 @@ VkResult wine_vkMapMemory(VkDevice client_device, VkDeviceMemory memory, VkDevic VkResult wine_vkMapMemory2KHR(VkDevice client_device, const VkMemoryMapInfoKHR *map_info, void **data) { struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct wine_phys_dev *physical_device = CONTAINING_RECORD(device->physical_device, struct wine_phys_dev, obj); + struct vulkan_physical_device *physical_device = device->physical_device; struct wine_device_memory *memory = wine_device_memory_from_handle(map_info->memory); VkMemoryMapInfoKHR info = *map_info; VkMemoryMapPlacedInfoEXT placed_info = @@ -1888,7 +1888,7 @@ void wine_vkUnmapMemory(VkDevice client_device, VkDeviceMemory memory) VkResult wine_vkUnmapMemory2KHR(VkDevice client_device, const VkMemoryUnmapInfoKHR *unmap_info) { struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct wine_phys_dev *physical_device = CONTAINING_RECORD(device->physical_device, struct wine_phys_dev, obj); + struct vulkan_physical_device *physical_device = device->physical_device; struct wine_device_memory *memory = wine_device_memory_from_handle(unmap_info->memory); VkMemoryUnmapInfoKHR info; VkResult result; @@ -1923,7 +1923,7 @@ VkResult wine_vkCreateBuffer(VkDevice client_device, const VkBufferCreateInfo *c const VkAllocationCallbacks *allocator, VkBuffer *buffer) { struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct wine_phys_dev *physical_device = CONTAINING_RECORD(device->physical_device, struct wine_phys_dev, obj); + struct vulkan_physical_device *physical_device = device->physical_device; VkExternalMemoryBufferCreateInfo external_memory_info; VkBufferCreateInfo info = *create_info;
@@ -1943,7 +1943,7 @@ VkResult wine_vkCreateImage(VkDevice client_device, const VkImageCreateInfo *cre const VkAllocationCallbacks *allocator, VkImage *image) { struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct wine_phys_dev *physical_device = CONTAINING_RECORD(device->physical_device, struct wine_phys_dev, obj); + struct vulkan_physical_device *physical_device = device->physical_device; VkExternalMemoryImageCreateInfo external_memory_info; VkImageCreateInfo info = *create_info;
diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 59b900930b3..83ca0d72a46 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -73,13 +73,8 @@ struct wine_debug_report_callback struct wine_phys_dev { struct vulkan_physical_device obj; - - VkPhysicalDeviceMemoryProperties memory_properties; VkExtensionProperties *extensions; uint32_t extension_count; - - uint32_t external_memory_align; - uint32_t map_placed_align; };
struct wine_debug_report_callback; diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index 3788ff02dc6..c4f8bad5a90 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -92,6 +92,11 @@ struct vulkan_physical_device VULKAN_OBJECT_HEADER( VkPhysicalDevice, physical_device ); struct vulkan_instance *instance; bool has_swapchain_maintenance1; + + /* for WOW64 memory mapping with VK_EXT_external_memory_host */ + VkPhysicalDeviceMemoryProperties memory_properties; + uint32_t external_memory_align; + uint32_t map_placed_align; };
static inline struct vulkan_physical_device *vulkan_physical_device_from_handle( VkPhysicalDevice handle )
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/vulkan.c | 16 ++++++++-------- dlls/winevulkan/vulkan_private.h | 2 -- include/wine/vulkan_driver.h | 3 +++ 3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index c0d341d6d53..e4381fe2708 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -325,7 +325,7 @@ static VkBool32 debug_report_callback_conversion(VkDebugReportFlagsEXT flags, Vk
static void wine_phys_dev_cleanup(struct wine_phys_dev *phys_dev) { - free(phys_dev->extensions); + free(phys_dev->obj.extensions); }
static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhysicalDevice host_physical_device, @@ -392,7 +392,7 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy
TRACE("Host supported extensions %u, Wine supported extensions %u\n", num_host_properties, num_properties);
- if (!(object->extensions = calloc(num_properties, sizeof(*object->extensions)))) + if (!(object->obj.extensions = calloc(num_properties, sizeof(*object->obj.extensions)))) { ERR("Failed to allocate memory for device extensions!\n"); goto err; @@ -402,11 +402,11 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy { if (wine_vk_device_extension_supported(host_properties[i].extensionName)) { - object->extensions[j] = host_properties[i]; + object->obj.extensions[j] = host_properties[i]; j++; } } - object->extension_count = num_properties; + object->obj.extension_count = num_properties;
if (zero_bits && have_memory_placed && have_map_memory2) { @@ -1082,15 +1082,15 @@ VkResult wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice client_physi
if (!properties) { - *count = phys_dev->extension_count; + *count = phys_dev->obj.extension_count; return VK_SUCCESS; }
- *count = min(*count, phys_dev->extension_count); - memcpy(properties, phys_dev->extensions, *count * sizeof(*properties)); + *count = min(*count, phys_dev->obj.extension_count); + memcpy(properties, phys_dev->obj.extensions, *count * sizeof(*properties));
TRACE("Returning %u extensions.\n", *count); - return *count < phys_dev->extension_count ? VK_INCOMPLETE : VK_SUCCESS; + return *count < phys_dev->obj.extension_count ? VK_INCOMPLETE : VK_SUCCESS; }
VkResult wine_vkEnumerateInstanceExtensionProperties(const char *name, uint32_t *count, diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 83ca0d72a46..18728fdc9ec 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -73,8 +73,6 @@ struct wine_debug_report_callback struct wine_phys_dev { struct vulkan_physical_device obj; - VkExtensionProperties *extensions; - uint32_t extension_count; };
struct wine_debug_report_callback; diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index c4f8bad5a90..fbe31f28a68 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -93,6 +93,9 @@ struct vulkan_physical_device struct vulkan_instance *instance; bool has_swapchain_maintenance1;
+ VkExtensionProperties *extensions; + uint32_t extension_count; + /* for WOW64 memory mapping with VK_EXT_external_memory_host */ VkPhysicalDeviceMemoryProperties memory_properties; uint32_t external_memory_align;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/vulkan.c | 112 +++++++++++++++---------------- dlls/winevulkan/vulkan_private.h | 11 +-- 2 files changed, 56 insertions(+), 67 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index e4381fe2708..957f57adea3 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -42,12 +42,6 @@ static struct wine_instance *wine_instance_from_handle(VkInstance handle) return CONTAINING_RECORD(object, struct wine_instance, obj); }
-static struct wine_phys_dev *wine_phys_dev_from_handle(VkPhysicalDevice handle) -{ - struct vulkan_physical_device *object = vulkan_physical_device_from_handle(handle); - return CONTAINING_RECORD(object, struct wine_phys_dev, obj); -} - static struct wine_device *wine_device_from_handle(VkDevice handle) { struct vulkan_device *object = vulkan_device_from_handle(handle); @@ -323,13 +317,14 @@ static VkBool32 debug_report_callback_conversion(VkDebugReportFlagsEXT flags, Vk return VK_FALSE; }
-static void wine_phys_dev_cleanup(struct wine_phys_dev *phys_dev) +static void vulkan_physical_device_cleanup(struct vulkan_physical_device *physical_device) { - free(phys_dev->obj.extensions); + free(physical_device->extensions); }
-static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhysicalDevice host_physical_device, - VkPhysicalDevice client_physical_device, struct vulkan_instance *instance) +static VkResult vulkan_physical_device_init(struct vulkan_physical_device *physical_device, + VkPhysicalDevice host_physical_device, VkPhysicalDevice client_physical_device, + struct vulkan_instance *instance) { BOOL have_memory_placed = FALSE, have_map_memory2 = FALSE; uint32_t num_host_properties, num_properties = 0; @@ -338,10 +333,10 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy VkResult res; unsigned int i, j;
- vulkan_object_init_ptr(&object->obj.obj, (UINT_PTR)host_physical_device, &client_physical_device->obj); - object->obj.instance = instance; + vulkan_object_init_ptr(&physical_device->obj, (UINT_PTR)host_physical_device, &client_physical_device->obj); + physical_device->instance = instance;
- instance->p_vkGetPhysicalDeviceMemoryProperties(host_physical_device, &object->obj.memory_properties); + instance->p_vkGetPhysicalDeviceMemoryProperties(host_physical_device, &physical_device->memory_properties);
res = instance->p_vkEnumerateDeviceExtensionProperties(host_physical_device, NULL, &num_host_properties, NULL); @@ -373,7 +368,7 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy { if (wine_vk_device_extension_supported(host_properties[i].extensionName)) { - TRACE("Enabling extension '%s' for physical device %p\n", host_properties[i].extensionName, object); + TRACE("Enabling extension '%s' for physical device %p\n", host_properties[i].extensionName, physical_device); num_properties++; } else @@ -385,14 +380,14 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy else if (!strcmp(host_properties[i].extensionName, "VK_EXT_map_memory_placed")) have_memory_placed = TRUE; else if (!strcmp(host_properties[i].extensionName, "VK_EXT_swapchain_maintenance1")) - object->obj.has_swapchain_maintenance1 = true; + physical_device->has_swapchain_maintenance1 = true; else if (!strcmp(host_properties[i].extensionName, "VK_KHR_map_memory2")) have_map_memory2 = TRUE; }
TRACE("Host supported extensions %u, Wine supported extensions %u\n", num_host_properties, num_properties);
- if (!(object->obj.extensions = calloc(num_properties, sizeof(*object->obj.extensions)))) + if (!(physical_device->extensions = calloc(num_properties, sizeof(*physical_device->extensions)))) { ERR("Failed to allocate memory for device extensions!\n"); goto err; @@ -402,11 +397,11 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy { if (wine_vk_device_extension_supported(host_properties[i].extensionName)) { - object->obj.extensions[j] = host_properties[i]; + physical_device->extensions[j] = host_properties[i]; j++; } } - object->obj.extension_count = num_properties; + physical_device->extension_count = num_properties;
if (zero_bits && have_memory_placed && have_map_memory2) { @@ -434,12 +429,12 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy };
instance->p_vkGetPhysicalDeviceProperties2(host_physical_device, &props); - object->obj.map_placed_align = map_placed_props.minPlacedMemoryMapAlignment; - TRACE( "Using placed map with alignment %u\n", object->obj.map_placed_align ); + physical_device->map_placed_align = map_placed_props.minPlacedMemoryMapAlignment; + TRACE( "Using placed map with alignment %u\n", physical_device->map_placed_align ); } }
- if (zero_bits && have_external_memory_host && !object->obj.map_placed_align) + if (zero_bits && have_external_memory_host && !physical_device->map_placed_align) { VkPhysicalDeviceExternalMemoryHostPropertiesEXT host_mem_props = { @@ -451,17 +446,17 @@ static VkResult wine_vk_physical_device_init(struct wine_phys_dev *object, VkPhy .pNext = &host_mem_props, }; instance->p_vkGetPhysicalDeviceProperties2KHR(host_physical_device, &props); - object->obj.external_memory_align = host_mem_props.minImportedHostPointerAlignment; - if (object->obj.external_memory_align) + physical_device->external_memory_align = host_mem_props.minImportedHostPointerAlignment; + if (physical_device->external_memory_align) TRACE("Using VK_EXT_external_memory_host for memory mapping with alignment: %u\n", - object->obj.external_memory_align); + physical_device->external_memory_align); }
free(host_properties); return VK_SUCCESS;
err: - wine_phys_dev_cleanup(object); + vulkan_physical_device_cleanup(physical_device); free(host_properties); return res; } @@ -546,7 +541,7 @@ static const char *find_extension(const char *const *extensions, uint32_t count, static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physical_device, struct conversion_context *ctx, const VkDeviceCreateInfo *src, VkDeviceCreateInfo *dst) { - struct wine_phys_dev *phys_dev = wine_phys_dev_from_handle(client_physical_device); + struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle(client_physical_device); const char *extra_extensions[3], * const*extensions = src->ppEnabledExtensionNames; unsigned int i, extra_count = 0, extensions_count = src->enabledExtensionCount;
@@ -568,7 +563,7 @@ static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physi } }
- if (phys_dev->obj.map_placed_align) + if (physical_device->map_placed_align) { VkPhysicalDeviceMapMemoryPlacedFeaturesEXT *map_placed_features; map_placed_features = conversion_context_alloc(ctx, sizeof(*map_placed_features)); @@ -584,7 +579,7 @@ static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physi if (!find_extension(extensions, extensions_count, "VK_KHR_map_memory2")) extra_extensions[extra_count++] = "VK_KHR_map_memory2"; } - else if (phys_dev->obj.external_memory_align) + else if (physical_device->external_memory_align) { if (!find_extension(extensions, extensions_count, "VK_KHR_external_memory")) extra_extensions[extra_count++] = "VK_KHR_external_memory"; @@ -593,7 +588,7 @@ static VkResult wine_vk_device_convert_create_info(VkPhysicalDevice client_physi }
/* win32u uses VkSwapchainPresentScalingCreateInfoEXT if available. */ - if (phys_dev->obj.has_swapchain_maintenance1) + if (physical_device->has_swapchain_maintenance1) { if (!find_extension(extensions, extensions_count, "VK_EXT_swapchain_maintenance1")) extra_extensions[extra_count++] = "VK_EXT_swapchain_maintenance1"; @@ -741,7 +736,7 @@ static VkResult wine_vk_instance_convert_create_info(struct conversion_context * static VkResult wine_vk_instance_init_physical_devices(struct wine_instance *object) { struct vulkan_instance *instance = &object->obj; - struct wine_phys_dev *physical_devices = object->phys_devs; + struct vulkan_physical_device *physical_devices = object->physical_devices; VkInstance client_instance = instance->client.instance; VkPhysicalDevice *host_physical_devices; uint32_t phys_dev_count; @@ -777,33 +772,33 @@ static VkResult wine_vk_instance_init_physical_devices(struct wine_instance *obj /* Wrap each host physical device handle into a dispatchable object for the ICD loader. */ for (i = 0; i < phys_dev_count; i++) { - struct wine_phys_dev *phys_dev = physical_devices + i; - res = wine_vk_physical_device_init(phys_dev, host_physical_devices[i], &client_instance->phys_devs[i], instance); + struct vulkan_physical_device *physical_device = physical_devices + i; + res = vulkan_physical_device_init(physical_device, host_physical_devices[i], &client_instance->phys_devs[i], instance); if (res != VK_SUCCESS) goto err; } - object->phys_dev_count = phys_dev_count; + object->physical_device_count = phys_dev_count;
free(host_physical_devices); return VK_SUCCESS;
err: - while (i) wine_phys_dev_cleanup(&physical_devices[--i]); + while (i) vulkan_physical_device_cleanup(&physical_devices[--i]); free(host_physical_devices); return res; }
-static struct wine_phys_dev *wine_vk_instance_wrap_physical_device(struct wine_instance *instance, +static struct vulkan_physical_device *wine_vk_instance_wrap_physical_device(struct wine_instance *instance, VkPhysicalDevice host_physical_device) { - struct wine_phys_dev *physical_devices = instance->phys_devs; - uint32_t physical_device_count = instance->phys_dev_count; + struct vulkan_physical_device *physical_devices = instance->physical_devices; + uint32_t physical_device_count = instance->physical_device_count; unsigned int i;
for (i = 0; i < physical_device_count; ++i) { - struct wine_phys_dev *current = physical_devices + i; - if (current->obj.host.physical_device == host_physical_device) return current; + struct vulkan_physical_device *current = physical_devices + i; + if (current->host.physical_device == host_physical_device) return current; }
ERR("Unrecognized physical device %p.\n", host_physical_device); @@ -954,7 +949,7 @@ VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, if (allocator) FIXME("Support for allocation callbacks not implemented yet\n");
- if (!(instance = calloc(1, offsetof(struct wine_instance, phys_devs[client_instance->phys_dev_count])))) + if (!(instance = calloc(1, offsetof(struct wine_instance, physical_devices[client_instance->phys_dev_count])))) { ERR("Failed to allocate memory for instance\n"); return VK_ERROR_OUT_OF_HOST_MEMORY; @@ -1015,10 +1010,10 @@ VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *create_info,
TRACE("Created instance %p, host_instance %p.\n", instance, instance->obj.host.instance);
- for (i = 0; i < instance->phys_dev_count; i++) + for (i = 0; i < instance->physical_device_count; i++) { - struct wine_phys_dev *phys_dev = &instance->phys_devs[i]; - vulkan_instance_insert_object(&instance->obj, &phys_dev->obj.obj); + struct vulkan_physical_device *physical_device = &instance->physical_devices[i]; + vulkan_instance_insert_object(&instance->obj, &physical_device->obj); } vulkan_instance_insert_object(&instance->obj, &instance->obj.obj);
@@ -1056,10 +1051,10 @@ void wine_vkDestroyInstance(VkInstance client_instance, const VkAllocationCallba return;
instance->obj.p_vkDestroyInstance(instance->obj.host.instance, NULL /* allocator */); - for (i = 0; i < instance->phys_dev_count; i++) + for (i = 0; i < instance->physical_device_count; i++) { - vulkan_instance_remove_object(&instance->obj, &instance->phys_devs[i].obj.obj); - wine_phys_dev_cleanup(&instance->phys_devs[i]); + vulkan_instance_remove_object(&instance->obj, &instance->physical_devices[i].obj); + vulkan_physical_device_cleanup(&instance->physical_devices[i]); } vulkan_instance_remove_object(&instance->obj, &instance->obj.obj);
@@ -1071,7 +1066,7 @@ void wine_vkDestroyInstance(VkInstance client_instance, const VkAllocationCallba VkResult wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice client_physical_device, const char *layer_name, uint32_t *count, VkExtensionProperties *properties) { - struct wine_phys_dev *phys_dev = wine_phys_dev_from_handle(client_physical_device); + struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle(client_physical_device);
/* This shouldn't get called with layer_name set, the ICD loader prevents it. */ if (layer_name) @@ -1082,15 +1077,15 @@ VkResult wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice client_physi
if (!properties) { - *count = phys_dev->obj.extension_count; + *count = physical_device->extension_count; return VK_SUCCESS; }
- *count = min(*count, phys_dev->obj.extension_count); - memcpy(properties, phys_dev->obj.extensions, *count * sizeof(*properties)); + *count = min(*count, physical_device->extension_count); + memcpy(properties, physical_device->extensions, *count * sizeof(*properties));
TRACE("Returning %u extensions.\n", *count); - return *count < phys_dev->obj.extension_count ? VK_INCOMPLETE : VK_SUCCESS; + return *count < physical_device->extension_count ? VK_INCOMPLETE : VK_SUCCESS; }
VkResult wine_vkEnumerateInstanceExtensionProperties(const char *name, uint32_t *count, @@ -1191,18 +1186,18 @@ VkResult wine_vkEnumeratePhysicalDevices(VkInstance client_instance, uint32_t *c
if (!client_physical_devices) { - *count = instance->phys_dev_count; + *count = instance->physical_device_count; return VK_SUCCESS; }
- *count = min(*count, instance->phys_dev_count); + *count = min(*count, instance->physical_device_count); for (i = 0; i < *count; i++) { - client_physical_devices[i] = instance->phys_devs[i].obj.client.physical_device; + client_physical_devices[i] = instance->physical_devices[i].client.physical_device; }
TRACE("Returning %u devices.\n", *count); - return *count < instance->phys_dev_count ? VK_INCOMPLETE : VK_SUCCESS; + return *count < instance->physical_device_count ? VK_INCOMPLETE : VK_SUCCESS; }
void wine_vkFreeCommandBuffers(VkDevice client_device, VkCommandPool command_pool, uint32_t count, @@ -1320,10 +1315,9 @@ static VkResult wine_vk_enumerate_physical_device_groups(struct wine_instance *i for (j = 0; j < current->physicalDeviceCount; ++j) { VkPhysicalDevice host_physical_device = current->physicalDevices[j]; - struct wine_phys_dev *phys_dev = wine_vk_instance_wrap_physical_device(instance, host_physical_device); - if (!phys_dev) - return VK_ERROR_INITIALIZATION_FAILED; - current->physicalDevices[j] = phys_dev->obj.client.physical_device; + struct vulkan_physical_device *physical_device = wine_vk_instance_wrap_physical_device(instance, host_physical_device); + if (!physical_device) return VK_ERROR_INITIALIZATION_FAILED; + current->physicalDevices[j] = physical_device->client.physical_device; } }
diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 18728fdc9ec..f7edb1680e4 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -70,11 +70,6 @@ struct wine_debug_report_callback UINT64 user_data; /* client pointer */ };
-struct wine_phys_dev -{ - struct vulkan_physical_device obj; -}; - struct wine_debug_report_callback;
struct wine_instance @@ -94,11 +89,11 @@ struct wine_instance pthread_rwlock_t objects_lock;
/* We cache devices as we need to wrap them as they are dispatchable objects. */ - uint32_t phys_dev_count; - struct wine_phys_dev phys_devs[]; + uint32_t physical_device_count; + struct vulkan_physical_device physical_devices[]; };
-C_ASSERT(sizeof(struct wine_instance) == offsetof(struct wine_instance, phys_devs[0])); +C_ASSERT(sizeof(struct wine_instance) == offsetof(struct wine_instance, physical_devices[0]));
struct wine_cmd_pool {
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winevulkan/vulkan.c | 42 +++++++++++++++++--------------- dlls/winevulkan/vulkan_private.h | 6 ----- include/wine/vulkan_driver.h | 3 +++ 3 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 957f57adea3..82cbaba5af8 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -733,10 +733,9 @@ static VkResult wine_vk_instance_convert_create_info(struct conversion_context * }
/* Helper function which stores wrapped physical devices in the instance object. */ -static VkResult wine_vk_instance_init_physical_devices(struct wine_instance *object) +static VkResult wine_vk_instance_init_physical_devices(struct vulkan_instance *instance, + struct vulkan_physical_device *physical_devices) { - struct vulkan_instance *instance = &object->obj; - struct vulkan_physical_device *physical_devices = object->physical_devices; VkInstance client_instance = instance->client.instance; VkPhysicalDevice *host_physical_devices; uint32_t phys_dev_count; @@ -777,7 +776,8 @@ static VkResult wine_vk_instance_init_physical_devices(struct wine_instance *obj if (res != VK_SUCCESS) goto err; } - object->physical_device_count = phys_dev_count; + instance->physical_device_count = phys_dev_count; + instance->physical_devices = physical_devices;
free(host_physical_devices); return VK_SUCCESS; @@ -788,7 +788,7 @@ err: return res; }
-static struct vulkan_physical_device *wine_vk_instance_wrap_physical_device(struct wine_instance *instance, +static struct vulkan_physical_device *vulkan_instance_get_physical_device(struct vulkan_instance *instance, VkPhysicalDevice host_physical_device) { struct vulkan_physical_device *physical_devices = instance->physical_devices; @@ -943,17 +943,19 @@ VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, struct conversion_context ctx; struct wine_instance *instance; VkInstance host_instance, client_instance = client_ptr; + struct vulkan_physical_device *physical_devices; unsigned int i; VkResult res;
if (allocator) FIXME("Support for allocation callbacks not implemented yet\n");
- if (!(instance = calloc(1, offsetof(struct wine_instance, physical_devices[client_instance->phys_dev_count])))) + if (!(instance = calloc(1, sizeof(*instance) + sizeof(*physical_devices) * client_instance->phys_dev_count))) { ERR("Failed to allocate memory for instance\n"); return VK_ERROR_OUT_OF_HOST_MEMORY; } + physical_devices = (struct vulkan_physical_device *)(instance + 1);
init_conversion_context(&ctx); res = wine_vk_instance_convert_create_info(&ctx, create_info, &create_info_host, instance); @@ -986,7 +988,7 @@ VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *create_info, * the host physical devices and present those to the application. * Cleanup happens as part of wine_vkDestroyInstance. */ - res = wine_vk_instance_init_physical_devices(instance); + res = wine_vk_instance_init_physical_devices(&instance->obj, physical_devices); if (res != VK_SUCCESS) { ERR("Failed to load physical devices, res=%d\n", res); @@ -1010,9 +1012,9 @@ VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *create_info,
TRACE("Created instance %p, host_instance %p.\n", instance, instance->obj.host.instance);
- for (i = 0; i < instance->physical_device_count; i++) + for (i = 0; i < instance->obj.physical_device_count; i++) { - struct vulkan_physical_device *physical_device = &instance->physical_devices[i]; + struct vulkan_physical_device *physical_device = &instance->obj.physical_devices[i]; vulkan_instance_insert_object(&instance->obj, &physical_device->obj); } vulkan_instance_insert_object(&instance->obj, &instance->obj.obj); @@ -1051,10 +1053,10 @@ void wine_vkDestroyInstance(VkInstance client_instance, const VkAllocationCallba return;
instance->obj.p_vkDestroyInstance(instance->obj.host.instance, NULL /* allocator */); - for (i = 0; i < instance->physical_device_count; i++) + for (i = 0; i < instance->obj.physical_device_count; i++) { - vulkan_instance_remove_object(&instance->obj, &instance->physical_devices[i].obj); - vulkan_physical_device_cleanup(&instance->physical_devices[i]); + vulkan_instance_remove_object(&instance->obj, &instance->obj.physical_devices[i].obj); + vulkan_physical_device_cleanup(&instance->obj.physical_devices[i]); } vulkan_instance_remove_object(&instance->obj, &instance->obj.obj);
@@ -1181,7 +1183,7 @@ VkResult wine_vkEnumerateInstanceVersion(uint32_t *version)
VkResult wine_vkEnumeratePhysicalDevices(VkInstance client_instance, uint32_t *count, VkPhysicalDevice *client_physical_devices) { - struct wine_instance *instance = wine_instance_from_handle(client_instance); + struct vulkan_instance *instance = vulkan_instance_from_handle(client_instance); unsigned int i;
if (!client_physical_devices) @@ -1298,14 +1300,14 @@ void wine_vkDestroyCommandPool(VkDevice client_device, VkCommandPool handle, free(pool); }
-static VkResult wine_vk_enumerate_physical_device_groups(struct wine_instance *instance, +static VkResult wine_vk_enumerate_physical_device_groups(struct vulkan_instance *instance, VkResult (*p_vkEnumeratePhysicalDeviceGroups)(VkInstance, uint32_t *, VkPhysicalDeviceGroupProperties *), uint32_t *count, VkPhysicalDeviceGroupProperties *properties) { unsigned int i, j; VkResult res;
- res = p_vkEnumeratePhysicalDeviceGroups(instance->obj.host.instance, count, properties); + res = p_vkEnumeratePhysicalDeviceGroups(instance->host.instance, count, properties); if (res < 0 || !properties) return res;
@@ -1315,7 +1317,7 @@ static VkResult wine_vk_enumerate_physical_device_groups(struct wine_instance *i for (j = 0; j < current->physicalDeviceCount; ++j) { VkPhysicalDevice host_physical_device = current->physicalDevices[j]; - struct vulkan_physical_device *physical_device = wine_vk_instance_wrap_physical_device(instance, host_physical_device); + struct vulkan_physical_device *physical_device = vulkan_instance_get_physical_device(instance, host_physical_device); if (!physical_device) return VK_ERROR_INITIALIZATION_FAILED; current->physicalDevices[j] = physical_device->client.physical_device; } @@ -1327,19 +1329,19 @@ static VkResult wine_vk_enumerate_physical_device_groups(struct wine_instance *i VkResult wine_vkEnumeratePhysicalDeviceGroups(VkInstance client_instance, uint32_t *count, VkPhysicalDeviceGroupProperties *properties) { - struct wine_instance *instance = wine_instance_from_handle(client_instance); + struct vulkan_instance *instance = vulkan_instance_from_handle(client_instance);
return wine_vk_enumerate_physical_device_groups(instance, - instance->obj.p_vkEnumeratePhysicalDeviceGroups, count, properties); + instance->p_vkEnumeratePhysicalDeviceGroups, count, properties); }
VkResult wine_vkEnumeratePhysicalDeviceGroupsKHR(VkInstance client_instance, uint32_t *count, VkPhysicalDeviceGroupProperties *properties) { - struct wine_instance *instance = wine_instance_from_handle(client_instance); + struct vulkan_instance *instance = vulkan_instance_from_handle(client_instance);
return wine_vk_enumerate_physical_device_groups(instance, - instance->obj.p_vkEnumeratePhysicalDeviceGroupsKHR, count, properties); + instance->p_vkEnumeratePhysicalDeviceGroupsKHR, count, properties); }
void wine_vkGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice client_physical_device, diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index f7edb1680e4..d9ff386b469 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -87,14 +87,8 @@ struct wine_instance
struct rb_tree objects; pthread_rwlock_t objects_lock; - - /* We cache devices as we need to wrap them as they are dispatchable objects. */ - uint32_t physical_device_count; - struct vulkan_physical_device physical_devices[]; };
-C_ASSERT(sizeof(struct wine_instance) == offsetof(struct wine_instance, physical_devices[0])); - struct wine_cmd_pool { VULKAN_OBJECT_HEADER( VkCommandPool, command_pool ); diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index fbe31f28a68..b468046a949 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -79,6 +79,9 @@ struct vulkan_instance #undef USE_VK_FUNC void (*p_insert_object)( struct vulkan_instance *instance, struct vulkan_object *obj ); void (*p_remove_object)( struct vulkan_instance *instance, struct vulkan_object *obj ); + + struct vulkan_physical_device *physical_devices; + uint32_t physical_device_count; };
static inline struct vulkan_instance *vulkan_instance_from_handle( VkInstance handle )
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/vulkan.c | 338 ++++++++++++++++++++++++++++++- dlls/winevulkan/make_vulkan | 18 +- dlls/winevulkan/vulkan.c | 311 ---------------------------- dlls/winevulkan/vulkan_private.h | 12 -- dlls/winevulkan/vulkan_thunks.c | 106 +++++----- dlls/winevulkan/vulkan_thunks.h | 8 - include/wine/vulkan_driver.h | 18 ++ 7 files changed, 411 insertions(+), 400 deletions(-)
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 9cd5a533060..1c397db76c4 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -46,6 +46,19 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
static const struct vulkan_driver_funcs *driver_funcs;
+struct device_memory +{ + struct vulkan_device_memory obj; + VkDeviceSize size; + void *vm_map; +}; + +static inline struct device_memory *device_memory_from_handle( VkDeviceMemory handle ) +{ + struct vulkan_device_memory *obj = vulkan_device_memory_from_handle( handle ); + return CONTAINING_RECORD( obj, struct device_memory, obj ); +} + struct surface { struct vulkan_surface obj; @@ -72,6 +85,309 @@ static struct swapchain *swapchain_from_handle( VkSwapchainKHR handle ) return CONTAINING_RECORD( obj, struct swapchain, obj ); }
+static inline const void *find_next_struct( const void *head, VkStructureType type ) +{ + const VkBaseInStructure *header; + for (header = head; header; header = header->pNext) if (header->sType == type) return header; + return NULL; +} + +static VkResult win32u_vkAllocateMemory( VkDevice client_device, const VkMemoryAllocateInfo *alloc_info, + const VkAllocationCallbacks *allocator, VkDeviceMemory *ret ) +{ + struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct vulkan_physical_device *physical_device = device->physical_device; + struct vulkan_instance *instance = device->physical_device->instance; + VkImportMemoryHostPointerInfoEXT host_pointer_info; + VkMemoryAllocateInfo info = *alloc_info; + VkDeviceMemory host_device_memory; + struct device_memory *memory; + uint32_t mem_flags; + void *mapping = NULL; + VkResult res; + + /* For host visible memory, we try to use VK_EXT_external_memory_host on wow64 to ensure that mapped pointer is 32-bit. */ + mem_flags = physical_device->memory_properties.memoryTypes[alloc_info->memoryTypeIndex].propertyFlags; + if (physical_device->external_memory_align && (mem_flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && + !find_next_struct( alloc_info->pNext, VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT )) + { + VkMemoryHostPointerPropertiesEXT props = + { + .sType = VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT, + }; + uint32_t i, align = physical_device->external_memory_align - 1; + SIZE_T alloc_size = info.allocationSize; + static int once; + + if (!once++) FIXME( "Using VK_EXT_external_memory_host\n" ); + + if (NtAllocateVirtualMemory( GetCurrentProcess(), &mapping, zero_bits, &alloc_size, MEM_COMMIT, PAGE_READWRITE )) + { + ERR( "NtAllocateVirtualMemory failed\n" ); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + + if ((res = device->p_vkGetMemoryHostPointerPropertiesEXT( device->host.device, VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, + mapping, &props ))) + { + ERR( "vkGetMemoryHostPointerPropertiesEXT failed: %d\n", res ); + return res; + } + + if (!(props.memoryTypeBits & (1u << info.memoryTypeIndex))) + { + /* If requested memory type is not allowed to use external memory, + * try to find a supported compatible type. */ + uint32_t mask = mem_flags & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + for (i = 0; i < physical_device->memory_properties.memoryTypeCount; i++) + { + if (!(props.memoryTypeBits & (1u << i))) continue; + if ((physical_device->memory_properties.memoryTypes[i].propertyFlags & mask) != mask) continue; + + TRACE( "Memory type not compatible with host memory, using %u instead\n", i ); + info.memoryTypeIndex = i; + break; + } + if (i == physical_device->memory_properties.memoryTypeCount) + { + FIXME( "Not found compatible memory type\n" ); + alloc_size = 0; + NtFreeVirtualMemory( GetCurrentProcess(), &mapping, &alloc_size, MEM_RELEASE ); + } + } + + if (props.memoryTypeBits & (1u << info.memoryTypeIndex)) + { + host_pointer_info.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT; + host_pointer_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + host_pointer_info.pHostPointer = mapping; + host_pointer_info.pNext = info.pNext; + info.pNext = &host_pointer_info; + + info.allocationSize = (info.allocationSize + align) & ~align; + } + } + + if (!(memory = malloc( sizeof(*memory) ))) return VK_ERROR_OUT_OF_HOST_MEMORY; + if ((res = device->p_vkAllocateMemory( device->host.device, &info, NULL, &host_device_memory ))) + { + free( memory ); + return res; + } + + vulkan_object_init( &memory->obj.obj, host_device_memory ); + memory->size = info.allocationSize; + memory->vm_map = mapping; + instance->p_insert_object( instance, &memory->obj.obj ); + + *ret = memory->obj.client.device_memory; + return VK_SUCCESS; +} + +static void win32u_vkFreeMemory( VkDevice client_device, VkDeviceMemory client_memory, const VkAllocationCallbacks *allocator ) +{ + struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct vulkan_physical_device *physical_device = device->physical_device; + struct vulkan_instance *instance = device->physical_device->instance; + struct device_memory *memory; + + if (!client_memory) return; + memory = device_memory_from_handle( client_memory ); + + if (memory->vm_map && !physical_device->external_memory_align) + { + const VkMemoryUnmapInfoKHR info = + { + .sType = VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR, + .memory = memory->obj.host.device_memory, + .flags = VK_MEMORY_UNMAP_RESERVE_BIT_EXT, + }; + device->p_vkUnmapMemory2KHR( device->host.device, &info ); + } + + device->p_vkFreeMemory( device->host.device, memory->obj.host.device_memory, NULL ); + instance->p_remove_object( instance, &memory->obj.obj ); + + if (memory->vm_map) + { + SIZE_T alloc_size = 0; + NtFreeVirtualMemory( GetCurrentProcess(), &memory->vm_map, &alloc_size, MEM_RELEASE ); + } + + free( memory ); +} + +static VkResult win32u_vkMapMemory2KHR( VkDevice client_device, const VkMemoryMapInfoKHR *map_info, void **data ) +{ + struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct vulkan_physical_device *physical_device = device->physical_device; + struct device_memory *memory = device_memory_from_handle( map_info->memory ); + VkMemoryMapInfoKHR info = *map_info; + VkMemoryMapPlacedInfoEXT placed_info = + { + .sType = VK_STRUCTURE_TYPE_MEMORY_MAP_PLACED_INFO_EXT, + }; + VkResult res; + + info.memory = memory->obj.host.device_memory; + if (memory->vm_map) + { + *data = (char *)memory->vm_map + info.offset; + TRACE( "returning %p\n", *data ); + return VK_SUCCESS; + } + + if (physical_device->map_placed_align) + { + SIZE_T alloc_size = memory->size; + + placed_info.pNext = info.pNext; + info.pNext = &placed_info; + info.offset = 0; + info.size = VK_WHOLE_SIZE; + info.flags |= VK_MEMORY_MAP_PLACED_BIT_EXT; + + if (NtAllocateVirtualMemory( GetCurrentProcess(), &placed_info.pPlacedAddress, zero_bits, + &alloc_size, MEM_COMMIT, PAGE_READWRITE )) + { + ERR( "NtAllocateVirtualMemory failed\n" ); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + } + + if (device->p_vkMapMemory2KHR) + res = device->p_vkMapMemory2KHR( device->host.device, &info, data ); + else + { + if (info.pNext) FIXME( "struct extension chain not implemented!\n" ); + res = device->p_vkMapMemory( device->host.device, info.memory, info.offset, info.size, info.flags, data ); + } + + if (placed_info.pPlacedAddress) + { + if (res != VK_SUCCESS) + { + SIZE_T alloc_size = 0; + ERR( "vkMapMemory2EXT failed: %d\n", res ); + NtFreeVirtualMemory( GetCurrentProcess(), &placed_info.pPlacedAddress, &alloc_size, MEM_RELEASE ); + return res; + } + memory->vm_map = placed_info.pPlacedAddress; + *data = (char *)memory->vm_map + map_info->offset; + TRACE( "Using placed mapping %p\n", memory->vm_map ); + } + +#ifdef _WIN64 + if (NtCurrentTeb()->WowTebOffset && res == VK_SUCCESS && (UINT_PTR)*data >> 32) + { + FIXME( "returned mapping %p does not fit 32-bit pointer\n", *data ); + device->p_vkUnmapMemory( device->host.device, memory->obj.host.device_memory ); + *data = NULL; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + } +#endif + + return res; +} + +static VkResult win32u_vkMapMemory( VkDevice client_device, VkDeviceMemory client_memory, VkDeviceSize offset, + VkDeviceSize size, VkMemoryMapFlags flags, void **data ) +{ + const VkMemoryMapInfoKHR info = + { + .sType = VK_STRUCTURE_TYPE_MEMORY_MAP_INFO_KHR, + .flags = flags, + .memory = client_memory, + .offset = offset, + .size = size, + }; + + return win32u_vkMapMemory2KHR( client_device, &info, data ); +} + +static VkResult win32u_vkUnmapMemory2KHR( VkDevice client_device, const VkMemoryUnmapInfoKHR *unmap_info ) +{ + struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct vulkan_physical_device *physical_device = device->physical_device; + struct device_memory *memory = device_memory_from_handle( unmap_info->memory ); + VkMemoryUnmapInfoKHR info; + VkResult res; + + if (memory->vm_map && physical_device->external_memory_align) return VK_SUCCESS; + + if (!device->p_vkUnmapMemory2KHR) + { + if (unmap_info->pNext || memory->vm_map) FIXME( "Not implemented\n" ); + device->p_vkUnmapMemory( device->host.device, memory->obj.host.device_memory ); + return VK_SUCCESS; + } + + info = *unmap_info; + info.memory = memory->obj.host.device_memory; + if (memory->vm_map) info.flags |= VK_MEMORY_UNMAP_RESERVE_BIT_EXT; + + res = device->p_vkUnmapMemory2KHR( device->host.device, &info ); + + if (res == VK_SUCCESS && memory->vm_map) + { + SIZE_T size = 0; + NtFreeVirtualMemory( GetCurrentProcess(), &memory->vm_map, &size, MEM_RELEASE ); + memory->vm_map = NULL; + } + return res; +} + +static void win32u_vkUnmapMemory( VkDevice client_device, VkDeviceMemory client_memory ) +{ + const VkMemoryUnmapInfoKHR info = + { + .sType = VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR, + .memory = client_memory, + }; + + win32u_vkUnmapMemory2KHR( client_device, &info ); +} + +static VkResult win32u_vkCreateBuffer( VkDevice client_device, const VkBufferCreateInfo *create_info, + const VkAllocationCallbacks *allocator, VkBuffer *buffer ) +{ + struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct vulkan_physical_device *physical_device = device->physical_device; + VkExternalMemoryBufferCreateInfo external_memory_info; + VkBufferCreateInfo info = *create_info; + + if (physical_device->external_memory_align && + !find_next_struct( info.pNext, VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO )) + { + external_memory_info.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO; + external_memory_info.pNext = info.pNext; + external_memory_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + info.pNext = &external_memory_info; + } + + return device->p_vkCreateBuffer( device->host.device, &info, NULL, buffer ); +} + +static VkResult win32u_vkCreateImage( VkDevice client_device, const VkImageCreateInfo *create_info, + const VkAllocationCallbacks *allocator, VkImage *image ) +{ + struct vulkan_device *device = vulkan_device_from_handle( client_device ); + struct vulkan_physical_device *physical_device = device->physical_device; + VkExternalMemoryImageCreateInfo external_memory_info; + VkImageCreateInfo info = *create_info; + + if (physical_device->external_memory_align && + !find_next_struct( info.pNext, VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO )) + { + external_memory_info.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO; + external_memory_info.pNext = info.pNext; + external_memory_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + info.pNext = &external_memory_info; + } + + return device->p_vkCreateImage( device->host.device, &info, NULL, image ); +} + static VkResult win32u_vkCreateWin32SurfaceKHR( VkInstance client_instance, const VkWin32SurfaceCreateInfoKHR *create_info, const VkAllocationCallbacks *allocator, VkSurfaceKHR *ret ) { @@ -483,19 +799,27 @@ static const char *win32u_get_host_surface_extension(void)
static struct vulkan_funcs vulkan_funcs = { + .p_vkAcquireNextImage2KHR = win32u_vkAcquireNextImage2KHR, + .p_vkAcquireNextImageKHR = win32u_vkAcquireNextImageKHR, + .p_vkAllocateMemory = win32u_vkAllocateMemory, + .p_vkCreateBuffer = win32u_vkCreateBuffer, + .p_vkCreateImage = win32u_vkCreateImage, + .p_vkCreateSwapchainKHR = win32u_vkCreateSwapchainKHR, .p_vkCreateWin32SurfaceKHR = win32u_vkCreateWin32SurfaceKHR, .p_vkDestroySurfaceKHR = win32u_vkDestroySurfaceKHR, - .p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = win32u_vkGetPhysicalDeviceSurfaceCapabilitiesKHR, - .p_vkGetPhysicalDeviceSurfaceCapabilities2KHR = win32u_vkGetPhysicalDeviceSurfaceCapabilities2KHR, + .p_vkDestroySwapchainKHR = win32u_vkDestroySwapchainKHR, + .p_vkFreeMemory = win32u_vkFreeMemory, .p_vkGetPhysicalDevicePresentRectanglesKHR = win32u_vkGetPhysicalDevicePresentRectanglesKHR, - .p_vkGetPhysicalDeviceSurfaceFormatsKHR = win32u_vkGetPhysicalDeviceSurfaceFormatsKHR, + .p_vkGetPhysicalDeviceSurfaceCapabilities2KHR = win32u_vkGetPhysicalDeviceSurfaceCapabilities2KHR, + .p_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = win32u_vkGetPhysicalDeviceSurfaceCapabilitiesKHR, .p_vkGetPhysicalDeviceSurfaceFormats2KHR = win32u_vkGetPhysicalDeviceSurfaceFormats2KHR, + .p_vkGetPhysicalDeviceSurfaceFormatsKHR = win32u_vkGetPhysicalDeviceSurfaceFormatsKHR, .p_vkGetPhysicalDeviceWin32PresentationSupportKHR = win32u_vkGetPhysicalDeviceWin32PresentationSupportKHR, - .p_vkCreateSwapchainKHR = win32u_vkCreateSwapchainKHR, - .p_vkDestroySwapchainKHR = win32u_vkDestroySwapchainKHR, - .p_vkAcquireNextImage2KHR = win32u_vkAcquireNextImage2KHR, - .p_vkAcquireNextImageKHR = win32u_vkAcquireNextImageKHR, + .p_vkMapMemory = win32u_vkMapMemory, + .p_vkMapMemory2KHR = win32u_vkMapMemory2KHR, .p_vkQueuePresentKHR = win32u_vkQueuePresentKHR, + .p_vkUnmapMemory = win32u_vkUnmapMemory, + .p_vkUnmapMemory2KHR = win32u_vkUnmapMemory2KHR, .p_get_host_surface_extension = win32u_get_host_surface_extension, };
diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index b968b7d6e87..09d450bba71 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -213,10 +213,14 @@ FUNCTION_OVERRIDES = { USER_DRIVER_FUNCS = { "vkAcquireNextImage2KHR", "vkAcquireNextImageKHR", + "vkAllocateMemory", + "vkCreateBuffer", + "vkCreateImage", "vkCreateSwapchainKHR", "vkCreateWin32SurfaceKHR", "vkDestroySurfaceKHR", "vkDestroySwapchainKHR", + "vkFreeMemory", "vkGetDeviceProcAddr", "vkGetInstanceProcAddr", "vkGetPhysicalDevicePresentRectanglesKHR", @@ -225,20 +229,21 @@ USER_DRIVER_FUNCS = { "vkGetPhysicalDeviceSurfaceFormats2KHR", "vkGetPhysicalDeviceSurfaceFormatsKHR", "vkGetPhysicalDeviceWin32PresentationSupportKHR", + "vkMapMemory", + "vkMapMemory2KHR", "vkQueuePresentKHR", + "vkUnmapMemory", + "vkUnmapMemory2KHR", }
# functions for which the unix thunk is manually implemented MANUAL_UNIX_THUNKS = { "vkAllocateCommandBuffers", - "vkAllocateMemory", - "vkCreateBuffer", "vkCreateCommandPool", "vkCreateDebugReportCallbackEXT", "vkCreateDebugUtilsMessengerEXT", "vkCreateDeferredOperationKHR", "vkCreateDevice", - "vkCreateImage", "vkCreateInstance", "vkDestroyCommandPool", "vkDestroyDebugReportCallbackEXT", @@ -255,7 +260,6 @@ MANUAL_UNIX_THUNKS = { "vkEnumeratePhysicalDeviceGroupsKHR", "vkEnumeratePhysicalDevices", "vkFreeCommandBuffers", - "vkFreeMemory", "vkGetCalibratedTimestampsEXT", "vkGetCalibratedTimestampsKHR", "vkGetDeviceProcAddr", @@ -272,10 +276,6 @@ MANUAL_UNIX_THUNKS = { "vkGetPhysicalDeviceExternalSemaphorePropertiesKHR", "vkGetPhysicalDeviceImageFormatProperties2", "vkGetPhysicalDeviceImageFormatProperties2KHR", - "vkMapMemory", - "vkMapMemory2KHR", - "vkUnmapMemory", - "vkUnmapMemory2KHR", }
# loader functions which are entirely manually implemented @@ -1112,7 +1112,7 @@ class VkHandle(object): if self.name == "VkInstance": return "vulkan_instance_from_handle({0})->host.instance".format(name) if self.name == "VkDeviceMemory": - return "wine_device_memory_from_handle({0})->host.device_memory".format(name) + return "vulkan_device_memory_from_handle({0})->host.device_memory".format(name) if self.name == "VkPhysicalDevice": return "vulkan_physical_device_from_handle({0})->host.physical_device".format(name) if self.name == "VkQueue": diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 82cbaba5af8..38930fa302b 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -1644,317 +1644,6 @@ void wine_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(VkPhysicalDevice cli properties->externalSemaphoreFeatures = 0; }
-VkResult wine_vkAllocateMemory(VkDevice client_device, const VkMemoryAllocateInfo *alloc_info, - const VkAllocationCallbacks *allocator, VkDeviceMemory *ret) -{ - struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct vulkan_physical_device *physical_device = device->physical_device; - struct vulkan_instance *instance = device->physical_device->instance; - struct wine_device_memory *memory; - VkMemoryAllocateInfo info = *alloc_info; - VkImportMemoryHostPointerInfoEXT host_pointer_info; - VkDeviceMemory host_device_memory; - uint32_t mem_flags; - void *mapping = NULL; - VkResult result; - - /* For host visible memory, we try to use VK_EXT_external_memory_host on wow64 - * to ensure that mapped pointer is 32-bit. */ - mem_flags = physical_device->memory_properties.memoryTypes[alloc_info->memoryTypeIndex].propertyFlags; - if (physical_device->external_memory_align && (mem_flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && - !find_next_struct(alloc_info->pNext, VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT)) - { - VkMemoryHostPointerPropertiesEXT props = - { - .sType = VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT, - }; - uint32_t i, align = physical_device->external_memory_align - 1; - SIZE_T alloc_size = info.allocationSize; - static int once; - - if (!once++) - FIXME("Using VK_EXT_external_memory_host\n"); - - if (NtAllocateVirtualMemory(GetCurrentProcess(), &mapping, zero_bits, &alloc_size, - MEM_COMMIT, PAGE_READWRITE)) - { - ERR("NtAllocateVirtualMemory failed\n"); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - result = device->p_vkGetMemoryHostPointerPropertiesEXT(device->host.device, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, mapping, &props); - if (result != VK_SUCCESS) - { - ERR("vkGetMemoryHostPointerPropertiesEXT failed: %d\n", result); - return result; - } - - if (!(props.memoryTypeBits & (1u << info.memoryTypeIndex))) - { - /* If requested memory type is not allowed to use external memory, - * try to find a supported compatible type. */ - uint32_t mask = mem_flags & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - for (i = 0; i < physical_device->memory_properties.memoryTypeCount; i++) - { - if (!(props.memoryTypeBits & (1u << i))) - continue; - if ((physical_device->memory_properties.memoryTypes[i].propertyFlags & mask) != mask) - continue; - - TRACE("Memory type not compatible with host memory, using %u instead\n", i); - info.memoryTypeIndex = i; - break; - } - if (i == physical_device->memory_properties.memoryTypeCount) - { - FIXME("Not found compatible memory type\n"); - alloc_size = 0; - NtFreeVirtualMemory(GetCurrentProcess(), &mapping, &alloc_size, MEM_RELEASE); - } - } - - if (props.memoryTypeBits & (1u << info.memoryTypeIndex)) - { - host_pointer_info.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT; - host_pointer_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; - host_pointer_info.pHostPointer = mapping; - host_pointer_info.pNext = info.pNext; - info.pNext = &host_pointer_info; - - info.allocationSize = (info.allocationSize + align) & ~align; - } - } - - if (!(memory = malloc(sizeof(*memory)))) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - result = device->p_vkAllocateMemory(device->host.device, &info, NULL, &host_device_memory); - if (result != VK_SUCCESS) - { - free(memory); - return result; - } - - vulkan_object_init(&memory->obj, host_device_memory); - memory->size = info.allocationSize; - memory->vm_map = mapping; - vulkan_instance_insert_object(instance, &memory->obj); - - *ret = memory->client.device_memory; - return VK_SUCCESS; -} - -void wine_vkFreeMemory(VkDevice client_device, VkDeviceMemory memory_handle, const VkAllocationCallbacks *allocator) -{ - struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct vulkan_physical_device *physical_device = device->physical_device; - struct vulkan_instance *instance = device->physical_device->instance; - struct wine_device_memory *memory; - - if (!memory_handle) - return; - memory = wine_device_memory_from_handle(memory_handle); - - if (memory->vm_map && !physical_device->external_memory_align) - { - const VkMemoryUnmapInfoKHR info = - { - .sType = VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR, - .memory = memory->host.device_memory, - .flags = VK_MEMORY_UNMAP_RESERVE_BIT_EXT, - }; - device->p_vkUnmapMemory2KHR(device->host.device, &info); - } - - device->p_vkFreeMemory(device->host.device, memory->host.device_memory, NULL); - vulkan_instance_remove_object(instance, &memory->obj); - - if (memory->vm_map) - { - SIZE_T alloc_size = 0; - NtFreeVirtualMemory(GetCurrentProcess(), &memory->vm_map, &alloc_size, MEM_RELEASE); - } - - free(memory); -} - -VkResult wine_vkMapMemory(VkDevice client_device, VkDeviceMemory memory, VkDeviceSize offset, - VkDeviceSize size, VkMemoryMapFlags flags, void **data) -{ - const VkMemoryMapInfoKHR info = - { - .sType = VK_STRUCTURE_TYPE_MEMORY_MAP_INFO_KHR, - .flags = flags, - .memory = memory, - .offset = offset, - .size = size, - }; - - return wine_vkMapMemory2KHR(client_device, &info, data); -} - -VkResult wine_vkMapMemory2KHR(VkDevice client_device, const VkMemoryMapInfoKHR *map_info, void **data) -{ - struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct vulkan_physical_device *physical_device = device->physical_device; - struct wine_device_memory *memory = wine_device_memory_from_handle(map_info->memory); - VkMemoryMapInfoKHR info = *map_info; - VkMemoryMapPlacedInfoEXT placed_info = - { - .sType = VK_STRUCTURE_TYPE_MEMORY_MAP_PLACED_INFO_EXT, - }; - VkResult result; - - info.memory = memory->host.device_memory; - if (memory->vm_map) - { - *data = (char *)memory->vm_map + info.offset; - TRACE("returning %p\n", *data); - return VK_SUCCESS; - } - - if (physical_device->map_placed_align) - { - SIZE_T alloc_size = memory->size; - - placed_info.pNext = info.pNext; - info.pNext = &placed_info; - info.offset = 0; - info.size = VK_WHOLE_SIZE; - info.flags |= VK_MEMORY_MAP_PLACED_BIT_EXT; - - if (NtAllocateVirtualMemory(GetCurrentProcess(), &placed_info.pPlacedAddress, zero_bits, &alloc_size, - MEM_COMMIT, PAGE_READWRITE)) - { - ERR("NtAllocateVirtualMemory failed\n"); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - } - - if (device->p_vkMapMemory2KHR) - { - result = device->p_vkMapMemory2KHR(device->host.device, &info, data); - } - else - { - assert(!info.pNext); - result = device->p_vkMapMemory(device->host.device, info.memory, info.offset, - info.size, info.flags, data); - } - - if (placed_info.pPlacedAddress) - { - if (result != VK_SUCCESS) - { - SIZE_T alloc_size = 0; - ERR("vkMapMemory2EXT failed: %d\n", result); - NtFreeVirtualMemory(GetCurrentProcess(), &placed_info.pPlacedAddress, &alloc_size, MEM_RELEASE); - return result; - } - memory->vm_map = placed_info.pPlacedAddress; - *data = (char *)memory->vm_map + map_info->offset; - TRACE("Using placed mapping %p\n", memory->vm_map); - } - -#ifdef _WIN64 - if (NtCurrentTeb()->WowTebOffset && result == VK_SUCCESS && (UINT_PTR)*data >> 32) - { - FIXME("returned mapping %p does not fit 32-bit pointer\n", *data); - device->p_vkUnmapMemory(device->host.device, memory->host.device_memory); - *data = NULL; - result = VK_ERROR_OUT_OF_HOST_MEMORY; - } -#endif - - return result; -} - -void wine_vkUnmapMemory(VkDevice client_device, VkDeviceMemory memory) -{ - const VkMemoryUnmapInfoKHR info = - { - .sType = VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR, - .memory = memory, - }; - - wine_vkUnmapMemory2KHR(client_device, &info); -} - -VkResult wine_vkUnmapMemory2KHR(VkDevice client_device, const VkMemoryUnmapInfoKHR *unmap_info) -{ - struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct vulkan_physical_device *physical_device = device->physical_device; - struct wine_device_memory *memory = wine_device_memory_from_handle(unmap_info->memory); - VkMemoryUnmapInfoKHR info; - VkResult result; - - if (memory->vm_map && physical_device->external_memory_align) - return VK_SUCCESS; - - if (!device->p_vkUnmapMemory2KHR) - { - assert(!unmap_info->pNext && !memory->vm_map); - device->p_vkUnmapMemory(device->host.device, memory->host.device_memory); - return VK_SUCCESS; - } - - info = *unmap_info; - info.memory = memory->host.device_memory; - if (memory->vm_map) - info.flags |= VK_MEMORY_UNMAP_RESERVE_BIT_EXT; - - result = device->p_vkUnmapMemory2KHR(device->host.device, &info); - - if (result == VK_SUCCESS && memory->vm_map) - { - SIZE_T size = 0; - NtFreeVirtualMemory(GetCurrentProcess(), &memory->vm_map, &size, MEM_RELEASE); - memory->vm_map = NULL; - } - return result; -} - -VkResult wine_vkCreateBuffer(VkDevice client_device, const VkBufferCreateInfo *create_info, - const VkAllocationCallbacks *allocator, VkBuffer *buffer) -{ - struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct vulkan_physical_device *physical_device = device->physical_device; - VkExternalMemoryBufferCreateInfo external_memory_info; - VkBufferCreateInfo info = *create_info; - - if (physical_device->external_memory_align && - !find_next_struct(info.pNext, VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO)) - { - external_memory_info.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO; - external_memory_info.pNext = info.pNext; - external_memory_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; - info.pNext = &external_memory_info; - } - - return device->p_vkCreateBuffer(device->host.device, &info, NULL, buffer); -} - -VkResult wine_vkCreateImage(VkDevice client_device, const VkImageCreateInfo *create_info, - const VkAllocationCallbacks *allocator, VkImage *image) -{ - struct vulkan_device *device = vulkan_device_from_handle(client_device); - struct vulkan_physical_device *physical_device = device->physical_device; - VkExternalMemoryImageCreateInfo external_memory_info; - VkImageCreateInfo info = *create_info; - - if (physical_device->external_memory_align && - !find_next_struct(info.pNext, VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO)) - { - external_memory_info.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO; - external_memory_info.pNext = info.pNext; - external_memory_info.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; - info.pNext = &external_memory_info; - } - - return device->p_vkCreateImage(device->host.device, &info, NULL, image); -} - VkResult wine_vkCreateDebugUtilsMessengerEXT(VkInstance client_instance, const VkDebugUtilsMessengerCreateInfoEXT *create_info, const VkAllocationCallbacks *allocator, diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index d9ff386b469..da520433467 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -100,18 +100,6 @@ static inline struct wine_cmd_pool *wine_cmd_pool_from_handle(VkCommandPool hand return (struct wine_cmd_pool *)(UINT_PTR)client->unix_handle; }
-struct wine_device_memory -{ - VULKAN_OBJECT_HEADER( VkDeviceMemory, device_memory ); - VkDeviceSize size; - void *vm_map; -}; - -static inline struct wine_device_memory *wine_device_memory_from_handle(VkDeviceMemory handle) -{ - return (struct wine_device_memory *)(uintptr_t)handle; -} - struct wine_debug_utils_messenger { VULKAN_OBJECT_HEADER( VkDebugUtilsMessengerEXT, debug_messenger ); diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index c8045fa397e..3d8882c8db0 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -9540,7 +9540,7 @@ static uint64_t wine_vk_unwrap_handle(uint32_t type, uint64_t handle) case VK_OBJECT_TYPE_DEVICE: return (uint64_t) (uintptr_t) vulkan_device_from_handle(((VkDevice) (uintptr_t) handle))->host.device; case VK_OBJECT_TYPE_DEVICE_MEMORY: - return (uint64_t) wine_device_memory_from_handle(handle)->host.device_memory; + return (uint64_t) vulkan_device_memory_from_handle(handle)->host.device_memory; case VK_OBJECT_TYPE_INSTANCE: return (uint64_t) (uintptr_t) vulkan_instance_from_handle(((VkInstance) (uintptr_t) handle))->host.instance; case VK_OBJECT_TYPE_PHYSICAL_DEVICE: @@ -9934,7 +9934,7 @@ static inline void convert_VkCommandBufferInheritanceInfo_win64_to_host(struct c const VkTileMemoryBindInfoQCOM *in_ext = (const VkTileMemoryBindInfoQCOM *)in_header; out_ext->sType = VK_STRUCTURE_TYPE_TILE_MEMORY_BIND_INFO_QCOM; out_ext->pNext = NULL; - out_ext->memory = wine_device_memory_from_handle(in_ext->memory)->host.device_memory; + out_ext->memory = vulkan_device_memory_from_handle(in_ext->memory)->host.device_memory; out_header->pNext = (void *)out_ext; out_header = (void *)out_ext; break; @@ -10077,7 +10077,7 @@ static inline void convert_VkCommandBufferInheritanceInfo_win32_to_host(struct c const VkTileMemoryBindInfoQCOM32 *in_ext = (const VkTileMemoryBindInfoQCOM32 *)in_header; out_ext->sType = VK_STRUCTURE_TYPE_TILE_MEMORY_BIND_INFO_QCOM; out_ext->pNext = NULL; - out_ext->memory = wine_device_memory_from_handle(in_ext->memory)->host.device_memory; + out_ext->memory = vulkan_device_memory_from_handle(in_ext->memory)->host.device_memory; out_header->pNext = (void *)out_ext; out_header = (void *)out_ext; break; @@ -10215,7 +10215,7 @@ static inline void convert_VkBindAccelerationStructureMemoryInfoNV_win64_to_host out->sType = in->sType; out->pNext = in->pNext; out->accelerationStructure = in->accelerationStructure; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; out->deviceIndexCount = in->deviceIndexCount; out->pDeviceIndices = in->pDeviceIndices; @@ -10229,7 +10229,7 @@ static inline void convert_VkBindAccelerationStructureMemoryInfoNV_win32_to_host out->sType = in->sType; out->pNext = NULL; out->accelerationStructure = in->accelerationStructure; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; out->deviceIndexCount = in->deviceIndexCount; out->pDeviceIndices = UlongToPtr(in->pDeviceIndices); @@ -10279,7 +10279,7 @@ static inline void convert_VkBindBufferMemoryInfo_win64_to_host(const VkBindBuff out->sType = in->sType; out->pNext = in->pNext; out->buffer = in->buffer; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; } #endif /* _WIN64 */ @@ -10294,7 +10294,7 @@ static inline void convert_VkBindBufferMemoryInfo_win32_to_host(struct conversio out->sType = in->sType; out->pNext = NULL; out->buffer = in->buffer; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset;
for (in_header = UlongToPtr(in->pNext); in_header; in_header = UlongToPtr(in_header->pNext)) @@ -10375,7 +10375,7 @@ static inline void convert_VkBindDataGraphPipelineSessionMemoryInfoARM_win64_to_ out->session = in->session; out->bindPoint = in->bindPoint; out->objectIndex = in->objectIndex; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; } #endif /* _WIN64 */ @@ -10389,7 +10389,7 @@ static inline void convert_VkBindDataGraphPipelineSessionMemoryInfoARM_win32_to_ out->session = in->session; out->bindPoint = in->bindPoint; out->objectIndex = in->objectIndex; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; if (in->pNext) FIXME("Unexpected pNext\n"); @@ -10440,7 +10440,7 @@ static inline void convert_VkBindImageMemoryInfo_win64_to_host(struct conversion out->sType = in->sType; out->pNext = NULL; out->image = in->image; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset;
for (in_header = (void *)in->pNext; in_header; in_header = (void *)in_header->pNext) @@ -10513,7 +10513,7 @@ static inline void convert_VkBindImageMemoryInfo_win32_to_host(struct conversion out->sType = in->sType; out->pNext = NULL; out->image = in->image; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset;
for (in_header = UlongToPtr(in->pNext); in_header; in_header = UlongToPtr(in_header->pNext)) @@ -10617,7 +10617,7 @@ static inline void convert_VkBindTensorMemoryInfoARM_win64_to_host(const VkBindT out->sType = in->sType; out->pNext = in->pNext; out->tensor = in->tensor; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; } #endif /* _WIN64 */ @@ -10629,7 +10629,7 @@ static inline void convert_VkBindTensorMemoryInfoARM_win32_to_host(const VkBindT out->sType = in->sType; out->pNext = NULL; out->tensor = in->tensor; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; if (in->pNext) FIXME("Unexpected pNext\n"); @@ -10677,7 +10677,7 @@ static inline void convert_VkBindVideoSessionMemoryInfoKHR_win64_to_host(const V out->sType = in->sType; out->pNext = in->pNext; out->memoryBindIndex = in->memoryBindIndex; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; out->memorySize = in->memorySize; } @@ -10690,7 +10690,7 @@ static inline void convert_VkBindVideoSessionMemoryInfoKHR_win32_to_host(const V out->sType = in->sType; out->pNext = NULL; out->memoryBindIndex = in->memoryBindIndex; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->memoryOffset = in->memoryOffset; out->memorySize = in->memorySize; if (in->pNext) @@ -11922,7 +11922,7 @@ static inline void convert_VkTileMemoryBindInfoQCOM_win64_to_host(const VkTileMe
out->sType = in->sType; out->pNext = in->pNext; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; } #endif /* _WIN64 */
@@ -11932,7 +11932,7 @@ static inline void convert_VkTileMemoryBindInfoQCOM_win32_to_host(const VkTileMe
out->sType = in->sType; out->pNext = NULL; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; if (in->pNext) FIXME("Unexpected pNext\n"); } @@ -26751,7 +26751,7 @@ static inline void convert_VkMappedMemoryRange_win64_to_host(const VkMappedMemor
out->sType = in->sType; out->pNext = in->pNext; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->offset = in->offset; out->size = in->size; } @@ -26763,7 +26763,7 @@ static inline void convert_VkMappedMemoryRange_win32_to_host(const VkMappedMemor
out->sType = in->sType; out->pNext = NULL; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->offset = in->offset; out->size = in->size; if (in->pNext) @@ -27804,7 +27804,7 @@ static inline void convert_VkDeviceMemoryOpaqueCaptureAddressInfo_win64_to_host(
out->sType = in->sType; out->pNext = in->pNext; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; } #endif /* _WIN64 */
@@ -27814,7 +27814,7 @@ static inline void convert_VkDeviceMemoryOpaqueCaptureAddressInfo_win32_to_host(
out->sType = in->sType; out->pNext = NULL; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; if (in->pNext) FIXME("Unexpected pNext\n"); } @@ -38466,7 +38466,7 @@ static inline void convert_VkMemoryMapInfo_win64_to_host(const VkMemoryMapInfo * out->sType = in->sType; out->pNext = in->pNext; out->flags = in->flags; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->offset = in->offset; out->size = in->size; } @@ -38482,7 +38482,7 @@ static inline void convert_VkMemoryMapInfo_win32_to_host(struct conversion_conte out->sType = in->sType; out->pNext = NULL; out->flags = in->flags; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; out->offset = in->offset; out->size = in->size;
@@ -38551,7 +38551,7 @@ static inline void convert_VkSparseMemoryBind_win64_to_host(const VkSparseMemory
out->resourceOffset = in->resourceOffset; out->size = in->size; - out->memory = in->memory ? wine_device_memory_from_handle(in->memory)->host.device_memory : 0; + out->memory = in->memory ? vulkan_device_memory_from_handle(in->memory)->host.device_memory : 0; out->memoryOffset = in->memoryOffset; out->flags = in->flags; } @@ -38563,7 +38563,7 @@ static inline void convert_VkSparseMemoryBind_win32_to_host(const VkSparseMemory
out->resourceOffset = in->resourceOffset; out->size = in->size; - out->memory = in->memory ? wine_device_memory_from_handle(in->memory)->host.device_memory : 0; + out->memory = in->memory ? vulkan_device_memory_from_handle(in->memory)->host.device_memory : 0; out->memoryOffset = in->memoryOffset; out->flags = in->flags; } @@ -38718,7 +38718,7 @@ static inline void convert_VkSparseImageMemoryBind_win64_to_host(const VkSparseI out->subresource = in->subresource; out->offset = in->offset; out->extent = in->extent; - out->memory = in->memory ? wine_device_memory_from_handle(in->memory)->host.device_memory : 0; + out->memory = in->memory ? vulkan_device_memory_from_handle(in->memory)->host.device_memory : 0; out->memoryOffset = in->memoryOffset; out->flags = in->flags; } @@ -38731,7 +38731,7 @@ static inline void convert_VkSparseImageMemoryBind_win32_to_host(const VkSparseI out->subresource = in->subresource; out->offset = in->offset; out->extent = in->extent; - out->memory = in->memory ? wine_device_memory_from_handle(in->memory)->host.device_memory : 0; + out->memory = in->memory ? vulkan_device_memory_from_handle(in->memory)->host.device_memory : 0; out->memoryOffset = in->memoryOffset; out->flags = in->flags; } @@ -39922,7 +39922,7 @@ static inline void convert_VkMemoryUnmapInfo_win64_to_host(const VkMemoryUnmapIn out->sType = in->sType; out->pNext = in->pNext; out->flags = in->flags; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; } #endif /* _WIN64 */
@@ -39933,7 +39933,7 @@ static inline void convert_VkMemoryUnmapInfo_win32_to_host(const VkMemoryUnmapIn out->sType = in->sType; out->pNext = NULL; out->flags = in->flags; - out->memory = wine_device_memory_from_handle(in->memory)->host.device_memory; + out->memory = vulkan_device_memory_from_handle(in->memory)->host.device_memory; if (in->pNext) FIXME("Unexpected pNext\n"); } @@ -40312,7 +40312,7 @@ static NTSTATUS thunk64_vkAllocateMemory(void *args)
TRACE("%p, %p, %p, %p\n", params->device, params->pAllocateInfo, params->pAllocator, params->pMemory);
- params->result = wine_vkAllocateMemory(params->device, params->pAllocateInfo, params->pAllocator, params->pMemory); + params->result = vk_funcs->p_vkAllocateMemory(params->device, params->pAllocateInfo, params->pAllocator, params->pMemory); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -40335,7 +40335,7 @@ static NTSTATUS thunk32_vkAllocateMemory(void *args)
init_conversion_context(ctx); convert_VkMemoryAllocateInfo_win32_to_host(ctx, (const VkMemoryAllocateInfo32 *)UlongToPtr(params->pAllocateInfo), &pAllocateInfo_host); - params->result = wine_vkAllocateMemory((VkDevice)UlongToPtr(params->device), &pAllocateInfo_host, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator), (VkDeviceMemory *)UlongToPtr(params->pMemory)); + params->result = vk_funcs->p_vkAllocateMemory((VkDevice)UlongToPtr(params->device), &pAllocateInfo_host, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator), (VkDeviceMemory *)UlongToPtr(params->pMemory)); free_conversion_context(ctx); return STATUS_SUCCESS; } @@ -40458,7 +40458,7 @@ static NTSTATUS thunk64_vkBindBufferMemory(void *args)
TRACE("%p, 0x%s, 0x%s, 0x%s\n", params->device, wine_dbgstr_longlong(params->buffer), wine_dbgstr_longlong(params->memory), wine_dbgstr_longlong(params->memoryOffset));
- params->result = vulkan_device_from_handle(params->device)->p_vkBindBufferMemory(vulkan_device_from_handle(params->device)->host.device, params->buffer, wine_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); + params->result = vulkan_device_from_handle(params->device)->p_vkBindBufferMemory(vulkan_device_from_handle(params->device)->host.device, params->buffer, vulkan_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -40476,7 +40476,7 @@ static NTSTATUS thunk32_vkBindBufferMemory(void *args)
TRACE("%#x, 0x%s, 0x%s, 0x%s\n", params->device, wine_dbgstr_longlong(params->buffer), wine_dbgstr_longlong(params->memory), wine_dbgstr_longlong(params->memoryOffset));
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkBindBufferMemory(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->buffer, wine_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkBindBufferMemory(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->buffer, vulkan_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); return STATUS_SUCCESS; }
@@ -40607,7 +40607,7 @@ static NTSTATUS thunk64_vkBindImageMemory(void *args)
TRACE("%p, 0x%s, 0x%s, 0x%s\n", params->device, wine_dbgstr_longlong(params->image), wine_dbgstr_longlong(params->memory), wine_dbgstr_longlong(params->memoryOffset));
- params->result = vulkan_device_from_handle(params->device)->p_vkBindImageMemory(vulkan_device_from_handle(params->device)->host.device, params->image, wine_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); + params->result = vulkan_device_from_handle(params->device)->p_vkBindImageMemory(vulkan_device_from_handle(params->device)->host.device, params->image, vulkan_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -40625,7 +40625,7 @@ static NTSTATUS thunk32_vkBindImageMemory(void *args)
TRACE("%#x, 0x%s, 0x%s, 0x%s\n", params->device, wine_dbgstr_longlong(params->image), wine_dbgstr_longlong(params->memory), wine_dbgstr_longlong(params->memoryOffset));
- params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkBindImageMemory(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->image, wine_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); + params->result = vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkBindImageMemory(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, params->image, vulkan_device_memory_from_handle(params->memory)->host.device_memory, params->memoryOffset); return STATUS_SUCCESS; }
@@ -47775,7 +47775,7 @@ static NTSTATUS thunk64_vkCreateBuffer(void *args)
TRACE("%p, %p, %p, %p\n", params->device, params->pCreateInfo, params->pAllocator, params->pBuffer);
- params->result = wine_vkCreateBuffer(params->device, params->pCreateInfo, params->pAllocator, params->pBuffer); + params->result = vk_funcs->p_vkCreateBuffer(params->device, params->pCreateInfo, params->pAllocator, params->pBuffer); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -47798,7 +47798,7 @@ static NTSTATUS thunk32_vkCreateBuffer(void *args)
init_conversion_context(ctx); convert_VkBufferCreateInfo_win32_to_host(ctx, (const VkBufferCreateInfo32 *)UlongToPtr(params->pCreateInfo), &pCreateInfo_host); - params->result = wine_vkCreateBuffer((VkDevice)UlongToPtr(params->device), &pCreateInfo_host, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator), (VkBuffer *)UlongToPtr(params->pBuffer)); + params->result = vk_funcs->p_vkCreateBuffer((VkDevice)UlongToPtr(params->device), &pCreateInfo_host, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator), (VkBuffer *)UlongToPtr(params->pBuffer)); free_conversion_context(ctx); return STATUS_SUCCESS; } @@ -48490,7 +48490,7 @@ static NTSTATUS thunk64_vkCreateImage(void *args)
init_conversion_context(ctx); convert_VkImageCreateInfo_win64_to_host(ctx, params->pCreateInfo, &pCreateInfo_host); - params->result = wine_vkCreateImage(params->device, &pCreateInfo_host, params->pAllocator, params->pImage); + params->result = vk_funcs->p_vkCreateImage(params->device, &pCreateInfo_host, params->pAllocator, params->pImage); free_conversion_context(ctx); return STATUS_SUCCESS; } @@ -48514,7 +48514,7 @@ static NTSTATUS thunk32_vkCreateImage(void *args)
init_conversion_context(ctx); convert_VkImageCreateInfo_win32_to_host(ctx, (const VkImageCreateInfo32 *)UlongToPtr(params->pCreateInfo), &pCreateInfo_host); - params->result = wine_vkCreateImage((VkDevice)UlongToPtr(params->device), &pCreateInfo_host, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator), (VkImage *)UlongToPtr(params->pImage)); + params->result = vk_funcs->p_vkCreateImage((VkDevice)UlongToPtr(params->device), &pCreateInfo_host, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator), (VkImage *)UlongToPtr(params->pImage)); free_conversion_context(ctx); return STATUS_SUCCESS; } @@ -51461,7 +51461,7 @@ static NTSTATUS thunk64_vkFreeMemory(void *args)
TRACE("%p, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->memory), params->pAllocator);
- wine_vkFreeMemory(params->device, params->memory, params->pAllocator); + vk_funcs->p_vkFreeMemory(params->device, params->memory, params->pAllocator); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -51477,7 +51477,7 @@ static NTSTATUS thunk32_vkFreeMemory(void *args)
TRACE("%#x, 0x%s, %#x\n", params->device, wine_dbgstr_longlong(params->memory), params->pAllocator);
- wine_vkFreeMemory((VkDevice)UlongToPtr(params->device), params->memory, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator)); + vk_funcs->p_vkFreeMemory((VkDevice)UlongToPtr(params->device), params->memory, (const VkAllocationCallbacks *)UlongToPtr(params->pAllocator)); return STATUS_SUCCESS; }
@@ -52957,7 +52957,7 @@ static NTSTATUS thunk64_vkGetDeviceMemoryCommitment(void *args)
TRACE("%p, 0x%s, %p\n", params->device, wine_dbgstr_longlong(params->memory), params->pCommittedMemoryInBytes);
- vulkan_device_from_handle(params->device)->p_vkGetDeviceMemoryCommitment(vulkan_device_from_handle(params->device)->host.device, wine_device_memory_from_handle(params->memory)->host.device_memory, params->pCommittedMemoryInBytes); + vulkan_device_from_handle(params->device)->p_vkGetDeviceMemoryCommitment(vulkan_device_from_handle(params->device)->host.device, vulkan_device_memory_from_handle(params->memory)->host.device_memory, params->pCommittedMemoryInBytes); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -52973,7 +52973,7 @@ static NTSTATUS thunk32_vkGetDeviceMemoryCommitment(void *args)
TRACE("%#x, 0x%s, %#x\n", params->device, wine_dbgstr_longlong(params->memory), params->pCommittedMemoryInBytes);
- vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetDeviceMemoryCommitment(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, wine_device_memory_from_handle(params->memory)->host.device_memory, (VkDeviceSize *)UlongToPtr(params->pCommittedMemoryInBytes)); + vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkGetDeviceMemoryCommitment(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, vulkan_device_memory_from_handle(params->memory)->host.device_memory, (VkDeviceSize *)UlongToPtr(params->pCommittedMemoryInBytes)); return STATUS_SUCCESS; }
@@ -57108,7 +57108,7 @@ static NTSTATUS thunk64_vkMapMemory(void *args)
TRACE("%p, 0x%s, 0x%s, 0x%s, %#x, %p\n", params->device, wine_dbgstr_longlong(params->memory), wine_dbgstr_longlong(params->offset), wine_dbgstr_longlong(params->size), params->flags, params->ppData);
- params->result = wine_vkMapMemory(params->device, params->memory, params->offset, params->size, params->flags, params->ppData); + params->result = vk_funcs->p_vkMapMemory(params->device, params->memory, params->offset, params->size, params->flags, params->ppData); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -57130,7 +57130,7 @@ static NTSTATUS thunk32_vkMapMemory(void *args) TRACE("%#x, 0x%s, 0x%s, 0x%s, %#x, %#x\n", params->device, wine_dbgstr_longlong(params->memory), wine_dbgstr_longlong(params->offset), wine_dbgstr_longlong(params->size), params->flags, params->ppData);
ppData_host = UlongToPtr(*(PTR32 *)UlongToPtr(params->ppData)); - params->result = wine_vkMapMemory((VkDevice)UlongToPtr(params->device), params->memory, params->offset, params->size, params->flags, &ppData_host); + params->result = vk_funcs->p_vkMapMemory((VkDevice)UlongToPtr(params->device), params->memory, params->offset, params->size, params->flags, &ppData_host); *(PTR32 *)UlongToPtr(params->ppData) = PtrToUlong(ppData_host); return STATUS_SUCCESS; } @@ -57181,7 +57181,7 @@ static NTSTATUS thunk64_vkMapMemory2KHR(void *args)
TRACE("%p, %p, %p\n", params->device, params->pMemoryMapInfo, params->ppData);
- params->result = wine_vkMapMemory2KHR(params->device, params->pMemoryMapInfo, params->ppData); + params->result = vk_funcs->p_vkMapMemory2KHR(params->device, params->pMemoryMapInfo, params->ppData); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -57205,7 +57205,7 @@ static NTSTATUS thunk32_vkMapMemory2KHR(void *args) init_conversion_context(ctx); convert_VkMemoryMapInfo_win32_to_unwrapped_host(ctx, (const VkMemoryMapInfo32 *)UlongToPtr(params->pMemoryMapInfo), &pMemoryMapInfo_host); ppData_host = UlongToPtr(*(PTR32 *)UlongToPtr(params->ppData)); - params->result = wine_vkMapMemory2KHR((VkDevice)UlongToPtr(params->device), &pMemoryMapInfo_host, &ppData_host); + params->result = vk_funcs->p_vkMapMemory2KHR((VkDevice)UlongToPtr(params->device), &pMemoryMapInfo_host, &ppData_host); *(PTR32 *)UlongToPtr(params->ppData) = PtrToUlong(ppData_host); free_conversion_context(ctx); return STATUS_SUCCESS; @@ -58035,7 +58035,7 @@ static NTSTATUS thunk64_vkSetDeviceMemoryPriorityEXT(void *args)
TRACE("%p, 0x%s, %f\n", params->device, wine_dbgstr_longlong(params->memory), params->priority);
- vulkan_device_from_handle(params->device)->p_vkSetDeviceMemoryPriorityEXT(vulkan_device_from_handle(params->device)->host.device, wine_device_memory_from_handle(params->memory)->host.device_memory, params->priority); + vulkan_device_from_handle(params->device)->p_vkSetDeviceMemoryPriorityEXT(vulkan_device_from_handle(params->device)->host.device, vulkan_device_memory_from_handle(params->memory)->host.device_memory, params->priority); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -58051,7 +58051,7 @@ static NTSTATUS thunk32_vkSetDeviceMemoryPriorityEXT(void *args)
TRACE("%#x, 0x%s, %f\n", params->device, wine_dbgstr_longlong(params->memory), params->priority);
- vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkSetDeviceMemoryPriorityEXT(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, wine_device_memory_from_handle(params->memory)->host.device_memory, params->priority); + vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->p_vkSetDeviceMemoryPriorityEXT(vulkan_device_from_handle((VkDevice)UlongToPtr(params->device))->host.device, vulkan_device_memory_from_handle(params->memory)->host.device_memory, params->priority); return STATUS_SUCCESS; }
@@ -58495,7 +58495,7 @@ static NTSTATUS thunk64_vkUnmapMemory(void *args)
TRACE("%p, 0x%s\n", params->device, wine_dbgstr_longlong(params->memory));
- wine_vkUnmapMemory(params->device, params->memory); + vk_funcs->p_vkUnmapMemory(params->device, params->memory); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -58510,7 +58510,7 @@ static NTSTATUS thunk32_vkUnmapMemory(void *args)
TRACE("%#x, 0x%s\n", params->device, wine_dbgstr_longlong(params->memory));
- wine_vkUnmapMemory((VkDevice)UlongToPtr(params->device), params->memory); + vk_funcs->p_vkUnmapMemory((VkDevice)UlongToPtr(params->device), params->memory); return STATUS_SUCCESS; }
@@ -58552,7 +58552,7 @@ static NTSTATUS thunk64_vkUnmapMemory2KHR(void *args)
TRACE("%p, %p\n", params->device, params->pMemoryUnmapInfo);
- params->result = wine_vkUnmapMemory2KHR(params->device, params->pMemoryUnmapInfo); + params->result = vk_funcs->p_vkUnmapMemory2KHR(params->device, params->pMemoryUnmapInfo); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -58570,7 +58570,7 @@ static NTSTATUS thunk32_vkUnmapMemory2KHR(void *args) TRACE("%#x, %#x\n", params->device, params->pMemoryUnmapInfo);
convert_VkMemoryUnmapInfo_win32_to_unwrapped_host((const VkMemoryUnmapInfo32 *)UlongToPtr(params->pMemoryUnmapInfo), &pMemoryUnmapInfo_host); - params->result = wine_vkUnmapMemory2KHR((VkDevice)UlongToPtr(params->device), &pMemoryUnmapInfo_host); + params->result = vk_funcs->p_vkUnmapMemory2KHR((VkDevice)UlongToPtr(params->device), &pMemoryUnmapInfo_host); return STATUS_SUCCESS; }
diff --git a/dlls/winevulkan/vulkan_thunks.h b/dlls/winevulkan/vulkan_thunks.h index 23dbf19424d..4f5abf6cabc 100644 --- a/dlls/winevulkan/vulkan_thunks.h +++ b/dlls/winevulkan/vulkan_thunks.h @@ -22,14 +22,11 @@
/* Functions for which we have custom implementations outside of the thunks. */ VkResult wine_vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers); -VkResult wine_vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory); -VkResult wine_vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer); VkResult wine_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool, void *client_ptr); VkResult wine_vkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback); VkResult wine_vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger); VkResult wine_vkCreateDeferredOperationKHR(VkDevice device, const VkAllocationCallbacks *pAllocator, VkDeferredOperationKHR *pDeferredOperation); VkResult wine_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, void *client_ptr); -VkResult wine_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage); VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, void *client_ptr); void wine_vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator); void wine_vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator); @@ -45,7 +42,6 @@ VkResult wine_vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t *pPh VkResult wine_vkEnumeratePhysicalDeviceGroupsKHR(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties); VkResult wine_vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices); void wine_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers); -void wine_vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator); VkResult wine_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps, uint64_t *pMaxDeviation); VkResult wine_vkGetCalibratedTimestampsKHR(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoKHR *pTimestampInfos, uint64_t *pTimestamps, uint64_t *pMaxDeviation); void wine_vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue); @@ -60,9 +56,5 @@ void wine_vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physic void wine_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties); VkResult wine_vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties); VkResult wine_vkGetPhysicalDeviceImageFormatProperties2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties); -VkResult wine_vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData); -VkResult wine_vkMapMemory2KHR(VkDevice device, const VkMemoryMapInfo *pMemoryMapInfo, void **ppData); -void wine_vkUnmapMemory(VkDevice device, VkDeviceMemory memory); -VkResult wine_vkUnmapMemory2KHR(VkDevice device, const VkMemoryUnmapInfo *pMemoryUnmapInfo);
#endif /* __WINE_VULKAN_THUNKS_H */ diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index b468046a949..c373f639451 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -138,6 +138,16 @@ static inline struct vulkan_queue *vulkan_queue_from_handle( VkQueue handle ) return (struct vulkan_queue *)(UINT_PTR)client->unix_handle; }
+struct vulkan_device_memory +{ + VULKAN_OBJECT_HEADER( VkDeviceMemory, device_memory ); +}; + +static inline struct vulkan_device_memory *vulkan_device_memory_from_handle( VkDeviceMemory handle ) +{ + return (struct vulkan_device_memory *)(UINT_PTR)handle; +} + struct vulkan_surface { VULKAN_OBJECT_HEADER( VkSurfaceKHR, surface ); @@ -167,10 +177,14 @@ struct vulkan_funcs */ PFN_vkAcquireNextImage2KHR p_vkAcquireNextImage2KHR; PFN_vkAcquireNextImageKHR p_vkAcquireNextImageKHR; + PFN_vkAllocateMemory p_vkAllocateMemory; + PFN_vkCreateBuffer p_vkCreateBuffer; + PFN_vkCreateImage p_vkCreateImage; PFN_vkCreateSwapchainKHR p_vkCreateSwapchainKHR; PFN_vkCreateWin32SurfaceKHR p_vkCreateWin32SurfaceKHR; PFN_vkDestroySurfaceKHR p_vkDestroySurfaceKHR; PFN_vkDestroySwapchainKHR p_vkDestroySwapchainKHR; + PFN_vkFreeMemory p_vkFreeMemory; PFN_vkGetDeviceProcAddr p_vkGetDeviceProcAddr; PFN_vkGetInstanceProcAddr p_vkGetInstanceProcAddr; PFN_vkGetPhysicalDevicePresentRectanglesKHR p_vkGetPhysicalDevicePresentRectanglesKHR; @@ -179,7 +193,11 @@ struct vulkan_funcs PFN_vkGetPhysicalDeviceSurfaceFormats2KHR p_vkGetPhysicalDeviceSurfaceFormats2KHR; PFN_vkGetPhysicalDeviceSurfaceFormatsKHR p_vkGetPhysicalDeviceSurfaceFormatsKHR; PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR p_vkGetPhysicalDeviceWin32PresentationSupportKHR; + PFN_vkMapMemory p_vkMapMemory; + PFN_vkMapMemory2KHR p_vkMapMemory2KHR; PFN_vkQueuePresentKHR p_vkQueuePresentKHR; + PFN_vkUnmapMemory p_vkUnmapMemory; + PFN_vkUnmapMemory2KHR p_vkUnmapMemory2KHR;
/* winevulkan specific functions */ const char *(*p_get_host_surface_extension)(void);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/vulkan.c | 126 +++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 58 deletions(-)
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 1c397db76c4..6503b217d1c 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -92,6 +92,71 @@ static inline const void *find_next_struct( const void *head, VkStructureType ty return NULL; }
+static VkResult allocate_external_host_memory( struct vulkan_device *device, VkMemoryAllocateInfo *alloc_info, + VkImportMemoryHostPointerInfoEXT *import_info ) +{ + struct vulkan_physical_device *physical_device = device->physical_device; + VkMemoryHostPointerPropertiesEXT props = + { + .sType = VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT, + }; + uint32_t i, mem_flags, align = physical_device->external_memory_align - 1; + SIZE_T alloc_size = alloc_info->allocationSize; + static int once; + void *mapping; + VkResult res; + + if (!once++) FIXME( "Using VK_EXT_external_memory_host\n" ); + + mem_flags = physical_device->memory_properties.memoryTypes[alloc_info->memoryTypeIndex].propertyFlags; + + if (NtAllocateVirtualMemory( GetCurrentProcess(), &mapping, zero_bits, &alloc_size, MEM_COMMIT, PAGE_READWRITE )) + { + ERR( "NtAllocateVirtualMemory failed\n" ); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + + if ((res = device->p_vkGetMemoryHostPointerPropertiesEXT( device->host.device, VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, + mapping, &props ))) + { + ERR( "vkGetMemoryHostPointerPropertiesEXT failed: %d\n", res ); + return res; + } + + if (!(props.memoryTypeBits & (1u << alloc_info->memoryTypeIndex))) + { + /* If requested memory type is not allowed to use external memory, try to find a supported compatible type. */ + uint32_t mask = mem_flags & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + for (i = 0; i < physical_device->memory_properties.memoryTypeCount; i++) + { + if (!(props.memoryTypeBits & (1u << i))) continue; + if ((physical_device->memory_properties.memoryTypes[i].propertyFlags & mask) != mask) continue; + + TRACE( "Memory type not compatible with host memory, using %u instead\n", i ); + alloc_info->memoryTypeIndex = i; + break; + } + if (i == physical_device->memory_properties.memoryTypeCount) + { + FIXME( "Not found compatible memory type\n" ); + alloc_size = 0; + NtFreeVirtualMemory( GetCurrentProcess(), &mapping, &alloc_size, MEM_RELEASE ); + } + } + + if (props.memoryTypeBits & (1u << alloc_info->memoryTypeIndex)) + { + import_info->sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT; + import_info->handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; + import_info->pHostPointer = mapping; + import_info->pNext = alloc_info->pNext; + alloc_info->pNext = import_info; + alloc_info->allocationSize = (alloc_info->allocationSize + align) & ~align; + } + + return VK_SUCCESS; +} + static VkResult win32u_vkAllocateMemory( VkDevice client_device, const VkMemoryAllocateInfo *alloc_info, const VkAllocationCallbacks *allocator, VkDeviceMemory *ret ) { @@ -109,64 +174,9 @@ static VkResult win32u_vkAllocateMemory( VkDevice client_device, const VkMemoryA /* For host visible memory, we try to use VK_EXT_external_memory_host on wow64 to ensure that mapped pointer is 32-bit. */ mem_flags = physical_device->memory_properties.memoryTypes[alloc_info->memoryTypeIndex].propertyFlags; if (physical_device->external_memory_align && (mem_flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && - !find_next_struct( alloc_info->pNext, VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT )) - { - VkMemoryHostPointerPropertiesEXT props = - { - .sType = VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT, - }; - uint32_t i, align = physical_device->external_memory_align - 1; - SIZE_T alloc_size = info.allocationSize; - static int once; - - if (!once++) FIXME( "Using VK_EXT_external_memory_host\n" ); - - if (NtAllocateVirtualMemory( GetCurrentProcess(), &mapping, zero_bits, &alloc_size, MEM_COMMIT, PAGE_READWRITE )) - { - ERR( "NtAllocateVirtualMemory failed\n" ); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - if ((res = device->p_vkGetMemoryHostPointerPropertiesEXT( device->host.device, VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, - mapping, &props ))) - { - ERR( "vkGetMemoryHostPointerPropertiesEXT failed: %d\n", res ); - return res; - } - - if (!(props.memoryTypeBits & (1u << info.memoryTypeIndex))) - { - /* If requested memory type is not allowed to use external memory, - * try to find a supported compatible type. */ - uint32_t mask = mem_flags & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - for (i = 0; i < physical_device->memory_properties.memoryTypeCount; i++) - { - if (!(props.memoryTypeBits & (1u << i))) continue; - if ((physical_device->memory_properties.memoryTypes[i].propertyFlags & mask) != mask) continue; - - TRACE( "Memory type not compatible with host memory, using %u instead\n", i ); - info.memoryTypeIndex = i; - break; - } - if (i == physical_device->memory_properties.memoryTypeCount) - { - FIXME( "Not found compatible memory type\n" ); - alloc_size = 0; - NtFreeVirtualMemory( GetCurrentProcess(), &mapping, &alloc_size, MEM_RELEASE ); - } - } - - if (props.memoryTypeBits & (1u << info.memoryTypeIndex)) - { - host_pointer_info.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT; - host_pointer_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT; - host_pointer_info.pHostPointer = mapping; - host_pointer_info.pNext = info.pNext; - info.pNext = &host_pointer_info; - - info.allocationSize = (info.allocationSize + align) & ~align; - } - } + !find_next_struct( alloc_info->pNext, VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT ) && + (res = allocate_external_host_memory( device, &info, &host_pointer_info ))) + return res;
if (!(memory = malloc( sizeof(*memory) ))) return VK_ERROR_OUT_OF_HOST_MEMORY; if ((res = device->p_vkAllocateMemory( device->host.device, &info, NULL, &host_device_memory )))