Commit bbdad747 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winevulkan: Wrap VkDeviceMemory.

parent 60085e46
......@@ -209,7 +209,10 @@ FUNCTION_OVERRIDES = {
"vkGetDeviceProcAddr" : {"dispatch" : False, "driver" : True, "thunk" : ThunkType.NONE, "loader_thunk" : ThunkType.NONE},
"vkGetDeviceQueue" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE},
"vkGetDeviceQueue2" : {"dispatch": True, "driver" : False, "thunk" : ThunkType.NONE},
"vkAllocateMemory" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.PRIVATE},
"vkFreeMemory" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.PRIVATE},
"vkMapMemory" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.PRIVATE},
"vkUnmapMemory" : {"dispatch" : True, "driver" : False, "thunk" : ThunkType.PRIVATE},
# VK_KHR_surface
"vkDestroySurfaceKHR" : {"dispatch" : True, "driver" : True, "thunk" : ThunkType.NONE},
......@@ -1079,6 +1082,8 @@ class VkHandle(object):
return "wine_device_from_handle({0})->device".format(name)
if self.name == "VkInstance":
return "wine_instance_from_handle({0})->instance".format(name)
if self.name == "VkDeviceMemory":
return "wine_device_memory_from_handle({0})->memory".format(name)
if self.name == "VkPhysicalDevice":
return "wine_phys_dev_from_handle({0})->phys_dev".format(name)
if self.name == "VkQueue":
......
......@@ -1441,19 +1441,54 @@ void wine_vkDestroySurfaceKHR(VkInstance handle, VkSurfaceKHR surface,
free(object);
}
VkResult wine_vkMapMemory(VkDevice handle, VkDeviceMemory memory, VkDeviceSize offset,
VkResult wine_vkAllocateMemory(VkDevice handle, const VkMemoryAllocateInfo *alloc_info,
const VkAllocationCallbacks *allocator, VkDeviceMemory *ret)
{
struct wine_device *device = wine_device_from_handle(handle);
struct wine_device_memory *memory;
VkResult result;
if (!(memory = malloc(sizeof(*memory))))
return VK_ERROR_OUT_OF_HOST_MEMORY;
result = device->funcs.p_vkAllocateMemory(device->device, alloc_info, NULL, &memory->memory);
if (result != VK_SUCCESS)
{
free(memory);
return result;
}
*ret = (VkDeviceMemory)(uintptr_t)memory;
return VK_SUCCESS;
}
void wine_vkFreeMemory(VkDevice handle, VkDeviceMemory memory_handle, const VkAllocationCallbacks *allocator)
{
struct wine_device *device = wine_device_from_handle(handle);
struct wine_device_memory *memory;
if (!memory_handle)
return;
memory = wine_device_memory_from_handle(memory_handle);
device->funcs.p_vkFreeMemory(device->device, memory->memory, NULL);
free(memory);
}
VkResult wine_vkMapMemory(VkDevice handle, VkDeviceMemory memory_handle, VkDeviceSize offset,
VkDeviceSize size, VkMemoryMapFlags flags, void **data)
{
struct wine_device *device = wine_device_from_handle(handle);
struct wine_device_memory *memory = wine_device_memory_from_handle(memory_handle);
VkResult result;
result = device->funcs.p_vkMapMemory(device->device, memory, offset, size, flags, data);
result = device->funcs.p_vkMapMemory(device->device, memory->memory, offset, size, flags, data);
#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->funcs.p_vkUnmapMemory(device->device, memory);
device->funcs.p_vkUnmapMemory(device->device, memory->memory);
*data = NULL;
result = VK_ERROR_OUT_OF_HOST_MEMORY;
}
......@@ -1462,6 +1497,14 @@ VkResult wine_vkMapMemory(VkDevice handle, VkDeviceMemory memory, VkDeviceSize o
return result;
}
void wine_vkUnmapMemory(VkDevice handle, VkDeviceMemory memory_handle)
{
struct wine_device *device = wine_device_from_handle(handle);
struct wine_device_memory *memory = wine_device_memory_from_handle(memory_handle);
device->funcs.p_vkUnmapMemory(device->device, memory->memory);
}
static inline void adjust_max_image_count(struct wine_phys_dev *phys_dev, VkSurfaceCapabilitiesKHR* capabilities)
{
/* Many Windows games, for example Strange Brigade, No Man's Sky, Path of Exile
......
......@@ -169,6 +169,16 @@ static inline struct wine_cmd_pool *wine_cmd_pool_from_handle(VkCommandPool hand
return (struct wine_cmd_pool *)(uintptr_t)client_ptr->unix_handle;
}
struct wine_device_memory
{
VkDeviceMemory memory;
};
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
{
struct wine_instance *instance; /* parent */
......
......@@ -16,6 +16,7 @@
/* Functions for which we have custom implementations outside of the thunks. */
VkResult wine_vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers) DECLSPEC_HIDDEN;
VkResult wine_vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory) DECLSPEC_HIDDEN;
VkResult wine_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool, void *client_ptr) DECLSPEC_HIDDEN;
VkResult wine_vkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) DECLSPEC_HIDDEN;
VkResult wine_vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger) DECLSPEC_HIDDEN;
......@@ -36,6 +37,7 @@ VkResult wine_vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t *pPh
VkResult wine_vkEnumeratePhysicalDeviceGroupsKHR(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties) DECLSPEC_HIDDEN;
VkResult wine_vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices) DECLSPEC_HIDDEN;
void wine_vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) DECLSPEC_HIDDEN;
void wine_vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator) DECLSPEC_HIDDEN;
VkResult wine_vkGetCalibratedTimestampsEXT(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoEXT *pTimestampInfos, uint64_t *pTimestamps, uint64_t *pMaxDeviation) DECLSPEC_HIDDEN;
void wine_vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) DECLSPEC_HIDDEN;
void wine_vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) DECLSPEC_HIDDEN;
......@@ -51,6 +53,7 @@ VkResult wine_vkGetPhysicalDeviceImageFormatProperties2KHR(VkPhysicalDevice phys
VkResult wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, VkSurfaceCapabilities2KHR *pSurfaceCapabilities) DECLSPEC_HIDDEN;
VkResult wine_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) DECLSPEC_HIDDEN;
VkResult wine_vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData) DECLSPEC_HIDDEN;
void wine_vkUnmapMemory(VkDevice device, VkDeviceMemory memory) DECLSPEC_HIDDEN;
/* For use by vkDevice and children */
struct vulkan_device_funcs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment