mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-08 17:50:10 +00:00
glcontext: Split dmabuf import codepaths
Use different codepaths for known formats vs unknown formats. Be more careful with unknown formats and always import them as GL_TEXTURE_EXTERNAL_OES when possible (GL can't do EXTERNAL) to avoid problems. This is a more defensive approach towards older drivers that don't support modifiers. This fixes importing YUV textures on AMD Gen8. Another approach would be to check for YUV and never try GL_TEXTURE_2D with them, but I decided to go this way first. Fixes #6668
This commit is contained in:
parent
719021e1f4
commit
c20e7a0c5d
@ -2198,6 +2198,10 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
|
||||
gdk_display_init_dmabuf (display);
|
||||
|
||||
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier))
|
||||
{
|
||||
/* This is the path for modern drivers that support modifiers */
|
||||
|
||||
if (!gdk_dmabuf_formats_contains (display->egl_external_formats, dmabuf->fourcc, dmabuf->modifier))
|
||||
{
|
||||
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
|
||||
@ -2249,6 +2253,41 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
|
||||
*external = TRUE;
|
||||
return texture_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is the opportunistic path.
|
||||
* We hit it both for drivers that do not support modifiers as well as for dmabufs
|
||||
* that the driver did not explicitly advertise. */
|
||||
int target;
|
||||
|
||||
if (gdk_gl_context_get_use_es (self))
|
||||
target = GL_TEXTURE_EXTERNAL_OES;
|
||||
else
|
||||
target = GL_TEXTURE_2D;
|
||||
|
||||
texture_id = gdk_gl_context_import_dmabuf_for_target (self,
|
||||
width, height,
|
||||
dmabuf,
|
||||
target);
|
||||
|
||||
if (texture_id == 0)
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Import of %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
|
||||
width, height,
|
||||
(char *) &dmabuf->fourcc, dmabuf->modifier);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as %s texture",
|
||||
width, height,
|
||||
(char *) &dmabuf->fourcc, dmabuf->modifier,
|
||||
target == GL_TEXTURE_EXTERNAL_OES ? "GL_TEXTURE_EXTERNAL_OES" : "GL_TEXTURE_2D");
|
||||
*external = target == GL_TEXTURE_EXTERNAL_OES;
|
||||
return texture_id;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_gl_context_export_dmabuf (GdkGLContext *self,
|
||||
|
Loading…
Reference in New Issue
Block a user