Commit 7130230d authored by Matthew Waters's avatar Matthew Waters 🐨
Browse files

memory: provide a mem_unmap function that takes the flags to unmap

There are gstmemory's available that operate in two memory domains
and need to ensure consistent access between these domains.

Imagine a scenario where e.g. the GLMemory is mapped twice in both
the GPU and the CPU domain.  On unmap or a subsequent map, it would
like to ensure that the most recent data is available in the memory
domain requested.  Either by flushing the writes and/or initiating a
DMA transfer.  Without knowing which domain is being unmapped, the
memory does not know where the most recent data is to transfer to
the other memory domain.

Note: this still does not allow downgrading a memory map.

https://bugzilla.gnome.org/show_bug.cgi?id=750319
parent e9c15d53
......@@ -97,6 +97,8 @@ typedef enum {
* @mem_copy: the implementation of the GstMemoryCopyFunction
* @mem_share: the implementation of the GstMemoryShareFunction
* @mem_is_span: the implementation of the GstMemoryIsSpanFunction
* @mem_unmap_full: the implementation of the GstMemoryUnmapFullFunction.
* Will be used instead of @mem_unmap if present. Since 1.6
*
* The #GstAllocator is used to create new memory.
*/
......@@ -104,18 +106,20 @@ struct _GstAllocator
{
GstObject object;
const gchar *mem_type;
const gchar *mem_type;
/*< public >*/
GstMemoryMapFunction mem_map;
GstMemoryUnmapFunction mem_unmap;
GstMemoryMapFunction mem_map;
GstMemoryUnmapFunction mem_unmap;
GstMemoryCopyFunction mem_copy;
GstMemoryShareFunction mem_share;
GstMemoryIsSpanFunction mem_is_span;
GstMemoryCopyFunction mem_copy;
GstMemoryShareFunction mem_share;
GstMemoryIsSpanFunction mem_is_span;
GstMemoryUnmapFullFunction mem_unmap_full;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
gpointer _gst_reserved[GST_PADDING - 1];
GstAllocatorPrivate *priv;
};
......
......@@ -338,7 +338,10 @@ gst_memory_unmap (GstMemory * mem, GstMapInfo * info)
g_return_if_fail (info != NULL);
g_return_if_fail (info->memory == mem);
mem->allocator->mem_unmap (mem);
if (mem->allocator->mem_unmap_full)
mem->allocator->mem_unmap_full (mem, info->flags);
else
mem->allocator->mem_unmap (mem);
gst_memory_unlock (mem, (GstLockFlags) info->flags);
}
......
......@@ -237,11 +237,18 @@ typedef gpointer (*GstMemoryMapFunction) (GstMemory *mem, gsize maxsize
* @mem: a #GstMemory
*
* Return the pointer previously retrieved with gst_memory_map().
*
* Returns: %TRUE on success.
*/
typedef void (*GstMemoryUnmapFunction) (GstMemory *mem);
/**
* GstMemoryUnmapFullFunction:
* @mem: a #GstMemory
* @flags: a #GstMapFlags
*
* Return the pointer previously retrieved with gst_memory_map() with @flags.
*/
typedef void (*GstMemoryUnmapFullFunction) (GstMemory *mem, GstMapFlags flags);
/**
* GstMemoryCopyFunction:
* @mem: a #GstMemory
......
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