gl/egl/dmabuf: Wrong attribute list type for EGL 1.5

For EGL 1.5 spec, the attribute list type should be EGLAttrib.

https://bugzilla.gnome.org/show_bug.cgi?id=768602
This commit is contained in:
Song Bing 2016-07-13 17:15:44 +08:00 committed by Matthew Waters
parent 2776cef25d
commit 4e04f28478
4 changed files with 77 additions and 36 deletions

View file

@ -244,6 +244,9 @@ gst_egl_image_from_dmabuf (GstGLContext * context,
gint fourcc; gint fourcc;
gint atti = 0; gint atti = 0;
EGLint attribs[13]; EGLint attribs[13];
#ifdef EGL_VERSION_1_5
EGLAttrib attribs_1_5[13];
#endif
EGLImageKHR img = EGL_NO_IMAGE_KHR; EGLImageKHR img = EGL_NO_IMAGE_KHR;
GstVideoGLTextureType type; GstVideoGLTextureType type;
@ -257,32 +260,55 @@ gst_egl_image_from_dmabuf (GstGLContext * context,
GST_VIDEO_INFO_COMP_WIDTH (in_info, plane), GST_VIDEO_INFO_COMP_WIDTH (in_info, plane),
GST_VIDEO_INFO_COMP_HEIGHT (in_info, plane)); GST_VIDEO_INFO_COMP_HEIGHT (in_info, plane));
attribs[atti++] = EGL_WIDTH; #ifdef EGL_VERSION_1_5
attribs[atti++] = GST_VIDEO_INFO_COMP_WIDTH (in_info, plane); if (GST_GL_CHECK_GL_VERSION (ctx_egl->egl_major, ctx_egl->egl_minor, 1, 5)) {
attribs[atti++] = EGL_HEIGHT; attribs_1_5[atti++] = EGL_WIDTH;
attribs[atti++] = GST_VIDEO_INFO_COMP_HEIGHT (in_info, plane); attribs_1_5[atti++] = GST_VIDEO_INFO_COMP_WIDTH (in_info, plane);
attribs_1_5[atti++] = EGL_HEIGHT;
attribs_1_5[atti++] = GST_VIDEO_INFO_COMP_HEIGHT (in_info, plane);
attribs_1_5[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
attribs_1_5[atti++] = fourcc;
attribs_1_5[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
attribs_1_5[atti++] = dmabuf;
attribs_1_5[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
attribs_1_5[atti++] = offset;
attribs_1_5[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
attribs_1_5[atti++] = GST_VIDEO_INFO_PLANE_STRIDE (in_info, plane);
attribs_1_5[atti] = EGL_NONE;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT; for (int i = 0; i < atti; i++)
attribs[atti++] = fourcc; GST_LOG ("attr %i: %" G_GINTPTR_FORMAT, i, attribs_1_5[i]);
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT; g_assert (atti == 12);
attribs[atti++] = dmabuf;
attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT; img = ctx_egl->eglCreateImage (ctx_egl->egl_display, EGL_NO_CONTEXT,
attribs[atti++] = offset; EGL_LINUX_DMA_BUF_EXT, NULL, attribs_1_5);
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
attribs[atti++] = GST_VIDEO_INFO_PLANE_STRIDE (in_info, plane);
attribs[atti] = EGL_NONE; } else
#endif
{
attribs[atti++] = EGL_WIDTH;
attribs[atti++] = GST_VIDEO_INFO_COMP_WIDTH (in_info, plane);
attribs[atti++] = EGL_HEIGHT;
attribs[atti++] = GST_VIDEO_INFO_COMP_HEIGHT (in_info, plane);
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
attribs[atti++] = fourcc;
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
attribs[atti++] = dmabuf;
attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT;
attribs[atti++] = offset;
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
attribs[atti++] = GST_VIDEO_INFO_PLANE_STRIDE (in_info, plane);
attribs[atti] = EGL_NONE;
for (int i = 0; i < atti; i++) for (int i = 0; i < atti; i++)
GST_LOG ("attr %i: %08X", i, attribs[i]); GST_LOG ("attr %i: %08X", i, attribs[i]);
g_assert (atti == 12); g_assert (atti == 12);
img = ctx_egl->eglCreateImage (ctx_egl->egl_display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT, NULL, attribs);
img = ctx_egl->eglCreateImageKHR (ctx_egl->egl_display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT, NULL, attribs);
}
if (!img) { if (!img) {
GST_WARNING ("eglCreateImage failed: %s", GST_WARNING ("eglCreateImage failed: %s",
gst_gl_context_egl_get_error_string (eglGetError ())); gst_gl_context_egl_get_error_string (eglGetError ()));

View file

@ -309,8 +309,8 @@ gst_gl_context_egl_create_context (GstGLContext * context,
GstGLContextEGL *egl; GstGLContextEGL *egl;
GstGLWindow *window = NULL; GstGLWindow *window = NULL;
EGLNativeWindowType window_handle = (EGLNativeWindowType) 0; EGLNativeWindowType window_handle = (EGLNativeWindowType) 0;
EGLint majorVersion; EGLint egl_major;
EGLint minorVersion; EGLint egl_minor;
gboolean need_surface = TRUE; gboolean need_surface = TRUE;
guintptr external_gl_context = 0; guintptr external_gl_context = 0;
GstGLDisplay *display; GstGLDisplay *display;
@ -363,8 +363,8 @@ gst_gl_context_egl_create_context (GstGLContext * context,
} }
gst_object_unref (display); gst_object_unref (display);
if (eglInitialize (egl->egl_display, &majorVersion, &minorVersion)) { if (eglInitialize (egl->egl_display, &egl_major, &egl_minor)) {
GST_INFO ("egl initialized, version: %d.%d", majorVersion, minorVersion); GST_INFO ("egl initialized, version: %d.%d", egl_major, egl_minor);
} else { } else {
g_set_error (error, GST_GL_CONTEXT_ERROR, g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
@ -380,16 +380,16 @@ gst_gl_context_egl_create_context (GstGLContext * context,
gint i; gint i;
/* egl + opengl only available with EGL 1.4+ */ /* egl + opengl only available with EGL 1.4+ */
if (majorVersion == 1 && minorVersion <= 3) { if (egl_major == 1 && egl_minor <= 3) {
if ((gl_api & ~GST_GL_API_OPENGL) == GST_GL_API_NONE) { if ((gl_api & ~GST_GL_API_OPENGL) == GST_GL_API_NONE) {
g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_OLD_LIBS, g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_OLD_LIBS,
"EGL version (%i.%i) too old for OpenGL support, (needed at least 1.4)", "EGL version (%i.%i) too old for OpenGL support, (needed at least 1.4)",
majorVersion, minorVersion); egl_major, egl_minor);
goto failure; goto failure;
} else { } else {
GST_WARNING GST_WARNING
("EGL version (%i.%i) too old for OpenGL support, (needed at least 1.4)", ("EGL version (%i.%i) too old for OpenGL support, (needed at least 1.4)",
majorVersion, minorVersion); egl_major, egl_minor);
if (gl_api & GST_GL_API_GLES2) { if (gl_api & GST_GL_API_GLES2) {
goto try_gles2; goto try_gles2;
} else { } else {
@ -599,22 +599,28 @@ gst_gl_context_egl_create_context (GstGLContext * context,
} }
/* EGLImage functions */ /* EGLImage functions */
if (GST_GL_CHECK_GL_VERSION (majorVersion, minorVersion, 1, 5)) { if (GST_GL_CHECK_GL_VERSION (egl_major, egl_minor, 1, 5)) {
egl->eglCreateImage = gst_gl_context_get_proc_address (context, egl->eglCreateImage = gst_gl_context_get_proc_address (context,
"eglCreateImage"); "eglCreateImage");
egl->eglDestroyImage = gst_gl_context_get_proc_address (context, egl->eglDestroyImage = gst_gl_context_get_proc_address (context,
"eglDestroyImage"); "eglDestroyImage");
if (egl->eglCreateImage == NULL || egl->eglDestroyImage == NULL) {
egl->eglCreateImage = NULL;
egl->eglDestroyImage = NULL;
}
} else if (gst_gl_check_extension ("EGL_KHR_image_base", egl->egl_exts)) { } else if (gst_gl_check_extension ("EGL_KHR_image_base", egl->egl_exts)) {
egl->eglCreateImage = gst_gl_context_get_proc_address (context, egl->eglCreateImageKHR = gst_gl_context_get_proc_address (context,
"eglCreateImageKHR"); "eglCreateImageKHR");
egl->eglDestroyImage = gst_gl_context_get_proc_address (context, egl->eglDestroyImage = gst_gl_context_get_proc_address (context,
"eglDestroyImageKHR"); "eglDestroyImageKHR");
if (egl->eglCreateImageKHR == NULL || egl->eglDestroyImage == NULL) {
egl->eglCreateImageKHR = NULL;
egl->eglDestroyImage = NULL;
}
} }
if (egl->eglCreateImage == NULL || egl->eglDestroyImage == NULL) { egl->egl_major = egl_major;
egl->eglCreateImage = NULL; egl->egl_minor = egl_minor;
egl->eglDestroyImage = NULL;
}
if (window) if (window)
gst_object_unref (window); gst_object_unref (window);
@ -817,7 +823,11 @@ gst_gl_context_egl_check_feature (GstGLContext * context, const gchar * feature)
GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context); GstGLContextEGL *context_egl = GST_GL_CONTEXT_EGL (context);
if (g_strcmp0 (feature, "EGL_KHR_image_base") == 0) { if (g_strcmp0 (feature, "EGL_KHR_image_base") == 0) {
return context_egl->eglCreateImage != NULL && if (GST_GL_CHECK_GL_VERSION (context_egl->egl_major, context_egl->egl_minor, 1, 5))
return context_egl->eglCreateImage != NULL &&
context_egl->eglDestroyImage != NULL;
else
return context_egl->eglCreateImageKHR != NULL &&
context_egl->eglDestroyImage != NULL; context_egl->eglDestroyImage != NULL;
} }

View file

@ -46,12 +46,17 @@ struct _GstGLContextEGL {
EGLSurface egl_surface; EGLSurface egl_surface;
EGLConfig egl_config; EGLConfig egl_config;
gint egl_major;
gint egl_minor;
GstGLAPI gl_api; GstGLAPI gl_api;
const gchar *egl_exts; const gchar *egl_exts;
EGLImageKHR (*eglCreateImage) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLImageKHR (*eglCreateImageKHR) (EGLDisplay dpy, EGLContext ctx, EGLenum target,
EGLClientBuffer buffer, const EGLint *attrib_list); EGLClientBuffer buffer, const EGLint *attrib_list);
EGLImageKHR (*eglCreateImage) (EGLDisplay dpy, EGLContext ctx, EGLenum target,
EGLClientBuffer buffer, const EGLAttrib *attrib_list);
EGLBoolean (*eglDestroyImage) (EGLDisplay dpy, EGLImageKHR image); EGLBoolean (*eglDestroyImage) (EGLDisplay dpy, EGLImageKHR image);
/* Cached handle */ /* Cached handle */

View file

@ -159,7 +159,7 @@ _gl_mem_create (GstGLMemoryEGL * gl_mem, GError ** error)
return FALSE; return FALSE;
if (gl_mem->image == NULL) { if (gl_mem->image == NULL) {
EGLImageKHR image = ctx_egl->eglCreateImage (ctx_egl->egl_display, EGLImageKHR image = ctx_egl->eglCreateImageKHR (ctx_egl->egl_display,
ctx_egl->egl_context, EGL_GL_TEXTURE_2D_KHR, ctx_egl->egl_context, EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer) (guintptr) gl_mem->mem.tex_id, NULL); (EGLClientBuffer) (guintptr) gl_mem->mem.tex_id, NULL);