gpu: Improve memory handling on Vulkan

We now handle the case where memory is not HOST_CACHED.

We also track the memory type now so we can avoid mapping image memory
that is not HOST_CACHED and use buffer transfers instead.
This commit is contained in:
Benjamin Otte
2023-11-06 04:31:24 +01:00
parent e8fb0e71c9
commit a5c7339920
3 changed files with 7 additions and 2 deletions

View File

@@ -746,6 +746,9 @@ gsk_vulkan_image_can_map (GskVulkanImage *self)
self->vk_image_layout != VK_IMAGE_LAYOUT_GENERAL)
return FALSE;
if ((self->allocation.memory_flags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) == 0)
return FALSE;
return self->allocation.map != NULL;
}

View File

@@ -57,6 +57,7 @@ gsk_vulkan_direct_allocator_alloc (GskVulkanAllocator *allocator,
alloc->offset = 0;
alloc->size = size;
alloc->memory_flags = self->vk_memory_type.propertyFlags;
}
static void
@@ -398,6 +399,7 @@ gsk_vulkan_external_allocator_alloc (GskVulkanAllocator *allocator,
alloc->map = NULL;
alloc->offset = 0;
alloc->size = size;
alloc->memory_flags = 0;
}
static void

View File

@@ -5,8 +5,7 @@
G_BEGIN_DECLS
#define GSK_VULKAN_MEMORY_MAPPABLE (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | \
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | \
VK_MEMORY_PROPERTY_HOST_CACHED_BIT)
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
typedef struct _GskVulkanAllocator GskVulkanAllocator;
typedef struct _GskVulkanAllocation GskVulkanAllocation;
@@ -18,6 +17,7 @@ struct _GskVulkanAllocation
guchar *map;
VkDeviceSize offset;
VkDeviceSize size;
VkMemoryPropertyFlags memory_flags;
};
struct _GskVulkanAllocator