Commit Graph

352 Commits

Author SHA1 Message Date
Lionel Landwerlin
00ea695ce2 winsys: glx: fix crash when inspecting onscreens
An unallocated onscreen might have a NULL winsys field.

https://bugzilla.gnome.org/show_bug.cgi?id=754888
2015-09-11 17:34:39 +02:00
Lionel Landwerlin
4cb750928e winsys: wayland: destroy eglsurface when destroying associated native window
On Wayland deinit() of an onscreen buffer is going to destroy the
associated native window of an EGLSurface. So we should destroy the
EGLSurface as well otherwise we might end up confusing the GL driver.

We also currently guard against setting a EGL_NO_SURFACE as current
EGLSurface, but this shouldn't be a problem if we have a surfaceless
context. So we allow surface destruction under that condition.

https://bugzilla.gnome.org/show_bug.cgi?id=754667
2015-09-07 17:27:50 +01:00
Ray Strode
6bd49c3dc8 kms-winsys: don't disable page flipping on EACCES
If the user switches VTs in the middle of a page flip, the
page flip operation may fail with EACCES. page flipping will
work next time the VT becomes active, so we shouldn't disable
page flipping in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=754540
2015-09-03 17:29:28 -04:00
Ray Strode
78c44ab132 kms-winsys: clean up error handling in _cogl_winsys_renderer_connect
If cogl fails to open the drm device, initialize gbm, or open the
egl display, then it closes the drm fd, uninitializes gbm, closes the
display and then calls _cogl_winsys_renderer_disconnect which does
most of those things again, on the, now deinitialized, members.

This commit removes the explicit failure handling in renderer_connect and
defers cleanup to disconnect.

https://bugzilla.gnome.org/show_bug.cgi?id=754540
2015-09-03 17:29:28 -04:00
Ray Strode
181176bdb1 kms-winsys: use correct surface format
gbm confusingly has two different format types, and cogl
is using the wrong one in some of its calls to gbm_surface_create

This commit fixes the calls that are wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=754540
2015-09-03 17:29:27 -04:00
Marek Chalupa
e7f54e6e60 egl-kms: append output after we know we found it
Otherwise we just append NULL output which is wrong and can
break things

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=752406
2015-07-28 15:32:51 +01:00
Adel Gadllah
4f8254f1ae winsys-glx: Add error traps in create_context
Both create_gl3_context and glXCreateNewContext can fail with an X error.

https://bugzilla.gnome.org/show_bug.cgi?id=742678
2015-07-26 16:04:14 +02:00
Emmanuele Bassi
812aba31e7 winsys: Drop xlib_get_visual_info from the vtable
We don't need the hack any more; CoglRenderer has the appropriate API
for the Xlib-based winsys backends.
2015-07-22 20:28:19 +01:00
Emmanuele Bassi
e79d571453 Store the XVisualInfo in the X11-based winsys backends
Instead of freeing it after creating the relative GL contexts, store it
in the CoglXlibRenderer data.
2015-07-22 20:20:05 +01:00
Emmanuele Bassi
3290240600 egl-x11: Fix compiler warnings
Stereo mode changed two fields in the winsys vtable, so we need to
update the signature of the implementation in the EGL-X11 winsys.
2015-06-10 15:20:17 +01:00
Ray Strode
68d9ba3b65 kms-winsys: try to hobble along if driver doesn't support page flips
Some drivers ( like mgag200 ) don't yet support drmModePageFlip.

This commit forgoes waiting for vblank and flips right away
in those cases. That prevents the hardware from freezing up the screen,
but does mean there will be some visible tearing.

https://bugzilla.gnome.org/show_bug.cgi?id=746042
2015-03-23 10:11:46 -04:00
Rui Matos
f82e9e2d22 kms-winsys: Remove a few unused variables 2015-02-23 18:36:56 +00:00
Rui Matos
200c4032ac kms-winsys: Defer setting new surfaces until swap buffers
We can't just destroy and replace the EGL and gbm surfaces while
they are still in use i.e. while there is a pending flip. In fact, in
that case, we were calling gbm_surface_destroy() on a surface that
still had the front buffer locked and then, on the flip handler,
gbm_surface_release_buffer() for a buffer that didn't belong to the
new surface.

Instead, we still allocate new surfaces when requested but they only
replace the old ones on the next swap buffers when we're sure that the
previous flip has been handled and buffers properly released.
2015-02-23 18:36:56 +00:00
Chris Wilson
5ccd2825c7 glx: Precisely wait for the next vblank
Currently the code queries the current msc then tries to approximate the
value of the next msc satisfing the modulus 2 for when to wait. This
introduces some instability as the msc may tick over during the
roundtrip leading to a 32ms wait instead of a 16ms wait. This happens
often enough to cause jerky animations, and affect gnome-shell-perf-tool.

A simpler solution is just use a single roundtrip by using WaitForMsc to
ask the driver to compute the next vblank itself.

Cc: Owen W. Taylor <otaylor@fishsoup.net>
Cc: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Robert Bragg <robert@sixbynine.org>
2015-02-04 19:31:40 +00:00
Rui Matos
b9640c091f wayland-winsys: Provide a wl_registry.global_remove callback
Otherwise libwayland-client will abort() when we get that event.

https://bugzilla.gnome.org/show_bug.cgi?id=743594
2015-01-30 16:05:41 +01:00
Rui Matos
c36e31401d kms-winsys: Mark the framebuffer to be bound when setting a new layout
We need to bind the context to the new EGL surface we just created.

https://bugzilla.gnome.org/show_bug.cgi?id=741881
2015-01-30 16:05:41 +01:00
Marco Trevisan (Treviño)
cd9676380f mir: use output names that are more conformat to the one used by Xmir
And by X itself...
2014-12-12 18:45:49 +01:00
Marco Trevisan (Treviño)
bc83282f4f mir: add renderer event listener support 2014-12-10 15:33:35 +01:00
Marco Trevisan (Treviño)
2872695fa7 mir: don't always allocate when getting the mir surface
Add proper documentation on header file
2014-12-09 22:01:32 +01:00
Marco Trevisan (Treviño)
7c71a06936 mir: fix mir surface recreation on resize, bind and update pointers
don't try to read from free'd memory allocation, copy stuff before
deinitializing the old onscreen.

Also, don't try to resize a foreign surface.
2014-12-09 20:22:53 +01:00
Marco Trevisan (Treviño)
a9a923c6f3 mir: correctly init/clear mutex and use prgname for surface 2014-12-09 20:16:36 +01:00
Marco Trevisan (Treviño)
1016fb64de mir: return proper surface / connection only when valid, without failing 2014-12-09 20:13:39 +01:00
Marco Trevisan (Treviño)
a144087085 mir: release surfaces on errors 2014-11-21 18:00:49 +01:00
Marco Trevisan (Treviño)
6aaeab0460 mir: add public method to resize a cogl onscreen
This will internally recreate a new surface with proper parameters
2014-11-21 18:00:10 +01:00
Marco Trevisan (Treviño)
77e28d4a77 mir: only allow to set foreign surfaces with hardware buffer
And return a CoglBool accordingly.
2014-11-20 07:18:26 +01:00
Marco Trevisan (Treviño)
8e6997db44 mir: return whether a foreign connection has been set or not 2014-11-20 07:17:19 +01:00
Marco Trevisan (Treviño)
e06a0b3d10 mir: release a connection on error 2014-11-18 22:16:38 +01:00
Marco Trevisan (Treviño)
b26466ad54 mir: improve error logging 2014-11-18 22:11:24 +01:00
Marco Trevisan (Treviño)
e5fd82e2a1 mir: use standard c types 2014-11-18 16:28:17 +01:00
Marco Trevisan (Treviño)
1cbc1c67a0 mir: add support for Mir Outputs 2014-11-17 18:50:30 +01:00
Marco Trevisan (Treviño)
a948c25116 mir: update the framebuffer size on resize events
We need to use a mutex as mir handles these on
different threads, also using an event idle prevents
to get initialization errors on cogl side.
2014-11-17 17:47:23 +01:00
Marco Trevisan (Treviño)
62f3f56d29 mir: set last state after initializing the surface 2014-11-17 17:45:59 +01:00
Marco Trevisan (Treviño)
1b9380ef3c mir: add support for foreign surfaces 2014-11-17 16:08:59 +01:00
Marco Trevisan (Treviño)
a3ae538c45 mir: add support for foreign display 2014-11-17 15:59:29 +01:00
Marco Trevisan (Treviño)
672eff0c6c cogl: add Mir EGL platform 2014-11-17 15:49:20 +01:00
Owen W. Taylor
4d8771a8c2 CoglTexturePixmapX11: add support for stereo content
Add cogl_texture_pixmap_x11_new_left() and
cogl_texture_pixmap_x11_new_right() (which takes the left texture
as an argument) for texture pixmap rendering with stereo content.
The underlying GLXPixmap is created using a stereo visual and shared
between the left and right textures.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-17 19:27:13 -04:00
Owen W. Taylor
d16df5a5aa Add support for setting up stereo CoglOnscreens
If we want to show quad-buffer stereo with Cogl, we need to pick an
appropriate fbconfig for creating the CoglOnscreen objects. Add
cogl_onscreen_template_set_stereo_enabled() to indicate whether
stereo support is needed.

Add cogl_framebuffer_get_stereo_mode() to see if a framebuffer was
created with stereo support.

Add cogl_framebuffer_get_stereo_mode() to pick whether to draw to
the left, right, or both buffers.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-17 19:27:05 -04:00
Adel Gadllah
d9afc6dada kms-winsys: Add api that tells cogl to ignore a crtc
An application might for whatever reason want to control a specific output
directly and have cogl only swap the other outputs if any. So add an api that
allows setting a crtc to be ignored.

https://bugzilla.gnome.org/show_bug.cgi?id=730536
2014-06-30 20:26:05 +02:00
Adel Gadllah
fe183554ca kms_winsys: Add cogl_kms_renderer_get_gbm api
Applications might want to get the underlying gbm device so add a getter for it.

https://bugzilla.gnome.org/show_bug.cgi?id=730536
2014-06-30 20:25:52 +02:00
Neil Roberts
52a646abc5 Use the EGL_KHR_surfacless_context extension
The surfaceless context extension can be used to bind a context
without a surface. We can use this to avoid creating a dummy surface
when the CoglContext is first created. Otherwise we have to have the
dummy surface so that we can bind it before the first onscreen is
created.

The main awkward part of this patch is that theoretically according to
the GL and GLES spec if you first bind a context without a surface
then the default state for glDrawBuffers is GL_NONE instead of
GL_BACK. In practice Mesa doesn't seem to do this but we need to be
robust against a GL implementation that does. Therefore we track when
the CoglContext is first used with a CoglOnscreen and force the
glDrawBuffers state to be GL_BACK.

There is a further awkward part in that GLES2 doesn't actually have a
glDrawBuffers state but GLES3 does. GLES3 also defaults to GL_NONE in
this case so if GLES3 is available then we have to be sure to set the
state to GL_BACK. As far as I can tell that actually makes GLES3
incompatible with GLES2 because in theory if the application is not
aware of GLES3 then it should be able to assume the draw buffer is
always GL_BACK.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
(cherry picked from commit e5f28f1e75db9bdc4f2688f420a74f908f96cf76)

Conflicts:
	cogl/winsys/cogl-winsys-egl-kms.c
	cogl/winsys/cogl-winsys-egl-x11.c
2014-06-17 13:31:03 +01:00
Kristian Høgsberg
22378d572b cogl-winsys-egl-kms: Call swap notify handler even when pageflip ioctl fails
This can happen when we dpms off the output or when login1 takes away
drm master status from our drm fd.  In either case, we need to call
the swap notify handler so that the compositor dosn't get stuck waiting
for that notification.  The compositor should stop repainting shortly in
both cases, as it's either going into dpms off mode or vt switching away.

https://bugzilla.gnome.org/show_bug.cgi?id=728979

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-04-30 16:41:09 +01:00
Kristian Høgsberg
8fb9cea451 cogl-winsys-egl-kms: Never set EGL_PLATFORM
This environment variable predates the reliable platform detection in mesa
and typically just causes crashes when the specified platform doesn't
match what's passed in.  Aside from being unecessary and problematic
it also leaks into the GNOME session, preventing clients from
automatically detecting the wayland platform.

https://bugzilla.gnome.org/show_bug.cgi?id=728978

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-04-30 16:41:06 +01:00
Lionel Landwerlin
1b2dd815b4 Registers gtypes for all public objects and structs
This adds much more comprehensive support for gobject-introspection
based bindings by registering all objects as fundamental types that
inherit from CoglObject, and all structs as boxed types.

Co-Author: Robert Bragg <robert@linux.intel.com>

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 18:27:12 +00:00
Robert Bragg
804082abd3 Expose EGL context/display and GLX context
To help facilitate integration with third party frameworks this exposes
the EGL context and display to applications as well as the GLX context.
(Note that the GLX display is already available via
cogl_xlib_renderer_get_display())

This adds a new top-level <cogl/cogl-glx.h> header that needs to be
included explicitly to access the glx specific api.

Anyone using these apis will be responsible for checking that Cogl
is indeed using EGL or GLX by calling cogl_renderer_get_winsys_id()

This will enable GStreamer, for example, to be able to create a GL
context that shares resources with Cogl's context.

https://bugzilla.gnome.org/show_bug.cgi?id=724992

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
081acdc146 move GLeglImageOES define into cogl-egl-private.h
This splits out the GLeglImageOES define in cogl-egl.h into a private
cogl-egl-private.h header and updates the guards in cogl-egl.h to be
consistent with other top-level headers where we need to be careful
about how __COGL_H_INSIDE__ is defined and undefined, esp when the
gobject introspection scanner is running.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
dca992a160 egl: remove NativeWindowType/NativeDisplayType defines
This ensures we use EGLNativeWindowType and EGLNativeDisplayType
everywhere instead. The previous names come from EGL 1.2 but it seems
reasonable to require more recent EGL versions. If someone wanted to add
compatibility for EGL 1.2 later it would be straightforward to define
the new names to the old.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
2beb7c40e0 sdl2: fix GL driver selection
SDL2 supports selecting between full OpenGL or OpenGL ES 1/2 but our
selection code was written before SDL 2.0 was officially released and
since then a new SDL_GL_CONTEXT_PROFILE_MASK attribute was added and
we have to explicitly set the SDL_GL_CONTEXT_MINOR_VERSION attribute.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
ad9db72f74 Expose COGL_FEATURE_ID_BUFFER_AGE feature id
This adds a new COGL_FEATURE_ID_BUFFER_AGE feature id that can be used
to determine if cogl_onscreen_get_buffer_age() will ever return an age
other than 0. This should be used instead of querying the winsys feature
via cogl_clutter_winsys_has_feature().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
beebbfc625 glx-feature-functions: update misleading comment
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
3917690f5a egl: fix incorrect #ifdef guarding of features
We have an #ifdef EGL_WL_bind_wayland_display guard in
cogl-winsys-egl-feature-functions.h to avoid referencing wayland types
when the EGL header doesn't know about them, but somehow this guard also
ended up around the KHR_create_context and EXT_buffer age features too
even though they aren't wayland specific.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:01 +00:00