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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user