mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-13 09:45:27 +00:00
gl: add and use gst_gl_internal_format_rgba
Previously when compiling GstGL with both GL and GLES2, GL_RGBA8 was picked from GL/gl.h. But a clash may happen at runtime when one is selecting GLES2. gst_gl_internal_format_rgba allows to check at runtime if it should use GL_RGBA or GL_RGBA8.
This commit is contained in:
parent
c5f8c789a3
commit
ba5bf50d5f
8 changed files with 31 additions and 15 deletions
|
@ -285,10 +285,11 @@ gst_gl_effects_init_gl_resources (GstGLFilter * filter)
|
||||||
|
|
||||||
gl->GenTextures (1, &effects->midtexture[i]);
|
gl->GenTextures (1, &effects->midtexture[i]);
|
||||||
gl->BindTexture (GL_TEXTURE_2D, 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_WIDTH (&filter->out_info),
|
||||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
NULL);
|
||||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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_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_S, GL_CLAMP_TO_EDGE);
|
||||||
|
|
|
@ -93,10 +93,11 @@ static void gst_gl_filtershader_hcallback (gint width, gint height,
|
||||||
static void
|
static void
|
||||||
gst_gl_filtershader_init_resources (GstGLFilter * filter)
|
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_WIDTH (&filter->out_info),
|
||||||
GST_VIDEO_INFO_HEIGHT (&filter->out_info),
|
GST_VIDEO_INFO_HEIGHT (&filter->out_info), 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
NULL);
|
||||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
|
|
@ -31,7 +31,6 @@ G_BEGIN_DECLS
|
||||||
//FIXME:
|
//FIXME:
|
||||||
#define GL_RGB16 GL_RGB565
|
#define GL_RGB16 GL_RGB565
|
||||||
#define GL_RGB8 GL_RGB
|
#define GL_RGB8 GL_RGB
|
||||||
#define GL_RGBA8 GL_RGBA
|
|
||||||
//END FIXME
|
//END FIXME
|
||||||
|
|
||||||
/* UNSUPPORTED */
|
/* UNSUPPORTED */
|
||||||
|
|
|
@ -1463,8 +1463,9 @@ _init_convert_fbo (GstGLColorConvert * convert)
|
||||||
/* a fake texture is attached to the convert FBO (cannot init without it) */
|
/* a fake texture is attached to the convert FBO (cannot init without it) */
|
||||||
gl->GenTextures (1, &fake_texture);
|
gl->GenTextures (1, &fake_texture);
|
||||||
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
|
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
|
||||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, out_width, out_height,
|
gl->TexImage2D (GL_TEXTURE_2D, 0,
|
||||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_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_S, GL_CLAMP_TO_EDGE);
|
||||||
|
|
|
@ -125,8 +125,9 @@ gst_gl_framebuffer_generate (GstGLFramebuffer * frame, gint width, gint height,
|
||||||
/* setup a texture to render to */
|
/* setup a texture to render to */
|
||||||
gl->GenTextures (1, &fake_texture);
|
gl->GenTextures (1, &fake_texture);
|
||||||
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
|
gl->BindTexture (GL_TEXTURE_2D, fake_texture);
|
||||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
|
gl->TexImage2D (GL_TEXTURE_2D, 0,
|
||||||
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_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_S, GL_CLAMP_TO_EDGE);
|
||||||
|
|
|
@ -303,7 +303,7 @@ _sized_gl_format_from_gl_format_type (GstGLContext * context, GLenum format,
|
||||||
case GL_RGBA:
|
case GL_RGBA:
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GL_UNSIGNED_BYTE:
|
case GL_UNSIGNED_BYTE:
|
||||||
return GL_RGBA8;
|
return gst_gl_internal_format_rgba (context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -113,8 +113,8 @@ _gen_texture (GstGLContext * context, GenTexture * data)
|
||||||
gl->BindTexture (GL_TEXTURE_2D, data->result);
|
gl->BindTexture (GL_TEXTURE_2D, data->result);
|
||||||
|
|
||||||
if (data->width > 0 && data->height > 0)
|
if (data->width > 0 && data->height > 0)
|
||||||
gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, data->width,
|
gl->TexImage2D (GL_TEXTURE_2D, 0, gst_gl_internal_format_rgba (context),
|
||||||
data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_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_xBGR:
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
{
|
{
|
||||||
glinternalformat = GL_RGBA8;
|
glinternalformat = gst_gl_internal_format_rgba (context);
|
||||||
glformat = GL_RGBA;
|
glformat = GL_RGBA;
|
||||||
gltype = GL_UNSIGNED_BYTE;
|
gltype = GL_UNSIGNED_BYTE;
|
||||||
break;
|
break;
|
||||||
|
@ -904,3 +904,15 @@ gst_gl_caps_replace_all_caps_features (const GstCaps * caps,
|
||||||
|
|
||||||
return tmp;
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ gsize gst_gl_get_plane_data_size (GstVideoInfo * info, GstVideoAlignment * align
|
||||||
guint plane);
|
guint plane);
|
||||||
GstCaps * gst_gl_caps_replace_all_caps_features (const GstCaps * caps,
|
GstCaps * gst_gl_caps_replace_all_caps_features (const GstCaps * caps,
|
||||||
const gchar * feature_name);
|
const gchar * feature_name);
|
||||||
|
GLint gst_gl_internal_format_rgba (GstGLContext * context);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue