diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index bbc5258aa2..439bf1dfec 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -1892,8 +1892,8 @@ init_dmabuf_formats (GdkDisplay *display) uint64_t *modifiers; unsigned int *external_only; - if (!gdk_dmabuf_texture_may_support ((unsigned int)formats[i])) - continue; +// if (!gdk_dmabuf_texture_may_support ((unsigned int)formats[i])) +// continue; eglQueryDmaBufModifiersEXT (priv->egl_display, formats[i], 0, NULL, NULL, &num_modifiers); modifiers = g_new (uint64_t, num_modifiers); diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c index 0924b73993..a6b4b9a924 100644 --- a/gsk/gl/gskglcommandqueue.c +++ b/gsk/gl/gskglcommandqueue.c @@ -282,7 +282,10 @@ snapshot_attachments (const GskGLAttachmentState *state, { bind[count].id = state->textures[i].id; bind[count].texture = state->textures[i].texture; - bind[count].sampler = state->textures[i].sampler; + if (state->textures[i].target == GL_TEXTURE_EXTERNAL_OES) + bind[count].sampler = 15; + else + bind[count].sampler = state->textures[i].sampler; count++; } } @@ -1190,12 +1193,23 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self, s->sync = NULL; } - glBindTexture (GL_TEXTURE_2D, bind->id); + if (bind->sampler == 15) + glBindTexture (GL_TEXTURE_EXTERNAL_OES, bind->id); + else + glBindTexture (GL_TEXTURE_2D, bind->id); textures[bind->texture] = bind->id; if (!self->has_samplers) { - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_from_index (bind->sampler / GSK_GL_N_FILTERS)); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_from_index (bind->sampler % GSK_GL_N_FILTERS)); + if (bind->sampler == 15) + { + glTexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else + { + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_from_index (bind->sampler / GSK_GL_N_FILTERS)); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_from_index (bind->sampler % GSK_GL_N_FILTERS)); + } } } @@ -1205,8 +1219,16 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self, glBindSampler (bind->texture, self->samplers[bind->sampler]); else { - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_from_index (bind->sampler / GSK_GL_N_FILTERS)); - glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_from_index (bind->sampler % GSK_GL_N_FILTERS)); + if (bind->sampler == 15) + { + glTexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else + { + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_from_index (bind->sampler / GSK_GL_N_FILTERS)); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_from_index (bind->sampler % GSK_GL_N_FILTERS)); + } } samplers[bind->texture] = bind->sampler; } @@ -1324,7 +1346,7 @@ gsk_gl_command_queue_end_frame (GskGLCommandQueue *self) if (self->attachments->textures[i].id != 0) { glActiveTexture (GL_TEXTURE0 + i); - glBindTexture (GL_TEXTURE_2D, 0); + glBindTexture (self->attachments->textures[i].target, 0); self->attachments->textures[i].id = 0; self->attachments->textures[i].changed = FALSE; @@ -1401,7 +1423,7 @@ gsk_gl_command_queue_create_texture (GskGLCommandQueue *self, glActiveTexture (GL_TEXTURE0); glBindTexture (GL_TEXTURE_2D, texture_id); - + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -1429,8 +1451,10 @@ gsk_gl_command_queue_create_texture (GskGLCommandQueue *self, } /* Restore the previous texture if it was set */ - if (self->attachments->textures[0].id != 0) - glBindTexture (GL_TEXTURE_2D, self->attachments->textures[0].id); + if (self->attachments->textures[0].id != 0 && + self->attachments->textures[0].target == GL_TEXTURE_2D) + glBindTexture (self->attachments->textures[0].target, + self->attachments->textures[0].id); return (int)texture_id; } diff --git a/gsk/gl/gskglcommandqueueprivate.h b/gsk/gl/gskglcommandqueueprivate.h index e9bb2f4003..575de3b093 100644 --- a/gsk/gl/gskglcommandqueueprivate.h +++ b/gsk/gl/gskglcommandqueueprivate.h @@ -54,6 +54,7 @@ typedef struct _GskGLCommandBind */ guint texture : 4; + /* the sampler to use. We set sampler to 15 to indicate external textures */ guint sampler : 4; /* The identifier for the texture created with glGenTextures(). */ diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c index 4beaa960bc..e5dc2a9dbf 100644 --- a/gsk/gl/gskgldriver.c +++ b/gsk/gl/gskgldriver.c @@ -789,9 +789,13 @@ egl_import_image (EGLImage image, glGenTextures (1, &texture_id); glBindTexture (target, texture_id); + g_assert (glGetError() == GL_NO_ERROR); glEGLImageTargetTexture2DOES (target, image); + g_assert (glGetError() == GL_NO_ERROR); glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + g_assert (glGetError() == GL_NO_ERROR); glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + g_assert (glGetError() == GL_NO_ERROR); return texture_id; }