diff --git a/ext/gl/gstgleffects.c b/ext/gl/gstgleffects.c index 0b84ca4e67..7106bdabcf 100644 --- a/ext/gl/gstgleffects.c +++ b/ext/gl/gstgleffects.c @@ -285,10 +285,11 @@ gst_gl_effects_init_gl_resources (GstGLFilter * filter) gl->GenTextures (1, &effects->midtexture[i]); gl->BindTexture (GL_TEXTURE_2D, effects->midtexture[i]); - gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, + gl->TexImage2D (GL_TEXTURE_2D, 0, + gst_gl_internal_format_rgba (GST_GL_BASE_FILTER (filter)->context), GST_VIDEO_INFO_WIDTH (&filter->out_info), - GST_VIDEO_INFO_HEIGHT (&filter->out_info), - 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE, + 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); diff --git a/ext/gl/gstglfiltershader.c b/ext/gl/gstglfiltershader.c index 0b96ebbd63..aa0af3c096 100644 --- a/ext/gl/gstglfiltershader.c +++ b/ext/gl/gstglfiltershader.c @@ -93,10 +93,11 @@ static void gst_gl_filtershader_hcallback (gint width, gint height, static void gst_gl_filtershader_init_resources (GstGLFilter * filter) { - glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, + glTexImage2D (GL_TEXTURE_2D, 0, + gst_gl_internal_format_rgba (GST_GL_BASE_FILTER (filter)->context), GST_VIDEO_INFO_WIDTH (&filter->out_info), - GST_VIDEO_INFO_HEIGHT (&filter->out_info), - 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE, + NULL); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); diff --git a/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h b/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h index b185e6a3df..d28299025d 100644 --- a/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h +++ b/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h @@ -31,7 +31,6 @@ G_BEGIN_DECLS //FIXME: #define GL_RGB16 GL_RGB565 #define GL_RGB8 GL_RGB -#define GL_RGBA8 GL_RGBA //END FIXME /* UNSUPPORTED */ diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index 9b285c4492..8e49fe977c 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -1463,8 +1463,9 @@ _init_convert_fbo (GstGLColorConvert * convert) /* a fake texture is attached to the convert FBO (cannot init without it) */ gl->GenTextures (1, &fake_texture); gl->BindTexture (GL_TEXTURE_2D, fake_texture); - gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, out_width, out_height, - 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + gl->TexImage2D (GL_TEXTURE_2D, 0, + gst_gl_internal_format_rgba (convert->context), out_width, out_height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, 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); diff --git a/gst-libs/gst/gl/gstglframebuffer.c b/gst-libs/gst/gl/gstglframebuffer.c index ff690105ab..945d418cc0 100644 --- a/gst-libs/gst/gl/gstglframebuffer.c +++ b/gst-libs/gst/gl/gstglframebuffer.c @@ -125,8 +125,9 @@ gst_gl_framebuffer_generate (GstGLFramebuffer * frame, gint width, gint height, /* setup a texture to render to */ gl->GenTextures (1, &fake_texture); gl->BindTexture (GL_TEXTURE_2D, fake_texture); - gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, - width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + gl->TexImage2D (GL_TEXTURE_2D, 0, + gst_gl_internal_format_rgba (frame->context), width, height, 0, GL_RGBA, + GL_UNSIGNED_BYTE, 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); diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index a4dc7dca6d..fd1ca31f62 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -303,7 +303,7 @@ _sized_gl_format_from_gl_format_type (GstGLContext * context, GLenum format, case GL_RGBA: switch (type) { case GL_UNSIGNED_BYTE: - return GL_RGBA8; + return gst_gl_internal_format_rgba (context); break; } break; diff --git a/gst-libs/gst/gl/gstglutils.c b/gst-libs/gst/gl/gstglutils.c index e4d9cad67d..20c5da611e 100644 --- a/gst-libs/gst/gl/gstglutils.c +++ b/gst-libs/gst/gl/gstglutils.c @@ -113,8 +113,8 @@ _gen_texture (GstGLContext * context, GenTexture * data) gl->BindTexture (GL_TEXTURE_2D, data->result); if (data->width > 0 && data->height > 0) - gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, data->width, - data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + gl->TexImage2D (GL_TEXTURE_2D, 0, gst_gl_internal_format_rgba (context), + data->width, data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -193,7 +193,7 @@ _gen_texture_full (GstGLContext * context, GenTextureFull * data) case GST_VIDEO_FORMAT_xBGR: case GST_VIDEO_FORMAT_AYUV: { - glinternalformat = GL_RGBA8; + glinternalformat = gst_gl_internal_format_rgba (context); glformat = GL_RGBA; gltype = GL_UNSIGNED_BYTE; break; @@ -904,3 +904,15 @@ gst_gl_caps_replace_all_caps_features (const GstCaps * caps, return tmp; } + +GLint +gst_gl_internal_format_rgba (GstGLContext * context) +{ +#if GST_GL_HAVE_GLES2 && (GST_GL_HAVE_OPENGL || GST_GL_HAVE_GLES3) + return USING_GLES2 (context) ? GL_RGBA : GL_RGBA8; +#elif GST_GL_HAVE_OPENGL || GST_GL_HAVE_GLES3 + return GL_RGBA8; +#else + return GL_RGBA; +#endif +} diff --git a/gst-libs/gst/gl/gstglutils.h b/gst-libs/gst/gl/gstglutils.h index c915bfb6fe..b4f3d48eb1 100644 --- a/gst-libs/gst/gl/gstglutils.h +++ b/gst-libs/gst/gl/gstglutils.h @@ -105,6 +105,7 @@ gsize gst_gl_get_plane_data_size (GstVideoInfo * info, GstVideoAlignment * align guint plane); GstCaps * gst_gl_caps_replace_all_caps_features (const GstCaps * caps, const gchar * feature_name); +GLint gst_gl_internal_format_rgba (GstGLContext * context); G_END_DECLS