mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 21:21:12 +00:00
vulkan: memory: Flush non coherent memory after write.
Spec 7.1.3: If a memory object does not have the VK_MEMORY_PROPERTY_HOST_COHERENT_BIT property, then vkFlushMappedMemoryRanges must be called in order to guarantee that writes to the memory object from the host are made available to the host domain, where they can be further made available to the device domain via a domain operation. Similarly, vkInvalidateMappedMemoryRanges must be called to guarantee that writes which are available to the host domain are made visible to host operations. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3723>
This commit is contained in:
parent
621feb32e9
commit
e54d334526
1 changed files with 21 additions and 0 deletions
|
@ -142,6 +142,27 @@ _vk_mem_map_full (GstVulkanMemory * mem, GstMapInfo * info, gsize size)
|
||||||
static void
|
static void
|
||||||
_vk_mem_unmap_full (GstVulkanMemory * mem, GstMapInfo * info)
|
_vk_mem_unmap_full (GstVulkanMemory * mem, GstMapInfo * info)
|
||||||
{
|
{
|
||||||
|
if ((info->flags & GST_MAP_WRITE)
|
||||||
|
&& !(mem->properties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
|
||||||
|
GError *error = NULL;
|
||||||
|
VkResult err;
|
||||||
|
VkMappedMemoryRange range = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
|
||||||
|
/* .pNext = */
|
||||||
|
.memory = mem->mem_ptr,
|
||||||
|
.offset = mem->vk_offset,
|
||||||
|
.size = mem->mem.size,
|
||||||
|
};
|
||||||
|
|
||||||
|
err = vkFlushMappedMemoryRanges (mem->device->device, 1u, &range);
|
||||||
|
if (gst_vulkan_error_to_g_error (err, &error,
|
||||||
|
"vkFlushMappedMemoryRanges") < 0) {
|
||||||
|
GST_CAT_WARNING (GST_CAT_VULKAN_MEMORY, "Failed to flush memory: %s",
|
||||||
|
error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vkUnmapMemory (mem->device->device, mem->mem_ptr);
|
vkUnmapMemory (mem->device->device, mem->mem_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue