diff --git a/gst-libs/gst/vaapi/gstvaapitexture_egl.c b/gst-libs/gst/vaapi/gstvaapitexture_egl.c
index 260ffaa2..bdd6fa8d 100644
--- a/gst-libs/gst/vaapi/gstvaapitexture_egl.c
+++ b/gst-libs/gst/vaapi/gstvaapitexture_egl.c
@@ -34,7 +34,7 @@
 #include "gstvaapiutils_egl.h"
 #include "gstvaapidisplay_egl.h"
 #include "gstvaapidisplay_egl_priv.h"
-#include "gstvaapisurface_egl.h"
+#include "gstvaapisurface_drm.h"
 #include "gstvaapifilter.h"
 
 #define DEBUG 1
@@ -95,6 +95,9 @@ create_objects (GstVaapiTextureEGL * texture, GLuint texture_id)
   EglContext *const ctx = texture->egl_context;
   EglVTable *const vtable = egl_context_get_vtable (ctx, FALSE);
   GLint attribs[3], *attrib;
+  gsize size, offset[GST_VIDEO_MAX_PLANES];
+  gint name, stride[GST_VIDEO_MAX_PLANES];
+  guint height;
 
   attrib = attribs;
   *attrib++ = EGL_IMAGE_PRESERVED_KHR;
@@ -106,10 +109,36 @@ create_objects (GstVaapiTextureEGL * texture, GLuint texture_id)
   if (!texture->egl_image)
     goto error_create_image;
 
+  /*
+   * The below dozen or so lines of code replaces all of gstvaapisurface_egl.c,
+   * which didn't work (deadlocks and incorrect GL context usage?) as well as
+   * being around 20x bigger than this. Maybe consider deleting
+   * gstvaapisurface_egl.c if it doesn't work and nobody calls it...
+   */
+  if (!vtable->has_EGL_MESA_drm_image) {
+    GST_ERROR ("missing EGL_MESA_drm_image");
+    goto error_create_surface;
+  }
+
+  memset (offset, 0, sizeof (offset));
+  memset (stride, 0, sizeof (stride));
+
+  if (!vtable->eglExportDRMImageMESA (ctx->display->base.handle.p,
+          texture->egl_image, &name, NULL, &stride[0]))
+    goto error_export_image_gem_buf;
+
+  // FIXME: The i965 VA driver requires height is a multiple of 16 at least.
+  // It also requires for tiling that width is a multiple of 128 and that
+  // height is a multiple of 32. TODO: How do we detect this? Get libVA to?
+  height = GST_ROUND_UP_32 (base_texture->height);
+
+  size = height * stride[0];
+
   texture->surface =
-      gst_vaapi_surface_new_with_egl_image (GST_VAAPI_OBJECT_DISPLAY (texture),
-      texture->egl_image, GST_VIDEO_FORMAT_RGBA, base_texture->width,
-      base_texture->height);
+      gst_vaapi_surface_new_with_gem_buf_handle (GST_VAAPI_OBJECT_DISPLAY
+      (texture), name, size, GST_VIDEO_FORMAT_RGBA, base_texture->width,
+      height, offset, stride);
+
   if (!texture->surface)
     goto error_create_surface;
 
@@ -120,7 +149,8 @@ create_objects (GstVaapiTextureEGL * texture, GLuint texture_id)
 
   /* ERRORS */
 error_create_image:
-  GST_ERROR ("failed to create EGL image from 2D texture %u", texture_id);
+  GST_ERROR ("failed to create EGL image from 2D texture %u (EGL error 0x%x)",
+      texture_id, eglGetError ());
   return FALSE;
 error_create_surface:
   GST_ERROR ("failed to create VA surface from 2D texture %u", texture_id);
@@ -128,6 +158,10 @@ error_create_surface:
 error_create_filter:
   GST_ERROR ("failed to create VPP filter for color conversion");
   return FALSE;
+error_export_image_gem_buf:
+  GST_ERROR ("failed to export EGL image to GEM buffer (EGL error 0x%x)",
+      eglGetError ());
+  return FALSE;
 }
 
 static gboolean
@@ -247,8 +281,18 @@ gst_vaapi_texture_egl_create (GstVaapiTextureEGL * texture)
 {
   CreateTextureArgs args = { texture };
 
-  egl_object_replace (&texture->egl_context,
-      GST_VAAPI_DISPLAY_EGL_CONTEXT (GST_VAAPI_OBJECT_DISPLAY (texture)));
+  /*
+   * We must use the context of the EGL application/downstream sink from the
+   * current thread. See gst_vaapi_texture_egl_new_wrapped and create_objects
+   * where the texture_id is only meaningful within the GL context that
+   * created it (which is that the calling thread).
+   */
+  EglDisplay *current_egl_display =
+      egl_display_new_wrapped (eglGetCurrentDisplay ());
+  EglContext *current_egl_context =
+      egl_context_new_wrapped (current_egl_display, eglGetCurrentContext ());
+
+  egl_object_replace (&texture->egl_context, current_egl_context);
 
   return egl_context_run (texture->egl_context,
       (EglContextRunFunc) do_create_texture, &args) && args.success;
diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c
index d45f7ee9..930a3cee 100644
--- a/gst/vaapi/gstvaapipostproc.c
+++ b/gst/vaapi/gstvaapipostproc.c
@@ -1069,7 +1069,7 @@ expand_allowed_srcpad_caps (GstVaapiPostproc * postproc, GstCaps * caps)
   }
   g_value_unset (&value);
 
-  if ((GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAN_DMABUF (postproc)
+  if ((!GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAN_DMABUF (postproc)
           || !gst_vaapi_display_has_opengl (GST_VAAPI_PLUGIN_BASE_DISPLAY
               (postproc)))
       && gl_upload_meta_idx > -1) {
