glmemory: implement on top of glbasebuffer

Provides convenient access to PBO usage.

Currently texture updates are coupled tightly to data transfers.
This commit is contained in:
Matthew Waters 2015-06-10 16:36:15 +10:00 committed by Tim-Philipp Müller
parent 1e87053475
commit 900bcea9de
9 changed files with 469 additions and 568 deletions

View File

@ -214,7 +214,7 @@ gst_gl_base_buffer_cpu_access (GstGLBaseBuffer * mem,
data = gl->MapBufferRange (mem->target, 0, size, gl_map_flags); data = gl->MapBufferRange (mem->target, 0, size, gl_map_flags);
if (data) if (data)
memcpy (data, mem->data, size); memcpy (mem->data, data, size);
gl->UnmapBuffer (mem->target); gl->UnmapBuffer (mem->target);
ret = mem->data; ret = mem->data;

View File

@ -70,13 +70,8 @@ typedef enum
* GstGLBaseBuffer: * GstGLBaseBuffer:
* @mem: the parent object * @mem: the parent object
* @context: the #GstGLContext to use for GL operations * @context: the #GstGLContext to use for GL operations
* @tex_id: the texture id for this memory * @id: the buffer id for this memory
* @v_format: the video format of this texture * @target: the GL target of this texture for binding purposes
* @gl_format: the format of the texture
* @width: width of the texture
* @height: height of the texture
* @download: the object used to download this texture into @v_format
* @upload: the object used to upload this texture from @v_format
* *
* Represents information about a GL buffer * Represents information about a GL buffer
*/ */
@ -89,16 +84,15 @@ struct _GstGLBaseBuffer
guint target; guint target;
/* <protected> */ /* <protected> */
GstMapFlags map_flags; /* cumulative map flags */
GMutex lock; GMutex lock;
GstMapFlags map_flags; /* cumulative map flags */
gint map_count; gint map_count;
gint gl_map_count; gint gl_map_count;
gpointer data; gpointer data;
/* <private> */
gpointer alloc_data; gpointer alloc_data;
gpointer impl;
}; };
typedef gboolean (*GstGLBaseBufferAllocatorCreateFunction) (GstGLBaseBuffer * buffer, GError ** error); typedef gboolean (*GstGLBaseBufferAllocatorCreateFunction) (GstGLBaseBuffer * buffer, GError ** error);

View File

@ -114,6 +114,7 @@ gst_gl_display_init (GstGLDisplay * display)
GST_TRACE ("init %p", display); GST_TRACE ("init %p", display);
gst_gl_base_buffer_init_once ();
gst_gl_memory_init (); gst_gl_memory_init ();
#if GST_GL_HAVE_PLATFORM_EGL #if GST_GL_HAVE_PLATFORM_EGL

View File

@ -413,17 +413,16 @@ _do_download (GstGLDownload * download, GstBuffer * inbuf)
for (i = 0; i < out_planes; i++) { for (i = 0; i < out_planes; i++) {
GstMemory *out_mem = gst_buffer_peek_memory (outbuf, i); GstMemory *out_mem = gst_buffer_peek_memory (outbuf, i);
gpointer temp_data = ((GstGLMemory *) out_mem)->data; gpointer temp_data = ((GstGLBaseBuffer *) out_mem)->data;
((GstGLMemory *) out_mem)->data = data[i]; ((GstGLBaseBuffer *) out_mem)->data = data[i];
gst_gl_memory_download_transfer ((GstGLMemory *) out_mem);
if (!gst_memory_map (out_mem, &map_info, GST_MAP_READ)) { if (!gst_memory_map (out_mem, &map_info, GST_MAP_READ)) {
GST_ERROR_OBJECT (download, "Failed to map memory"); GST_ERROR_OBJECT (download, "Failed to map memory");
ret = FALSE; ret = FALSE;
} }
gst_memory_unmap (out_mem, &map_info); gst_memory_unmap (out_mem, &map_info);
((GstGLMemory *) out_mem)->data = temp_data; ((GstGLBaseBuffer *) out_mem)->data = temp_data;
GST_MINI_OBJECT_FLAG_SET (out_mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
} }
gst_buffer_unref (outbuf); gst_buffer_unref (outbuf);

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@
#include <gst/gstmemory.h> #include <gst/gstmemory.h>
#include <gst/video/video.h> #include <gst/video/video.h>
#include <gst/gl/gstglbasebuffer.h>
#include <gst/gl/gl.h> #include <gst/gl/gl.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -40,49 +41,24 @@ GType gst_gl_allocator_get_type(void);
#define GST_GL_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_ALLOCATOR, GstGLAllocatorClass)) #define GST_GL_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_GL_ALLOCATOR, GstGLAllocatorClass))
#define GST_GL_ALLOCATOR_CAST(obj) ((GstGLAllocator *)(obj)) #define GST_GL_ALLOCATOR_CAST(obj) ((GstGLAllocator *)(obj))
/**
* GstGLMemoryFlags:
*
* Flags indicating the current state of a #GstGLMemory
*/
typedef enum
{
GST_GL_MEMORY_FLAG_DOWNLOAD_INITTED = (GST_MEMORY_FLAG_LAST << 0),
GST_GL_MEMORY_FLAG_UPLOAD_INITTED = (GST_MEMORY_FLAG_LAST << 1),
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD = (GST_MEMORY_FLAG_LAST << 2),
GST_GL_MEMORY_FLAG_NEED_UPLOAD = (GST_MEMORY_FLAG_LAST << 3)
} GstGLMemoryFlags;
/**
* GST_MAP_GL:
*
* Flag indicating that we should map the GL object instead of to system memory.
*
* Combining #GST_MAP_GL with #GST_MAP_WRITE has the same semantics as though
* you are writing to OpenGL. Conversely, combining #GST_MAP_GL with
* #GST_MAP_READ has the same semantics as though you are reading from OpenGL.
*/
#define GST_MAP_GL GST_MAP_FLAG_LAST << 1
/** /**
* GstGLMemory: * GstGLMemory:
* @mem: the parent object * @mem: the parent object
* @context: the #GstGLContext to use for GL operations * @context: the #GstGLContext to use for GL operations
* @tex_id: the texture id for this memory * @tex_id: the GL texture id for this memory
* @v_format: the video format of this texture * @tex_target: the GL texture target for this memory
* @gl_format: the format of the texture * @tex_type: the texture type
* @width: width of the texture * @info: the texture's #GstVideoInfo
* @height: height of the texture * @valign: data alignment for system memory mapping
* @download: the object used to download this texture into @v_format * @plane: data plane in @info
* @upload: the object used to upload this texture from @v_format * @tex_scaling: GL shader scaling parameters for @valign and/or width/height
* *
* Represents information about a GL texture * Represents information about a GL texture
*/ */
struct _GstGLMemory struct _GstGLMemory
{ {
GstMemory mem; GstGLBaseBuffer mem;
GstGLContext *context;
guint tex_id; guint tex_id;
guint tex_target; guint tex_target;
GstVideoGLTextureType tex_type; GstVideoGLTextureType tex_type;
@ -92,20 +68,11 @@ struct _GstGLMemory
gfloat tex_scaling[2]; gfloat tex_scaling[2];
/* <private> */ /* <private> */
gpointer alloc_data;
gpointer data;
gboolean texture_wrapped; gboolean texture_wrapped;
GDestroyNotify notify; GDestroyNotify notify;
gpointer user_data; gpointer user_data;
guint pbo;
guint unpack_length; guint unpack_length;
guint tex_width; guint tex_width;
guint transfer_pbo;
GstMapFlags map_flags;
guint map_count;
GMutex lock;
}; };
#define GST_CAPS_FEATURE_MEMORY_GL_MEMORY "memory:GLMemory" #define GST_CAPS_FEATURE_MEMORY_GL_MEMORY "memory:GLMemory"
@ -117,71 +84,57 @@ struct _GstGLMemory
/** /**
* GST_GL_MEMORY_ALLOCATOR: * GST_GL_MEMORY_ALLOCATOR:
* *
* The name of the GL memore allocator * The name of the GL memory allocator
*/ */
#define GST_GL_MEMORY_ALLOCATOR "GLMemory" #define GST_GL_MEMORY_ALLOCATOR "GLMemory"
/**
* GST_GL_MEMORY_FLAGS:
* @mem: a #GstGLMemory
*
* Get the currently set flags on @mem
*/
#define GST_GL_MEMORY_FLAGS(mem) GST_MEMORY_FLAGS(mem)
/**
* GST_GL_MEMORY_FLAG_IS_SET:
* @mem: a #GstGLMemory
* @flag: a flag
*
* Whether @flag is set on @mem
*/
#define GST_GL_MEMORY_FLAG_IS_SET(mem,flag) GST_MEMORY_FLAG_IS_SET(mem,flag)
/**
* GST_GL_MEMORY_FLAG_SET:
* @mem: a #GstGLMemory
* @flag: a flag
*
* Set @flag on @mem
*/
#define GST_GL_MEMORY_FLAG_SET(mem,flag) GST_MINI_OBJECT_FLAG_SET(mem,flag)
/**
* GST_GL_MEMORY_FLAG_UNSET:
* @mem: a #GstGLMemory
* @flag: a flag
*
* Unset @flag on @mem
*/
#define GST_GL_MEMORY_FLAG_UNSET(mem,flag) GST_MEMORY_FLAG_UNSET(mem,flag)
void gst_gl_memory_init (void); void gst_gl_memory_init (void);
gboolean gst_is_gl_memory (GstMemory * mem); gboolean gst_is_gl_memory (GstMemory * mem);
GstMemory * gst_gl_memory_alloc (GstGLContext * context, GstAllocationParams *params, GstMemory * gst_gl_memory_alloc (GstGLContext * context,
GstVideoInfo * info, guint plane, GstVideoAlignment *valign); GstAllocationParams *params,
GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context, GstVideoInfo * info, guint plane, GstVideoInfo * info,
GstVideoAlignment *valign, gpointer data, guint plane,
gpointer user_data, GDestroyNotify notify); GstVideoAlignment *valign);
GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context, guint texture_id, guint texture_target, GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context,
GstVideoInfo * info, guint plane, GstVideoAlignment *valign, GstVideoInfo * info,
gpointer user_data, GDestroyNotify notify); guint plane,
GstVideoAlignment *valign,
gpointer data,
gpointer user_data,
GDestroyNotify notify);
GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context,
guint texture_id,
guint texture_target,
GstVideoInfo * info,
guint plane,
GstVideoAlignment *valign,
gpointer user_data,
GDestroyNotify notify);
gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem, guint tex_id, gboolean gst_gl_memory_copy_into_texture (GstGLMemory *gl_mem,
guint tex_id,
GstVideoGLTextureType tex_type, GstVideoGLTextureType tex_type,
gint width, gint height, gint stride, gint width,
gint height,
gint stride,
gboolean respecify); gboolean respecify);
gboolean gst_gl_memory_setup_buffer (GstGLContext * context, GstAllocationParams * params, gboolean gst_gl_memory_setup_buffer (GstGLContext * context,
GstVideoInfo * info, GstVideoAlignment *valign, GstBuffer * buffer); GstAllocationParams * params,
gboolean gst_gl_memory_setup_wrapped (GstGLContext * context, GstVideoInfo * info, GstVideoAlignment *valign, GstVideoInfo * info,
GstVideoAlignment *valign,
GstBuffer * buffer);
gboolean gst_gl_memory_setup_wrapped (GstGLContext * context,
GstVideoInfo * info,
GstVideoAlignment *valign,
gpointer data[GST_VIDEO_MAX_PLANES], gpointer data[GST_VIDEO_MAX_PLANES],
GstGLMemory *textures[GST_VIDEO_MAX_PLANES]); GstGLMemory *textures[GST_VIDEO_MAX_PLANES]);
gint gst_gl_memory_get_texture_width (GstGLMemory * gl_mem); gint gst_gl_memory_get_texture_width (GstGLMemory * gl_mem);
gint gst_gl_memory_get_texture_height (GstGLMemory * gl_mem); gint gst_gl_memory_get_texture_height (GstGLMemory * gl_mem);
/* utility functions */
GstVideoGLTextureType gst_gl_texture_type_from_format (GstGLContext *context, GstVideoGLTextureType gst_gl_texture_type_from_format (GstGLContext *context,
GstVideoFormat v_format, GstVideoFormat v_format,
guint plane); guint plane);
@ -190,8 +143,6 @@ guint gst_gl_sized_gl_format_from_gl_format_type (GstGLContext *
guint format, guint format,
guint type); guint type);
void gst_gl_memory_download_transfer (GstGLMemory * gl_mem);
/** /**
* GstGLAllocator * GstGLAllocator
* *
@ -199,7 +150,7 @@ void gst_gl_memory_download_transfer (GstGLMemory * gl_mem);
*/ */
struct _GstGLAllocator struct _GstGLAllocator
{ {
GstAllocator parent; GstGLBaseBufferAllocator parent;
GstMemoryCopyFunction fallback_mem_copy; GstMemoryCopyFunction fallback_mem_copy;
}; };
@ -210,7 +161,7 @@ struct _GstGLAllocator
*/ */
struct _GstGLAllocatorClass struct _GstGLAllocatorClass
{ {
GstAllocatorClass parent_class; GstGLBaseBufferAllocatorClass parent_class;
}; };
G_END_DECLS G_END_DECLS

View File

@ -266,7 +266,8 @@ _gl_memory_upload_perform (gpointer impl, GstBuffer * buffer,
GstMemory *mem = gst_buffer_peek_memory (buffer, i); GstMemory *mem = gst_buffer_peek_memory (buffer, i);
gl_mem = (GstGLMemory *) mem; gl_mem = (GstGLMemory *) mem;
if (!gst_gl_context_can_share (upload->upload->context, gl_mem->context)) if (!gst_gl_context_can_share (upload->upload->context,
gl_mem->mem.context))
return GST_GL_UPLOAD_UNSHARED_GL_CONTEXT; return GST_GL_UPLOAD_UNSHARED_GL_CONTEXT;
} }
@ -434,8 +435,8 @@ _egl_image_upload_perform_gl_thread (GstGLContext * context,
} }
if (GST_IS_GL_BUFFER_POOL (image->buffer->pool)) if (GST_IS_GL_BUFFER_POOL (image->buffer->pool))
gst_gl_buffer_pool_replace_last_buffer (GST_GL_BUFFER_POOL (image->buffer-> gst_gl_buffer_pool_replace_last_buffer (GST_GL_BUFFER_POOL (image->
pool), image->buffer); buffer->pool), image->buffer);
} }
static GstGLUploadReturn static GstGLUploadReturn
@ -581,11 +582,11 @@ _upload_meta_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
gpointer handle; gpointer handle;
gl_apis = gl_apis =
gst_gl_api_to_string (gst_gl_context_get_gl_api (upload-> gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
upload->context)); context));
platform = platform =
gst_gl_platform_to_string (gst_gl_context_get_gl_platform gst_gl_platform_to_string (gst_gl_context_get_gl_platform (upload->
(upload->upload->context)); upload->context));
handle = (gpointer) gst_gl_context_get_gl_context (upload->upload->context); handle = (gpointer) gst_gl_context_get_gl_context (upload->upload->context);
gl_context = gl_context =
@ -791,13 +792,6 @@ _raw_data_upload_perform (gpointer impl, GstBuffer * buffer,
gst_gl_memory_setup_wrapped (raw->upload->context, gst_gl_memory_setup_wrapped (raw->upload->context,
&raw->upload->priv->in_info, NULL, raw->in_frame.data, in_tex); &raw->upload->priv->in_info, NULL, raw->in_frame.data, in_tex);
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
if (in_tex[i]) {
in_tex[i]->data = raw->in_frame.data[i];
GST_GL_MEMORY_FLAG_SET (in_tex[i], GST_GL_MEMORY_FLAG_NEED_UPLOAD);
}
}
*outbuf = gst_buffer_new (); *outbuf = gst_buffer_new ();
for (i = 0; i < max_planes; i++) { for (i = 0; i < max_planes; i++) {
gst_buffer_append_memory (*outbuf, (GstMemory *) in_tex[i]); gst_buffer_append_memory (*outbuf, (GstMemory *) in_tex[i]);

View File

@ -205,7 +205,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++) { for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->info); i++) {
GstGLMemory *in_mem = upload->priv->in_tex[i]; GstGLMemory *in_mem = upload->priv->in_tex[i];
if (GST_GL_MEMORY_FLAG_IS_SET (in_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD)) { if (GST_MEMORY_FLAG_IS_SET (in_mem, GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD)) {
GstMapInfo map_info; GstMapInfo map_info;
guint tex_id; guint tex_id;
@ -219,7 +219,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
gst_memory_unmap ((GstMemory *) in_mem, &map_info); gst_memory_unmap ((GstMemory *) in_mem, &map_info);
in_mem->tex_id = tex_id; in_mem->tex_id = tex_id;
GST_GL_MEMORY_FLAG_SET (in_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD); GST_MINI_OBJECT_FLAG_SET (in_mem, GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD);
} else { } else {
GstGLMemory *out_mem; GstGLMemory *out_mem;
gint mem_width, mem_height; gint mem_width, mem_height;
@ -234,7 +234,7 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta *
if (out_mem->tex_id != texture_id[i]) { if (out_mem->tex_id != texture_id[i]) {
out_mem->tex_id = texture_id[i]; out_mem->tex_id = texture_id[i];
GST_GL_MEMORY_FLAG_SET (out_mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD); GST_MINI_OBJECT_FLAG_SET (out_mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
} }
mem_width = gst_gl_memory_get_texture_width (out_mem); mem_width = gst_gl_memory_get_texture_width (out_mem);
@ -262,8 +262,6 @@ _perform_with_data_unlocked (GstGLUploadMeta * upload,
if (!upload->priv->in_tex[i]) if (!upload->priv->in_tex[i])
upload->priv->in_tex[i] = gst_gl_memory_wrapped (upload->context, upload->priv->in_tex[i] = gst_gl_memory_wrapped (upload->context,
&upload->info, i, NULL, data[i], NULL, NULL); &upload->info, i, NULL, data[i], NULL, NULL);
upload->priv->in_tex[i]->data = data[i];
} }
return _perform_with_gl_memory (upload, meta, texture_id); return _perform_with_gl_memory (upload, meta, texture_id);

View File

@ -79,7 +79,7 @@ GST_START_TEST (test_basic)
/* test init params */ /* test init params */
fail_if (gst_video_info_is_equal (&v_info, &gl_mem->info) == FALSE); fail_if (gst_video_info_is_equal (&v_info, &gl_mem->info) == FALSE);
fail_if (gl_mem->context != context); fail_if (gl_mem->mem.context != context);
fail_if (gl_mem->tex_id == 0); fail_if (gl_mem->tex_id == 0);
/* copy the memory */ /* copy the memory */
@ -90,7 +90,7 @@ GST_START_TEST (test_basic)
/* test params */ /* test params */
fail_if (gst_video_info_is_equal (&gl_mem2->info, fail_if (gst_video_info_is_equal (&gl_mem2->info,
&gl_mem->info) == FALSE); &gl_mem->info) == FALSE);
fail_if (gl_mem->context != gl_mem2->context); fail_if (gl_mem->mem.context != gl_mem2->mem.context);
if (gst_gl_context_get_error ()) if (gst_gl_context_get_error ())
printf ("%s\n", gst_gl_context_get_error ()); printf ("%s\n", gst_gl_context_get_error ());
@ -125,10 +125,10 @@ GST_START_TEST (test_transfer)
/* texture creation */ /* texture creation */
mem = (GstMemory *) gst_gl_memory_alloc (context, NULL, &v_info, 0, NULL); mem = (GstMemory *) gst_gl_memory_alloc (context, NULL, &v_info, 0, NULL);
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
/* test wrapping raw data */ /* test wrapping raw data */
mem2 = mem2 =
@ -136,27 +136,27 @@ GST_START_TEST (test_transfer)
rgba_pixel, NULL, NULL); rgba_pixel, NULL, NULL);
fail_if (mem == NULL); fail_if (mem == NULL);
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
/* wrapped texture creation */ /* wrapped texture creation */
mem3 = (GstMemory *) gst_gl_memory_wrapped_texture (context, mem3 = (GstMemory *) gst_gl_memory_wrapped_texture (context,
((GstGLMemory *) mem)->tex_id, GL_TEXTURE_2D, &v_info, 0, NULL, NULL, ((GstGLMemory *) mem)->tex_id, GL_TEXTURE_2D, &v_info, 0, NULL, NULL,
NULL); NULL);
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem3, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem3, fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
/* check data/flags are correct */ /* check data/flags are correct */
fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ)); fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ));
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
fail_unless (((gchar *) map_info.data)[0] == rgba_pixel[0]); fail_unless (((gchar *) map_info.data)[0] == rgba_pixel[0]);
fail_unless (((gchar *) map_info.data)[1] == rgba_pixel[1]); fail_unless (((gchar *) map_info.data)[1] == rgba_pixel[1]);
@ -165,32 +165,32 @@ GST_START_TEST (test_transfer)
gst_memory_unmap (mem2, &map_info); gst_memory_unmap (mem2, &map_info);
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ | GST_MAP_GL)); fail_unless (gst_memory_map (mem2, &map_info, GST_MAP_READ | GST_MAP_GL));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
/* test texture copy */ /* test texture copy */
fail_unless (gst_gl_memory_copy_into_texture ((GstGLMemory *) mem2, fail_unless (gst_gl_memory_copy_into_texture ((GstGLMemory *) mem2,
((GstGLMemory *) mem)->tex_id, GST_VIDEO_GL_TEXTURE_TYPE_RGBA, 1, 1, ((GstGLMemory *) mem)->tex_id, GST_VIDEO_GL_TEXTURE_TYPE_RGBA, 1, 1,
4, FALSE)); 4, FALSE));
GST_GL_MEMORY_FLAG_SET (mem, GST_GL_MEMORY_FLAG_NEED_DOWNLOAD); GST_MINI_OBJECT_FLAG_SET (mem, GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD);
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem2, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem2,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem, fail_unless (GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
gst_memory_unmap (mem2, &map_info); gst_memory_unmap (mem2, &map_info);
@ -207,10 +207,10 @@ GST_START_TEST (test_transfer)
/* test download of wrapped copied texture */ /* test download of wrapped copied texture */
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_READ)); fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_READ));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
fail_unless (((gchar *) map_info.data)[0] == rgba_pixel[0]); fail_unless (((gchar *) map_info.data)[0] == rgba_pixel[0]);
fail_unless (((gchar *) map_info.data)[1] == rgba_pixel[1]); fail_unless (((gchar *) map_info.data)[1] == rgba_pixel[1]);
@ -223,19 +223,19 @@ GST_START_TEST (test_transfer)
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE)); fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE));
gst_memory_unmap (mem3, &map_info); gst_memory_unmap (mem3, &map_info);
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem3, fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem3, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
/* test download flag */ /* test download flag */
fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE | GST_MAP_GL)); fail_unless (gst_memory_map (mem3, &map_info, GST_MAP_WRITE | GST_MAP_GL));
gst_memory_unmap (mem3, &map_info); gst_memory_unmap (mem3, &map_info);
fail_unless (!GST_GL_MEMORY_FLAG_IS_SET (mem3, fail_unless (!GST_MEMORY_FLAG_IS_SET (mem3,
GST_GL_MEMORY_FLAG_NEED_UPLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_UPLOAD));
fail_unless (GST_GL_MEMORY_FLAG_IS_SET (mem3, fail_unless (GST_MEMORY_FLAG_IS_SET (mem3,
GST_GL_MEMORY_FLAG_NEED_DOWNLOAD)); GST_GL_BASE_BUFFER_FLAG_NEED_DOWNLOAD));
if (gst_gl_context_get_error ()) if (gst_gl_context_get_error ())
printf ("%s\n", gst_gl_context_get_error ()); printf ("%s\n", gst_gl_context_get_error ());