Commit Graph

63 Commits

Author SHA1 Message Date
Marek Olšák 0b56e23e7f egl/dri2: use the correct screen index
Required for multi-GPU configuration where each GPU has its own X screen.
2014-09-01 20:09:19 +02:00
Sarah Sharp c524f3ef91 egl: Add EGL_CHROMIUM_sync_control extension.
Chromium defined a new GL extension (that isn't registered with Khronos).
We need to add an EGL extension for it, so we can migrate ChromeOS on
Intel systems to use EGL instead of GLX.

http://git.chromium.org/gitweb/?p=chromium/src/third_party/khronos.git;a=commitdiff;h=27cbfdab35c601f70aa150581ad1448d0401f447

The EGL_CHROMIUM_sync_control extension is similar to the GLX extension
OML_sync_control, but only defines one function,
eglGetSyncValuesCHROMIUM, which is equivalent to glXGetSyncValuesOML.

http://www.opengl.org/registry/specs/OML/glx_sync_control.txt

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Cc: Jamey Sharp <jamey@minilop.net>
Cc: Ian Romanick <idr@freedesktop.org>
Cc: Stéphane Marchesin <stephane.marchesin@gmail.com>
2014-05-20 15:19:48 -07:00
Emil Velikov 5f280d0c44 egl_dri: rework dri extension handling
Use designated initialisers, and store the extensions pointers as const.

The loader extensions __DRIdri2LoaderExtension and __DRIswrastLoaderExtension
are setup by the platform backends so they should not be constified.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-04-28 19:13:38 +01:00
Chad Versace 6d1f83ec09 egl/main: Stop using EGLNative types internally
Internally, much of the EGL code uses EGLNativeDisplayType,
EGLNativeWindowType, and EGLPixmapType. However, the EGLNative type
often does not match the variable's actual type.

The concept of EGLNative types are a bad match for Linux, as explained
below. And the EGL platform extensions don't use EGLNative types at all.
Those extensions attempt to solve cross-platform issues by moving the
EGL API away from the EGLNative types.

The core of the problem is that eglplatform.h can define each EGLNative
type once only, but Linux supports multiple EGL platforms.

To work around the problem, Mesa's eglplatform.h contains multiple
definitions of each EGLNative type, selected by feature macros. Mesa
expects EGL clients to set the feature macro approrpiately. But the
feature macros don't work when a single codebase must be built with
support for multiple EGL platforms, *such as Mesa itself*.

When building libEGL, autotools chooses the EGLNative typedefs based on
the first element of '--with-egl-platforms'. For example,
'--with-egl-platforms=x11,drm,wayland' defines the following:

    typedef Display* EGLNativeDisplayType;
    typedef Window   EGLNativeWindowType;
    typedef Pixmap   EGLNativePixmapType;

Clearly, this doesn't work well for Wayland and GBM.  Mesa works around
the problem by casting the EGLNative types to different things in
different files.

For sanity's sake, and to prepare for the EGL platform extensions, this
patch removes from egl/main and egl/dri2 all internal use of the
EGLNative types. It replaces them with 'void*' and checks each explicit
cast with a static assertion. Also, the patch touches egl_gallium the
minimal amount to keep it compatible with eglapi.h.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:39:23 -07:00
Chad Versace eef68a9094 egl/dri2: Dispatch eglCreateImageKHR by display, not driver
Add dri2_egl_display_vtbl::create_image, set it for each platform, and
let egl_dri2 dispatch eglCreateImageKHR to that.

To remove ambiguity, rename egl_dri2.c:dri2_create_image() to
dri2_create_image_from_dri().

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:39:23 -07:00
Chad Versace eadd5e0c0a egl/dri2: Dispatch eglCreateWaylandBufferFromImageWL by display, not driver
Add dri2_egl_display_vtbl::create_wayland_buffer_from_image, set it for
each platform, and let egl_dri2 dispatch
eglCreateWaylandBufferFromImageWL to that.

This prepares for the EGL platform extensions.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:39:22 -07:00
Chad Versace 688a0e8e73 egl/dri2: Dispatch eglPostSubBufferNV by display, not driver
Add dri2_egl_display_vtbl::post_sub_buffer, set it for each
platform, and let egl_dri2 dispatch eglPostSubBufferNV to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:04 -07:00
Chad Versace 75d398ed93 egl/dri2: Dispatch eglSwapBuffersRegionNOK by display, not driver
Add dri2_egl_display_vtbl::swap_buffers_region, set it for each
platform, and let egl_dri2 dispatch eglSwapBuffersRegionNOK to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:04 -07:00
Chad Versace bc2cbc0951 egl/dri2: Dispatch eglCopyBuffers by display, not driver
Add dri2_egl_display_vtbl::copy_buffers, set it for each
platform, and let egl_dri2 dispatch eglCopyBuffers to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:04 -07:00
Chad Versace 3fdfbd2572 egl/dri2: Dispatch API.QueryBufferAge by display, not driver
Add dri2_egl_display_vtbl::query_buffer_age, set it for each
platform, and let egl_dri2 dispatch API.QueryBufferAge to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:04 -07:00
Chad Versace 958dd80c40 egl/dri2: Dispatch eglDestroySurface by display, not driver
Add dri2_egl_display_vtbl::destroy_surface, set it for each
platform, and let egl_dri2 dispatch eglDestroySurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:04 -07:00
Chad Versace bf20076baf egl/dri2: Dispatch eglCreatePbufferSurface by display, not driver
Add dri2_egl_display_vtbl::create_pbuffer_surface, set it for each
platform, and let egl_dri2 dispatch eglCreatePbufferSurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:04 -07:00
Chad Versace bc8b07a657 egl/dri2: Dispatch eglCreatePixmapSurface by display, not driver
Add dri2_egl_display_vtbl::create_pbuffer_surface, set it for each
platform, and let egl_dri2 dispatch eglCreatePixmapSurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:04 -07:00
Chad Versace 0a0c881a13 egl/dri2: Dispatch eglCreateWindowSurface by display, not driver
Add dri2_egl_display_vtbl::create_window_surface, set it for each
platform, and let egl_dri2 dispatch eglCreateWindowSurface to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:03 -07:00
Chad Versace d03948a766 egl/dri2: Dispatch eglSwapBuffersWithDamage by display, not driver
Add dri2_egl_display_vtbl::swap_buffers_with_damage, set it for each
platform, and let egl_dri2 dispatch eglSwapBuffersWithDamageEXT to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:03 -07:00
Chad Versace ad173bcfdb egl/dri2: Dispatch eglSwapBuffers by display, not driver
Add dri2_egl_display_vtbl::swap_buffers, set it for each platform, and
let egl_dri2 dispatch eglSwapBuffers to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:03 -07:00
Chad Versace 8b9298af0a egl/dri2: Dispatch eglSwapInterval by display, not driver
Add dri2_egl_display_vtbl::swap_interval, set it for each platform, and
let egl_dri2 dispatch eglSwapInterval to that.

This prepares for the EGL platform extensions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:03 -07:00
Chad Versace 90502b18b2 egl/dri2: Move dri2_egl_display virtual funcs to vtbl
dri2_egl_display has only one virtual function, 'authenticate'.  Define
dri2_egl_display::vtbl and move 'authenticate' there.

This prepares for the EGL platform extensions, which will add many
more virtual functions to dri2_egl_display.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2014-03-17 15:36:03 -07:00
Emil Velikov 8d4357b5ba egl_dri2: use loader util lib
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-01-18 18:47:49 +00:00
Neil Roberts 0b7058c46a egl_dri2: Remove the unused swap_interval member of dri2_egl_surface
The _EGLSurface struct which is embedded into dri2_egl_surface also contains a
swap interval member so the other member is redundant. Nothing was using it as
far as I can tell.
2013-12-09 16:14:32 -08:00
Neil Roberts 992a2dbba8 wayland: Add support for eglSwapInterval
The Wayland EGL platform now respects the eglSwapInterval value. The value is
clamped to either 0 or 1 because it is difficult (and probably not useful) to
sync to more than 1 redraw.

The main change is that if the swap interval is 0 then Mesa won't install a
frame callback so that eglSwapBuffers can be executed as often as necessary.
Instead it will do a sync request after the swap buffers. It will block for
sync complete event in get_back_bo instead of the frame callback. The
compositor is likely to send a release event while processing the new buffer
attach and this makes sure we will receive that before deciding whether to
allocate a new buffer.

If there are no buffers available then instead of returning with an error,
get_back_bo will now poll the compositor by repeatedly sending sync requests
every 10ms. This is a last resort and in theory this shouldn't happen because
there should be no reason for the compositor to hold on to more than three
buffers. That means whenever we attach the fourth buffer we should always get
an immediate release event which should come in with the notification for the
first sync request that we are throttled to.

When the compositor is directly scanning out from the application's buffer it
may end up holding on to three buffers. These are the one that is is currently
scanning out from, one that has been given to DRM as the next buffer to flip
to, and one that has been attached and will be given to DRM as soon as the
previous flip completes. When we attach a fourth buffer to the compositor it
should replace that third buffer so we should get a release event immediately
after that. This patch therefore also changes the number of buffer slots to 4
so that we can accomodate that situation.

If DRM eventually gets a way to cancel a pending page flip then the compositors
can be changed to only need to hold on to two buffers and this value can be
put back to 3.

This also moves the vblank configuration defines from platform_x11.c to the
common egl_dri2.h header so they can be shared by both platforms.
2013-12-07 22:36:02 -08:00
Kristian Høgsberg 68bb26bead wayland: Use __DRIimage based getBuffers implementation when available
This lets us allocate color buffers as __DRIimages and pass them into
the driver instead of having to create a __DRIbuffer with the flink
that requires.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Cc: "10.0" <mesa-stable@lists.freedesktop.org>
2013-11-12 16:08:17 -08:00
Eric Anholt f93533d118 dri: Pass in the dlsym()ed driver extension to screen creation.
This will allow a megadrivers build to reference the actual driver being
loaded from the shared dri_util screen creation code.

v2: Fix indentation, fallback case in EGL (review by Emil).

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v1)
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2013-10-24 14:04:20 -07:00
Kristian Høgsberg 44e584a73a egl_dri2: Remove depth argument from dri2_add_config()
All callers now use the more correct rgba mask mechanism for filtering
out mathcing DRI configs.  Even if depth and buffer size match, the
color component layout can be different, or in case or ARGB8888 and
ARGB2101010 the color components can even be different sizes.

Since anything that the depth check would reject is also rejected by
the rgba mask comparison, the depth parameter is redundant and not
specific enough.  We should probably have removed it when the rgba
masks argument was introduced, but better late than never.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2013-10-15 22:07:52 -07:00
Ander Conselvan de Oliveira 8d29b5271a egl: Update to Wayland 1.2 server API
Since Wayland 1.2, struct wl_buffer and a few functions are deprecated.

References to wl_buffer are replaced with wl_resource and some getter
functions and calls to deprecated functions are replaced with the proper
new API. The latter changes are related to resource versioning.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2013-08-07 10:37:58 -07:00
Kristian Høgsberg de315f76a2 wayland: Add prime fd passing as a buffer sharing mechanism
Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
2013-03-18 21:15:41 -04:00
Kristian Høgsberg 664fe6dc84 wayland: allocate a __DRIimage for the color buffer
No functional change here, but this will let us query the image
for an fd handle later.

Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
2013-03-18 21:03:46 -04:00
Kristian Høgsberg 90804e886d egl/wayland: Pull color buffers from dri2_surf->color_buffers pool
We used to keep the color buffers in the dri_buffers array and
swap __DRI_BUFFER_BACK_LEFT and __DRI_BUFFER_FRONT_LEFT around there
and swap third_buffer in in case we needed to triple buffer.  That
gets a little fidgety with all the swaps, so lets use the
color_buffers pool like the gbm platform does.  We track the color buffers,
their corresponding wl_buffer and locked status here and just plug
a free one into dri2_surf->buffers when we need to.

This is a nice clean-up in itself, but it also sets us up to track
buffer age in the color_buffers structs.

Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
2013-01-14 16:39:15 -05:00
Kristian Høgsberg 4e42e569dd egl/gbm: Implement EGL_EXT_buffer_age
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-01-10 15:58:05 -05:00
Kristian Høgsberg b5160a10c0 egl_dri2: Remove unused struct dri2_egl_buffer from header file 2013-01-04 11:20:12 -05:00
Kristian Høgsberg 0229e3ae41 egl/wayland: Update to Wayland 0.99 API
The 0.99.0 Wayland release changes the event API to provide a thread-safe
mechanism for receiving events specific to a subsystem (such as EGL) and
we need to use it in the EGL platform.

The Wayland protocol now also requires a commit request to make changes
take effect, issue that from eglSwapBuffers.
2012-10-17 16:32:13 -04:00
Eric Anholt 7e9bd2b2ed egl: Add support for driconf control of swapinterval.
This behavior mostly matches glx_dri2.  It's slightly complicated in
comparison because EGL exposes the implementation limits in the EGL config.

Note that platform_x11 was the only one setting swap_available, so the move of
the MaxSwapInterval into it is appropriate.

Acked-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09 14:32:03 -07:00
Ian Romanick 7b4b4f8e68 egl_dri2: Add support for EGL_KHR_create_context and EGL_EXT_create_context_robustness
Just like in GLX, EGL_KHR_create_context requires DRI2 version >= 3, and
EGL_EXT_create_context_robustness requires both DRI2 version >= 3 and the
__DRI2_ROBUSTNESS extension.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-08-14 15:41:03 -07:00
Ander Conselvan de Oliveira 4a976b60b1 egl_dri2: use gbm_surface as the native window type in drm platform 2012-03-28 22:14:34 -04:00
Fredrik Höglund 352c889c10 egl_dri2/x11: Add support for the DRI2 SwapBuffers request 2011-12-20 22:11:18 -05:00
Fredrik Höglund 655f2c1d65 egl_dri2/x11: Add support for eglSwapInterval 2011-12-20 22:11:17 -05:00
Benjamin Franzke 2a58453e25 egl_dri2: Fix some valgrind reported leaks
Free the device_name, reported by Pekka Paalanen.

Destroy wayland display and drm resources,
if created by dri2_initialize_wayland.
2011-12-13 15:32:43 +01:00
Chia-I Wu 75cc24c876 android: add support for ICS
With ICS (Android 4.0), several headers and structs are renamed.  Define
ANDROID_VERSION so that we can choose a different path depending on the
platform version.

I've tested only softpipe and llvmpipe.  r600g is also reported to work.
2011-11-25 12:34:33 +08:00
Kristian Høgsberg 7b1d94e5d1 wayland: Track changes to drop wl_visual 2011-08-31 18:33:47 -04:00
Benjamin Franzke f811c1e6d6 egl_dri2: Drop dri2_surface_type enum
Was only used in platform_wayland, and the remaining egl stack
uses _EGLSurface::Type with one of EGL_{WINDOW,PIXMAP,PBUFFER}_BIT.
2011-08-31 11:45:34 +02:00
Chia-I Wu 9779f6f5c1 egl_dri2: add support for Android
Add platform_android.c that supports _EGL_PLAFORM_ANDROID.  It works
with drm_gralloc, where back buffers of windows are backed by GEM
objects.

In Android a native window has a queue of back buffers allocated by the
server, through drm_gralloc.  For each frame, EGL needs to

  dequeue the next back buffer
  render to the buffer
  enqueue the buffer

After enqueuing, the buffer is no longer valid to EGL.  A window has no
depth buffer or other aux buffers.  They need to be allocated locally by
EGL.

Reviewed-by: Benjamin Franzke <benjaminfranzke@googlemail.com>
Reviewed-by: Chad Versace <chad@chad-versace.us>

[olv: with assorted minor changes, mostly suggested during the review]
2011-08-28 21:56:23 +08:00
Chia-I Wu 58911b86a1 egl_dri2: allow RGBA masks to be specified for matching
Add rgba_masks to dri2_add_config.  When it is non-NULL, the DRI config
is accepted only when the offsets and sizes of the its channels match
rgba_mask.

Reviewed-by: Chad Versace <chad@chad-versace.us>
2011-08-28 21:56:22 +08:00
Benjamin Franzke 8c40940321 dri2: Add __DRI_BUFFER_COUNT token
Remove definition from egl_dri2.
Defining this is egl_dri2.h breaks as soon as
a new dri2 buffer token is added like with commit
4501a5d6e8.
2011-08-16 09:06:41 +02:00
Benjamin Franzke 32f4cf3808 egl/gbm: Fix EGL_DEFAULT_DISPLAY 2011-08-04 14:09:34 +02:00
Benjamin Franzke b2d6375e6a egl_dri2: Fix compilation if udev devel files are not installed
NOTE: This is a candidate for the 7.11 branch.
2011-07-02 13:56:27 +02:00
Benjamin Franzke 992680c8b4 egl: Fix Terminate with shared gbm screens
NOTE: This is a candidate for the 7.11 branch.
2011-06-27 10:25:12 +02:00
Benjamin Franzke e5fc4c81ce egl_dri2: Hookup gbm as drm platform 2011-06-23 21:07:17 +02:00
Benjamin Franzke 0cb356dd5c egl_dri2/wayland: Hook up new buffer.release event 2011-06-21 13:11:43 -04:00
Kristian Høgsberg 16a04e019d wayland: Pass use_invalidate extension to driver 2011-06-20 11:05:26 -04:00
Chia-I Wu cf69eeacc6 egl_dri2: add dri2_load_driver_swrast
Refactor dri2_load_driver and add dri2_load_driver_swrast for loading
swrast DRI driver.
2011-06-13 11:11:43 +08:00