From 5f547c56001c25fcb352ed735ca79c0ff344322c Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Wed, 28 Jan 2015 00:13:46 +1100 Subject: [PATCH] gl: initial support for texture targets other than GL_TEXTURE_2D Make GstGLMemory hold the texture target (tex_target) the texture it represents (tex_id) is bound to. Modify gst_gl_memory_wrapped_texture and gst_gl_download_perform_with_data to take the texture target as an argument. This change is needed to support wrapping textures created outside libgstgl, which might be bound to a target other than GL_TEXTURE_2D. For example on OSX textures coming from VideoToolbox have target GL_TEXTURE_RECTANGLE. With this change we still keep (and sometimes imply) GL_TEXTURE_2D as the target of textures created with libgstgl. API: modify GstGLMemory API: modify gst_gl_memory_wrapped_texture API: gst_gl_download_perform_with_data --- ext/gl/gstglmixer.c | 9 +++-- ext/gl/gstgltestsrc.c | 9 +++-- gst-libs/gst/gl/gstglcolorconvert.c | 13 ++++--- gst-libs/gst/gl/gstgldownload.c | 17 ++++++--- gst-libs/gst/gl/gstgldownload.h | 3 +- gst-libs/gst/gl/gstglfilter.c | 10 +++-- gst-libs/gst/gl/gstglmemory.c | 57 ++++++++++++++++++----------- gst-libs/gst/gl/gstglmemory.h | 3 +- gst-libs/gst/gl/gstgluploadmeta.c | 6 ++- 9 files changed, 79 insertions(+), 48 deletions(-) diff --git a/ext/gl/gstglmixer.c b/ext/gl/gstglmixer.c index 5fdcc3db93..a122f8f278 100644 --- a/ext/gl/gstglmixer.c +++ b/ext/gl/gstglmixer.c @@ -1127,7 +1127,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf) { guint i; GList *walk; - guint out_tex; + guint out_tex, out_tex_target; gboolean res = TRUE; guint array_index = 0; GstVideoFrame out_frame; @@ -1153,6 +1153,8 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf) if (!to_download) { out_tex = *(guint *) out_frame.data[0]; + out_tex_target = + ((GstGLMemory *) gst_buffer_peek_memory (outbuf, 0))->tex_target; } else { GST_INFO ("Output Buffer does not contain correct memory, " "attempting to wrap for download"); @@ -1162,6 +1164,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf) gst_gl_download_set_format (mix->download, &out_frame.info); out_tex = mix->out_tex_id; + out_tex_target = GL_TEXTURE_2D; } GST_OBJECT_LOCK (mix); @@ -1215,8 +1218,8 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf) g_mutex_unlock (&priv->gl_resource_lock); if (to_download) { - if (!gst_gl_download_perform_with_data (mix->download, out_tex, - out_frame.data)) { + if (!gst_gl_download_perform_with_data (mix->download, + out_tex, out_tex_target, out_frame.data)) { GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND, ("%s", "Failed to download video frame"), (NULL)); res = FALSE; diff --git a/ext/gl/gstgltestsrc.c b/ext/gl/gstgltestsrc.c index 8cb0fd17ed..6b10a2cdab 100644 --- a/ext/gl/gstgltestsrc.c +++ b/ext/gl/gstgltestsrc.c @@ -599,7 +599,7 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer) gint width, height; GstVideoFrame out_frame; GstGLSyncMeta *sync_meta; - guint out_tex; + guint out_tex, out_tex_target; gboolean to_download = gst_caps_features_is_equal (GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY, gst_caps_get_features (src->out_caps, 0)); @@ -634,6 +634,8 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer) if (!to_download) { out_tex = *(guint *) out_frame.data[0]; + out_tex_target = + ((GstGLMemory *) gst_buffer_peek_memory (buffer, 0))->tex_target; } else { GST_INFO ("Output Buffer does not contain correct meta, " "attempting to wrap for download"); @@ -649,6 +651,7 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer) GST_VIDEO_FRAME_HEIGHT (&out_frame)); } out_tex = src->out_tex_id; + out_tex_target = GL_TEXTURE_2D; } gst_buffer_replace (&src->buffer, buffer); @@ -661,8 +664,8 @@ gst_gl_test_src_fill (GstPushSrc * psrc, GstBuffer * buffer) } if (to_download) { - if (!gst_gl_download_perform_with_data (src->download, out_tex, - out_frame.data)) { + if (!gst_gl_download_perform_with_data (src->download, + out_tex, out_tex_target, out_frame.data)) { GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, ("%s", "Failed to init upload format"), (NULL)); return FALSE; diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index 95262f93a7..daf2a492d5 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -1549,14 +1549,15 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert) for (i = c_info->in_n_textures - 1; i >= 0; i--) { gchar *scale_name = g_strdup_printf ("tex_scale%u", i); + GstGLMemory *m = convert->priv->in_tex[i]; + guint tex_target = m->tex_target; gl->ActiveTexture (GL_TEXTURE0 + i); - gl->BindTexture (GL_TEXTURE_2D, convert->priv->in_tex[i]->tex_id); - - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gl->BindTexture (tex_target, convert->priv->in_tex[i]->tex_id); + gl->TexParameteri (tex_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl->TexParameteri (tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl->TexParameteri (tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl->TexParameteri (tex_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1, convert->priv->in_tex[i]->tex_scaling); diff --git a/gst-libs/gst/gl/gstgldownload.c b/gst-libs/gst/gl/gstgldownload.c index 12cf051d80..a5d5b624ce 100644 --- a/gst-libs/gst/gl/gstgldownload.c +++ b/gst-libs/gst/gl/gstgldownload.c @@ -47,7 +47,8 @@ static gboolean _do_download (GstGLDownload * download, guint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]); static gboolean _init_download (GstGLDownload * download); static gboolean _gst_gl_download_perform_with_data_unlocked (GstGLDownload * - download, GLuint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]); + download, GLuint texture_id, GLuint texture_target, + gpointer data[GST_VIDEO_MAX_PLANES]); static void gst_gl_download_reset (GstGLDownload * download); /* *INDENT-ON* */ @@ -183,6 +184,7 @@ gst_gl_download_set_format (GstGLDownload * download, GstVideoInfo * out_info) * gst_gl_download_perform_with_data: * @download: a #GstGLDownload * @texture_id: the texture id to download + * @texture_target: the GL texture target * @data: (out): where the downloaded data should go * * Downloads @texture_id into @data. @data size and format is specified by @@ -191,7 +193,8 @@ gst_gl_download_set_format (GstGLDownload * download, GstVideoInfo * out_info) * Returns: whether the download was successful */ gboolean -gst_gl_download_perform_with_data (GstGLDownload * download, GLuint texture_id, +gst_gl_download_perform_with_data (GstGLDownload * download, + GLuint texture_id, GLuint texture_target, gpointer data[GST_VIDEO_MAX_PLANES]) { gboolean ret; @@ -200,7 +203,8 @@ gst_gl_download_perform_with_data (GstGLDownload * download, GLuint texture_id, GST_OBJECT_LOCK (download); ret = - _gst_gl_download_perform_with_data_unlocked (download, texture_id, data); + _gst_gl_download_perform_with_data_unlocked (download, + texture_id, texture_target, data); GST_OBJECT_UNLOCK (download); return ret; @@ -208,7 +212,8 @@ gst_gl_download_perform_with_data (GstGLDownload * download, GLuint texture_id, static gboolean _gst_gl_download_perform_with_data_unlocked (GstGLDownload * download, - GLuint texture_id, gpointer data[GST_VIDEO_MAX_PLANES]) + GLuint texture_id, GLuint texture_target, + gpointer data[GST_VIDEO_MAX_PLANES]) { guint i; @@ -231,8 +236,8 @@ _gst_gl_download_perform_with_data_unlocked (GstGLDownload * download, GST_VIDEO_INFO_HEIGHT (&download->info)); download->priv->in_tex[0] = - gst_gl_memory_wrapped_texture (download->context, texture_id, - &temp_info, 0, NULL, NULL, NULL); + gst_gl_memory_wrapped_texture (download->context, + texture_id, texture_target, &temp_info, 0, NULL, NULL, NULL); } download->priv->in_tex[0]->tex_id = texture_id; diff --git a/gst-libs/gst/gl/gstgldownload.h b/gst-libs/gst/gl/gstgldownload.h index 531e4f4d06..828c01dc0e 100644 --- a/gst-libs/gst/gl/gstgldownload.h +++ b/gst-libs/gst/gl/gstgldownload.h @@ -74,7 +74,8 @@ GstGLDownload * gst_gl_download_new (GstGLContext * context); void gst_gl_download_set_format (GstGLDownload * download, GstVideoInfo * out_info); -gboolean gst_gl_download_perform_with_data (GstGLDownload * download, GLuint texture_id, +gboolean gst_gl_download_perform_with_data (GstGLDownload * download, + GLuint texture_id, GLuint texture_target, gpointer data[GST_VIDEO_MAX_PLANES]); G_END_DECLS diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index cf744aa8ee..d77dde9a20 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -1222,7 +1222,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf, GstBuffer * outbuf) { GstGLFilterClass *filter_class; - guint in_tex, out_tex; + guint in_tex, out_tex, out_tex_target; GstVideoFrame gl_frame, out_frame; GstVideoInfo gl_info; gboolean ret; @@ -1261,7 +1261,6 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf, } in_tex = *(guint *) gl_frame.data[0]; - to_download |= !gst_is_gl_memory (gst_buffer_peek_memory (outbuf, 0)); if (!to_download) @@ -1275,6 +1274,8 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf, if (!to_download) { out_tex = *(guint *) out_frame.data[0]; + out_tex_target = + ((GstGLMemory *) gst_buffer_peek_memory (outbuf, 0))->tex_target; } else { GST_LOG ("Output Buffer does not contain correct memory, " "attempting to wrap for download"); @@ -1285,6 +1286,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf, gst_gl_download_set_format (filter->download, &out_frame.info); out_tex = filter->out_tex_id; + out_tex_target = GL_TEXTURE_2D; } GST_DEBUG ("calling filter_texture with textures in:%i out:%i", in_tex, @@ -1294,8 +1296,8 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf, ret = filter_class->filter_texture (filter, in_tex, out_tex); if (to_download) { - if (!gst_gl_download_perform_with_data (filter->download, out_tex, - out_frame.data)) { + if (!gst_gl_download_perform_with_data (filter->download, + out_tex, out_tex_target, out_frame.data)) { GST_ELEMENT_ERROR (filter, RESOURCE, NOT_FOUND, ("%s", "Failed to download video frame"), (NULL)); ret = FALSE; diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index ca4628ad73..3e79476f54 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -112,6 +112,7 @@ typedef struct guint out_width, out_height; guint out_stride; gboolean respecify; + guint tex_target; /* inout */ guint tex_id; /* out */ @@ -372,6 +373,7 @@ _get_plane_height (GstVideoInfo * info, guint plane) typedef struct _GenTexture { guint width, height; + GLenum gl_target; GLenum gl_format; GLenum gl_type; guint result; @@ -391,14 +393,14 @@ _generate_texture (GstGLContext * context, GenTexture * data) _sized_gl_format_from_gl_format_type (data->gl_format, data->gl_type); gl->GenTextures (1, &data->result); - gl->BindTexture (GL_TEXTURE_2D, data->result); - gl->TexImage2D (GL_TEXTURE_2D, 0, internal_format, data->width, + gl->BindTexture (data->gl_target, data->result); + gl->TexImage2D (data->gl_target, 0, internal_format, data->width, data->height, 0, data->gl_format, data->gl_type, NULL); - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + gl->TexParameteri (data->gl_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gl->TexParameteri (data->gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + gl->TexParameteri (data->gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + gl->TexParameteri (data->gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); GST_CAT_LOG (GST_CAT_GL_MEMORY, "generated texture id:%d", data->result); } @@ -427,7 +429,7 @@ static void _upload_memory (GstGLContext * context, GstGLMemory * gl_mem) { const GstGLFuncs *gl; - GLenum gl_format, gl_type; + GLenum gl_format, gl_type, gl_target; gpointer data; gsize plane_start; @@ -442,6 +444,7 @@ _upload_memory (GstGLContext * context, GstGLMemory * gl_mem) gl_type = GL_UNSIGNED_SHORT_5_6_5; gl_format = _gst_gl_format_from_gl_texture_type (gl_mem->tex_type); + gl_target = gl_mem->tex_target; if (USING_OPENGL (context) || USING_GLES3 (context) || USING_OPENGL3 (context)) { @@ -464,8 +467,8 @@ _upload_memory (GstGLContext * context, GstGLMemory * gl_mem) data = (gpointer) ((gintptr) plane_start + (gintptr) gl_mem->data); } - gl->BindTexture (GL_TEXTURE_2D, gl_mem->tex_id); - gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, gl_mem->tex_width, + gl->BindTexture (gl_target, gl_mem->tex_id); + gl->TexSubImage2D (gl_target, 0, 0, 0, gl_mem->tex_width, GL_MEM_HEIGHT (gl_mem), gl_format, gl_type, data); if (gl_mem->transfer_pbo && CONTEXT_SUPPORTS_PBO_UPLOAD (context)) @@ -478,7 +481,7 @@ _upload_memory (GstGLContext * context, GstGLMemory * gl_mem) gl->PixelStorei (GL_UNPACK_ALIGNMENT, 4); } - gl->BindTexture (GL_TEXTURE_2D, 0); + gl->BindTexture (gl_target, 0); GST_GL_MEMORY_FLAG_UNSET (gl_mem, GST_GL_MEMORY_FLAG_NEED_UPLOAD); } @@ -688,9 +691,9 @@ _download_memory (GstGLContext * context, GstGLMemory * gl_mem) if (gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE || gl_mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA) { - gl->BindTexture (GL_TEXTURE_2D, gl_mem->tex_id); - gl->GetTexImage (GL_TEXTURE_2D, 0, format, type, gl_mem->data); - gl->BindTexture (GL_TEXTURE_2D, 0); + gl->BindTexture (gl_mem->tex_target, gl_mem->tex_id); + gl->GetTexImage (gl_mem->tex_target, 0, format, type, gl_mem->data); + gl->BindTexture (gl_mem->tex_target, 0); } else if (gl_mem->transfer_pbo && CONTEXT_SUPPORTS_PBO_DOWNLOAD (context)) { gsize size = ((GstMemory *) gl_mem)->maxsize; gpointer map_data = NULL; @@ -717,7 +720,7 @@ _download_memory (GstGLContext * context, GstGLMemory * gl_mem) gl->BindFramebuffer (GL_FRAMEBUFFER, fboId); gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, gl_mem->tex_id, 0); + gl_mem->tex_target, gl_mem->tex_id, 0); if (!gst_gl_context_check_framebuffer_status (context)) goto fbo_error; @@ -759,6 +762,8 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent, mem->tex_type = gst_gl_texture_type_from_format (context, GST_VIDEO_INFO_FORMAT (info), plane); + /* we always operate on 2D textures unless we're dealing with wrapped textures */ + mem->tex_target = GL_TEXTURE_2D; mem->plane = plane; mem->notify = notify; mem->user_data = user_data; @@ -789,6 +794,7 @@ _gl_mem_new (GstAllocator * allocator, GstMemory * parent, data.height = GL_MEM_HEIGHT (mem); data.gl_format = _gst_gl_format_from_gl_texture_type (mem->tex_type); data.gl_type = GL_UNSIGNED_BYTE; + data.gl_target = mem->tex_target; if (mem->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_RGB16) data.gl_type = GL_UNSIGNED_SHORT_5_6_5; @@ -802,6 +808,7 @@ _gl_mem_new (GstAllocator * allocator, GstMemory * parent, GST_CAT_TRACE (GST_CAT_GL_MEMORY, "created texture %u", data.result); mem->tex_id = data.result; + mem->tex_target = data.gl_target; return mem; } @@ -897,6 +904,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data) GstGLMemoryCopyParams *copy_params; GstGLMemory *src; guint tex_id; + GLuint out_tex_target; GLuint fboId; gsize out_width, out_height, out_stride; GLuint out_gl_format, out_gl_type; @@ -906,6 +914,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data) copy_params = (GstGLMemoryCopyParams *) data; src = copy_params->src; tex_id = copy_params->tex_id; + out_tex_target = copy_params->tex_target; out_width = copy_params->out_width; out_height = copy_params->out_height; out_stride = copy_params->out_stride; @@ -942,6 +951,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data) GenTexture data = { 0, }; data.width = copy_params->out_width; data.height = copy_params->out_height; + data.gl_target = out_tex_target; data.gl_format = out_gl_format; data.gl_type = GL_UNSIGNED_BYTE; if (copy_params->out_format == GST_VIDEO_GL_TEXTURE_TYPE_RGB16) @@ -965,17 +975,17 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data) gl->BindFramebuffer (GL_FRAMEBUFFER, fboId); gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, src->tex_id, 0); + src->tex_target, src->tex_id, 0); // if (!gst_gl_context_check_framebuffer_status (src->context)) // goto fbo_error; - gl->BindTexture (GL_TEXTURE_2D, tex_id); + gl->BindTexture (out_tex_target, tex_id); if (copy_params->respecify) { if (!gl->GenBuffers) { gst_gl_context_set_error (context, "Cannot reinterpret texture contents " "without buffer objects"); - gl->BindTexture (GL_TEXTURE_2D, 0); + gl->BindTexture (out_tex_target, 0); goto fbo_error; } @@ -983,7 +993,7 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data) && (in_gl_format != GL_RGBA || in_gl_type != GL_UNSIGNED_BYTE)) { gst_gl_context_set_error (context, "Cannot copy non RGBA/UNSIGNED_BYTE " "textures on GLES2"); - gl->BindTexture (GL_TEXTURE_2D, 0); + gl->BindTexture (out_tex_target, 0); goto fbo_error; } @@ -1002,16 +1012,16 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data) gl->BindBuffer (GL_PIXEL_PACK_BUFFER, 0); gl->BindBuffer (GL_PIXEL_UNPACK_BUFFER, src->pbo); - gl->TexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, out_width, out_height, + gl->TexSubImage2D (out_tex_target, 0, 0, 0, out_width, out_height, out_gl_format, out_gl_type, 0); gl->BindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); } else { /* different sizes */ - gl->CopyTexImage2D (GL_TEXTURE_2D, 0, out_gl_format, 0, 0, out_width, + gl->CopyTexImage2D (out_tex_target, 0, out_gl_format, 0, 0, out_width, out_height, 0); } - gl->BindTexture (GL_TEXTURE_2D, 0); + gl->BindTexture (out_tex_target, 0); gl->BindFramebuffer (GL_FRAMEBUFFER, 0); gl->DeleteFramebuffers (1, &fboId); @@ -1203,6 +1213,7 @@ gst_gl_memory_copy_into_texture (GstGLMemory * gl_mem, guint tex_id, * gst_gl_memory_wrapped_texture: * @context: a #GstGLContext * @texture_id: the GL texture handle + * @texture_target: the GL texture target * @info: the #GstVideoInfo of the memory * @plane: The plane this memory will represent * @user_data: user data @@ -1213,7 +1224,8 @@ gst_gl_memory_copy_into_texture (GstGLMemory * gl_mem, guint tex_id, * Returns: a newly allocated #GstGLMemory */ GstGLMemory * -gst_gl_memory_wrapped_texture (GstGLContext * context, guint texture_id, +gst_gl_memory_wrapped_texture (GstGLContext * context, + guint texture_id, guint texture_target, GstVideoInfo * info, guint plane, GstVideoAlignment * valign, gpointer user_data, GDestroyNotify notify) { @@ -1224,6 +1236,7 @@ gst_gl_memory_wrapped_texture (GstGLContext * context, guint texture_id, NULL); mem->tex_id = texture_id; + mem->tex_target = texture_target; mem->texture_wrapped = TRUE; mem->data = g_try_malloc (mem->mem.maxsize); if (mem->data == NULL) { diff --git a/gst-libs/gst/gl/gstglmemory.h b/gst-libs/gst/gl/gstglmemory.h index bf2480dd95..7dad0aa2a9 100644 --- a/gst-libs/gst/gl/gstglmemory.h +++ b/gst-libs/gst/gl/gstglmemory.h @@ -84,6 +84,7 @@ struct _GstGLMemory GstGLContext *context; guint tex_id; + guint tex_target; GstVideoGLTextureType tex_type; GstVideoInfo info; GstVideoAlignment valign; @@ -158,7 +159,7 @@ GstMemory * gst_gl_memory_alloc (GstGLContext * context, GstVideoInfo * info GstGLMemory * gst_gl_memory_wrapped (GstGLContext * context, GstVideoInfo * info, guint plane, GstVideoAlignment *valign, gpointer data, gpointer user_data, GDestroyNotify notify); -GstGLMemory * gst_gl_memory_wrapped_texture (GstGLContext * context, guint texture_id, +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); diff --git a/gst-libs/gst/gl/gstgluploadmeta.c b/gst-libs/gst/gl/gstgluploadmeta.c index bab4b024d4..5eb58748f2 100644 --- a/gst-libs/gst/gl/gstgluploadmeta.c +++ b/gst-libs/gst/gl/gstgluploadmeta.c @@ -221,9 +221,11 @@ _perform_with_gl_memory (GstGLUploadMeta * upload, GstVideoGLTextureUploadMeta * GstGLMemory *out_mem; gint mem_width, mem_height; - if (!upload->priv->out_tex[i]) + if (!upload->priv->out_tex[i]) { + /* the GL upload meta creates GL_TEXTURE_2D textures */ upload->priv->out_tex[i] = gst_gl_memory_wrapped_texture (upload->context, - texture_id[i], &upload->info, i, NULL, NULL, NULL); + texture_id[i], GL_TEXTURE_2D, &upload->info, i, NULL, NULL, NULL); + } out_mem = upload->priv->out_tex[i];