MetaWaylandEglStream: Use EGL_WL_wayland_eglstream instead of fd hack
Use the proposed EGL_WL_wayland_eglstream EGL extension instead of the file descriptor hack that was used as a temporary solution. Note that this results in EGL clients will no longer work if they are running on a Nvidia driver with a version older than 370. https://bugzilla.gnome.org/show_bug.cgi?id=773629
This commit is contained in:
parent
f7fd018cf8
commit
2df35d636e
@ -66,8 +66,6 @@ struct _MetaEgl
|
|||||||
|
|
||||||
PFNEGLSTREAMCONSUMERACQUIREKHRPROC eglStreamConsumerAcquireKHR;
|
PFNEGLSTREAMCONSUMERACQUIREKHRPROC eglStreamConsumerAcquireKHR;
|
||||||
PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC eglStreamConsumerAcquireAttribNV;
|
PFNEGLSTREAMCONSUMERACQUIREATTRIBNVPROC eglStreamConsumerAcquireAttribNV;
|
||||||
|
|
||||||
PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC eglCreateStreamFromFileDescriptorKHR;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaEgl, meta_egl, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (MetaEgl, meta_egl, G_TYPE_OBJECT)
|
||||||
@ -699,27 +697,6 @@ meta_egl_stream_consumer_acquire (MetaEgl *egl,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLStreamKHR
|
|
||||||
meta_egl_create_stream_from_file_descriptor (MetaEgl *egl,
|
|
||||||
EGLDisplay display,
|
|
||||||
EGLNativeFileDescriptorKHR file_descriptor,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
EGLStreamKHR stream;
|
|
||||||
|
|
||||||
if (!is_egl_proc_valid (egl->eglCreateStreamFromFileDescriptorKHR, error))
|
|
||||||
return EGL_NO_STREAM_KHR;
|
|
||||||
|
|
||||||
stream = egl->eglCreateStreamFromFileDescriptorKHR (display, file_descriptor);
|
|
||||||
if (stream == EGL_NO_STREAM_KHR)
|
|
||||||
{
|
|
||||||
set_egl_error (error);
|
|
||||||
return EGL_NO_STREAM_KHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GET_EGL_PROC_ADDR(proc) \
|
#define GET_EGL_PROC_ADDR(proc) \
|
||||||
egl->proc = (void *) eglGetProcAddress (#proc);
|
egl->proc = (void *) eglGetProcAddress (#proc);
|
||||||
|
|
||||||
@ -762,8 +739,6 @@ meta_egl_constructed (GObject *object)
|
|||||||
|
|
||||||
GET_EGL_PROC_ADDR (eglStreamConsumerAcquireKHR);
|
GET_EGL_PROC_ADDR (eglStreamConsumerAcquireKHR);
|
||||||
GET_EGL_PROC_ADDR (eglStreamConsumerAcquireAttribNV);
|
GET_EGL_PROC_ADDR (eglStreamConsumerAcquireAttribNV);
|
||||||
|
|
||||||
GET_EGL_PROC_ADDR (eglCreateStreamFromFileDescriptorKHR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef GET_EGL_PROC_ADDR
|
#undef GET_EGL_PROC_ADDR
|
||||||
|
@ -163,9 +163,4 @@ gboolean meta_egl_stream_consumer_gl_texture_external (MetaEgl *egl,
|
|||||||
EGLStreamKHR stream,
|
EGLStreamKHR stream,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
EGLStreamKHR meta_egl_create_stream_from_file_descriptor (MetaEgl *egl,
|
|
||||||
EGLDisplay display,
|
|
||||||
EGLNativeFileDescriptorKHR file_descriptor,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
#endif /* META_EGL_H */
|
#endif /* META_EGL_H */
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "cogl/cogl-egl.h"
|
#include "cogl/cogl-egl.h"
|
||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
#include "backends/meta-egl.h"
|
#include "backends/meta-egl.h"
|
||||||
|
#include "backends/meta-egl-ext.h"
|
||||||
#include "meta/meta-backend.h"
|
#include "meta/meta-backend.h"
|
||||||
#include "wayland/meta-wayland-buffer.h"
|
#include "wayland/meta-wayland-buffer.h"
|
||||||
|
|
||||||
@ -54,43 +55,28 @@ meta_wayland_egl_stream_new (MetaWaylandBuffer *buffer,
|
|||||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||||
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||||
EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context);
|
EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context);
|
||||||
g_autoptr (MetaWaylandEglStream) stream = NULL;
|
EGLAttrib stream_attribs[] = {
|
||||||
int stream_fd;
|
EGL_WAYLAND_EGLSTREAM_WL, (EGLAttrib) buffer->resource,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
EGLStreamKHR egl_stream;
|
EGLStreamKHR egl_stream;
|
||||||
|
MetaWaylandEglStream *stream;
|
||||||
|
|
||||||
stream = g_object_new (META_TYPE_WAYLAND_EGL_STREAM, NULL);
|
egl_stream = meta_egl_create_stream_attrib (egl, egl_display, stream_attribs,
|
||||||
|
error);
|
||||||
/*
|
if (egl_stream == EGL_NO_STREAM_KHR)
|
||||||
* HACK: Use a (as far as I can tell) undocumented hack by passing
|
|
||||||
* EGL_WAYLAND_BUFFER_WL to eglQueryWaylandBufferWL. If it happens to be a
|
|
||||||
* dummy EGLStream buffer, we'll get a EGLStream file descriptor.
|
|
||||||
*
|
|
||||||
* FIXME: At some point, replace this with the EGL_WL_wayland_eglstream
|
|
||||||
* extension.
|
|
||||||
*/
|
|
||||||
if (!meta_egl_query_wayland_buffer (egl, egl_display, buffer->resource,
|
|
||||||
EGL_WAYLAND_BUFFER_WL, &stream_fd,
|
|
||||||
error))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (stream_fd == EGL_NO_FILE_DESCRIPTOR_KHR)
|
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR,
|
g_set_error (error, G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_FAILED,
|
||||||
"Stream already used with other wl_buffer");
|
"Failed to create stream from wl_buffer resource");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
egl_stream = meta_egl_create_stream_from_file_descriptor (egl, egl_display, stream_fd,
|
stream = g_object_new (META_TYPE_WAYLAND_EGL_STREAM, NULL);
|
||||||
error);
|
|
||||||
close (stream_fd);
|
|
||||||
if (egl_stream == EGL_NO_STREAM_KHR)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
stream->egl_stream = egl_stream;
|
stream->egl_stream = egl_stream;
|
||||||
stream->buffer = buffer;
|
stream->buffer = buffer;
|
||||||
|
|
||||||
return g_steal_pointer (&stream);
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user