Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/adapter_vk.c | 11 +++++++++++ dlls/wined3d/context_vk.c | 8 ++++++-- dlls/wined3d/wined3d_private.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index a5900b29e59..a015963ee67 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -496,6 +496,7 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context, struct wined3d_device_vk *device_vk; VkCommandBuffer vk_command_buffer; VkBufferMemoryBarrier vk_barrier; + VkMappedMemoryRange range; struct wined3d_bo_vk *bo; void *map_ptr; VkResult vr; @@ -525,6 +526,16 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context, vk_barrier.size = size; VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_HOST_BIT, 0, 0, NULL, 1, &vk_barrier, 0, NULL)); + + if (!(bo->memory_type & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) + { + range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; + range.pNext = NULL; + range.memory = bo->vk_memory; + range.offset = (uintptr_t)data->addr; + range.size = size; + VK_CALL(vkInvalidateMappedMemoryRanges(device_vk->vk_device, 1, &range)); + } }
wined3d_context_vk_submit_command_buffer(context_vk); diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index 84e701543f1..b0e65231f25 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -38,6 +38,7 @@ BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDevic struct wined3d_adapter_vk *adapter_vk; VkMemoryAllocateInfo allocate_info; VkBufferCreateInfo create_info; + unsigned int memory_type_idx; VkResult vr;
adapter_vk = wined3d_adapter_vk(device_vk->d.adapter); @@ -62,14 +63,15 @@ BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDevic allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocate_info.pNext = NULL; allocate_info.allocationSize = memory_requirements.size; - allocate_info.memoryTypeIndex = wined3d_adapter_vk_get_memory_type_index(adapter_vk, + memory_type_idx = wined3d_adapter_vk_get_memory_type_index(adapter_vk, memory_requirements.memoryTypeBits, memory_type); - if (allocate_info.memoryTypeIndex == ~0u) + if (memory_type_idx == ~0u) { ERR("Failed to find suitable memory type.\n"); VK_CALL(vkDestroyBuffer(device_vk->vk_device, bo->vk_buffer, NULL)); return FALSE; } + allocate_info.memoryTypeIndex = memory_type_idx; if ((vr = VK_CALL(vkAllocateMemory(device_vk->vk_device, &allocate_info, NULL, &bo->vk_memory))) < 0) { ERR("Failed to allocate buffer memory, vr %s.\n", wined3d_debug_vkresult(vr)); @@ -85,6 +87,8 @@ BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDevic return FALSE; }
+ bo->memory_type = adapter_vk->memory_properties.memoryTypes[memory_type_idx].propertyFlags; + return TRUE; }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index c2fde81e641..55243050b03 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1521,6 +1521,8 @@ struct wined3d_bo_vk { VkBuffer vk_buffer; VkDeviceMemory vk_memory; + + VkMemoryPropertyFlags memory_type; };
struct wined3d_bo_address