Commit Graph

439 Commits

Author SHA1 Message Date
Emil Velikov d42b09580a egl: drop _eglInitImage() return type
Function cannot fail and always returns true.

v2: Inline the one line function in the header

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-06-26 12:40:22 +01:00
Chad Versace cd717cbe1a egl/dri2: Declare loop vars inside the loop
That is, consistently do this:

    for (int i = 0; ...)

No behavioral change.
This patch touches only egl_dri2.c.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-06-22 12:35:49 -07:00
Eric Engestrom b81cfc7340 egl: simplify dri_config conditionals
In the same spirit as 858f2f2ae6 (egl/dri2: ease srgb __DRIconfig
conditionals), let's merge dri_single_config and dri_double_config into
a single dri_config[2].

This moves the `if (double) dri_double_config else dri_single_config`
logic to `dri_config[double]`, reducing code duplication and making it
easier to read.

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-22 14:54:36 +01:00
Eric Engestrom 60f984262c egl: turn boolean `int`s into `bool`s
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-21 21:42:08 +01:00
Harish Krupo 9827547313 egl/android: support for EGL_KHR_partial_update
This patch adds support for the EGL_KHR_partial_update extension for
android platform. It passes 36/37 tests in dEQP for EGL_KHR_partial_update.
1 test not supported.

v2: add fallback for eglSetDamageRegionKHR (Tapani)

v3: The native_window_set_surface_damage call is available only from
    Android version 6.0. Reintroduce the ANDROID_VERSION guard and
    advertise extension only if version is >= 6.0. (Emil Velikov)

v4: use newly introduced ANDROID_API_LEVEL guard rather than
    ANDROID_VERSION guard to advertise the extension.The extension
    is advertised only if ANDROID_API_LEVEL >= 23 (Android 6.0 or
    greater). Add fallback function for platforms other than Android.
    Fix possible math overflow. (Emil Velikov)
    Return immediately when n_rects is 0. Place function's entrypoint
    in alphabetical order. (Eric Engestrom)

v5: Replace unnecessary calloc with malloc (Eric)
    Check for BAD_ALLOC error (Emil)
    Check for error in native_window_set_damage_region. (Emil, Tapani,
    Eric).

Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2017-06-11 01:02:09 +01:00
Daniel Stone 11e549ae3f egl/dri2: Avoid sign extension when building modifier
Since the EGL attributes are signed integers, a straight OR would
also perform sign extension,

Fixes: 6f10e7c37a ("egl/dri2: Create EGLImages with dmabuf modifiers")
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-06-08 22:27:30 +01:00
Varad Gautam 4c412293d0 egl: advertise EGL_EXT_image_dma_buf_import_modifiers
v2: check for DRIimageExtension version 15 (Jason Ekstrand)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-05-30 13:56:20 +01:00
Varad Gautam de3c459bbd egl: implement eglQueryDmaBufModifiersEXT
query and return supported dmabuf format modifiers for
EGL_EXT_image_dma_buf_import_modifiers.

v2: move format check to the driver instead of making format queries
   here and then checking.
v3: Check DRIimageExtension version before query (Daniel Stone)
v4:
- move to DRIimageExtension version 15, check queryDmaBufModifiers before
  calling (Jason Ekstrand)
- pass external_only to the driver instead of setting as EGL_TRUE here
  (Emil Velikov, Daniel Stone)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-05-30 13:56:20 +01:00
Varad Gautam 6719e058d6 egl: implement eglQueryDmaBufFormatsEXT
allow egl clients to query the dmabuf formats supported on this platform.

v2: return EGLBoolean.
v3: Check DRIimageExtension version before querying (Daniel Stone).
v4: move to DRIimageExtension version 15, error checking (Jason Ekstrand).

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-05-30 13:56:20 +01:00
Varad Gautam 6f10e7c37a egl/dri2: Create EGLImages with dmabuf modifiers
Allow creating EGLImages with dmabuf format modifiers when target is
EGL_LINUX_DMA_BUF_EXT for EGL_EXT_image_dma_buf_import_modifiers.

v2:
- clear modifier assembling and error label name (Eric Engestrom)
v3:
- remove goto jumps within switch-case (Emil Velikov)
- treat zero as valid modifier (Daniel Stone)
- ensure same modifier across all dmabuf planes (Emil Velikov)
v4:
- allow modifiers to add extra planes (Louis-Francis Ratté-Boulianne)
v5:
- fix error checking, some cleanups (Jason Ekstrand)
- pass single copy of the modifier to createImageFromDmaBufs2

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-05-30 13:56:20 +01:00
Pekka Paalanen fb2a1c2327 egl/main: add support for fourth plane tokens
The EGL_EXT_dma_buf_import_modifiers extension adds support for a
fourth plane, just like DRM KMS API does.

Bump maximum dma_buf plane count to four.

v2: prevent attribute tokens from being parsed if
    EXT_image_dma_buf_import_modifiers is not suported. (Emil Velikov)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-05-30 13:56:20 +01:00
Pekka Paalanen 9434f057c8 egl: introduce DMA_BUF_MAX_PLANES
Rather than hardcoding 3, use a #define. Makes it easier to bump this
later to 4.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-05-30 13:56:20 +01:00
Gregory Hainaut 3fde8db53a egl: implement __DRIbackgroundCallableExtension.isThreadSafe
v2:
bump version

v3:
Add code comment
s/IsGlThread/IsThread/ (and variation)
Include X11/Xlibint.h protected by ifdef

v5: based on Daniel feedback
Move non X11 code outside of X11 define
Always return true for Wayland

Signed-off-by: Gregory Hainaut <gregory.hainaut@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-05-29 17:06:57 +01:00
Emil Velikov 2c341f2bda egl: refactor dri2_create_screen() into three separate functions
Split the create_screen into:
 - create screen
 - setup/bind extensions
 - setup screen

This will allow us to reuse the latter two on egl/drm. Said platform
does create its own screen and attempts to reinvent the later two
functions itself.

Since the GBM ones tend to get out of sync quite often, and there is no
distinct reason why it does so we'll drop them with latter commits.

v2: disp -> dpy for the Android platform.
v3: use correct goto label (Rob)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Rob Herring <robh@kernel.org>
2017-05-29 16:50:06 +01:00
Emil Velikov 3e73c0245b egl: split out a dri2_display_destroy() helper
Within dri2_display_release() we already tear down all the display
specifics. Within the platform specific dri initialize however we badly
and partially duplicate that.

Let's stop that by fleshing out the required functionality into a helper
and using it throughout the codebase.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Rob Herring <robh@kernel.org>
2017-05-29 16:49:52 +01:00
Tapani Pälli 12196d1b76 egl: check for driver_configs in dri2_display_release
With later commits we'll split and reuse the destroy side of the
function for the initialize_foo error path.

In such cases, driver_configs may be NULL leading to a crash.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
[Emil Velikov: reword commit message]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Rob Herring <robh@kernel.org>
2017-05-29 16:49:49 +01:00
Emil Velikov 628af2bc96 gbm: remove unneeded gbm_drm_device abstraction
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Rob Herring <robh@kernel.org>
2017-05-29 16:49:47 +01:00
Emil Velikov b6643095ba eg: explicitly size dri2_to_egl_attribute_map[]
This way we'll get an implicit zero initialization of the remaining
members, as required by dri2_add_config().

Fixes: e5efaeb85c ("egl: polish dri2_to_egl_attribute_map[]")
Cc: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2017-05-04 18:05:47 +01:00
Emil Velikov e5efaeb85c egl: polish dri2_to_egl_attribute_map[]
Annotate the array as static const and use C99 initialiser to populate
it.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2017-04-29 14:40:09 +01:00
Eric Anholt 3b7b6adf3a egl: Implement __DRI_BACKGROUND_CALLABLE
v2: (Timothy Arceri) use C99 initializers.

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Acked-by: Marek Olšák <maraeo@gmail.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
2017-03-16 14:14:18 +11:00
Kenneth Graunke 4061bbccf2 egl: Ensure ResetNotificationStrategy matches for shared contexts.
Fixes:
dEQP-EGL.functional.robustness.negative_context.invalid_robust_shared_context_creation

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
2017-03-01 10:26:42 -08:00
Rainer Hochecker 09b140abb5 dri: allow 16bit R/GR images to be exported via drm buffers
This allows eglCreateImageKHR to access P010 surfaces created by vaapi

Signed-off-by: Rainer Hochecker <fernetmenta@online.de>
Acked-by: Ben Widawky <ben@bwidawsk.net>
2017-01-23 08:47:15 -08:00
Boyan Ding 868ae3e31b egl/dri2: Unify the style of function pointer calls in structs
Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
[Emil Velikov: address platform_surfaceless]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2017-01-13 16:24:22 +00:00
Jonas Ådahl 36b9976e1f egl/wayland: Avoid race conditions when on non-main thread
When EGL is used on some other thread than the thread that drives the
main wl_display queue, the Wayland EGL dri2 implementation is
vulnerable to a race condition related to display round trips and global
object advertisements.

The race that may happen is that after after a proxy is created, but
before the queue is set, events meant to be emitted via the yet to be
set queue may already have been queued on the wrong queue.

In order to make it possible to avoid this race, wayland 1.11
introduced new API that allows creating a proxy wrapper that may be used
as the factory proxy when creating new proxies via Wayland requests. The
queue of a proxy wrapper can be changed without effecting what queue
events emitted by the actual proxy will be queued on, while still
effecting what default queue proxies created from it will have.

By introducing a wl_display proxy wrapper and using this when performing
round trips (via wl_display_sync()) and retrieving the global objects (via
wl_display_get_registry()), the mentioned race condition is avoided.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-13 15:50:37 +00:00
Rob Clark 0201f01dc4 egl: add EGL_ANDROID_native_fence_sync
With fixes from Chad squashed in, plus fixes for issues that Rafael
found while writing piglit tests.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Tested-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Tested-by: Chad Versace <chadversary@chromium.org>
2016-12-01 10:57:35 -08:00
Christian Gmeiner 0c73a3b7d0 dri: make use of loader_get_extensions_name(..) helper
Changes since v1:
 - removed not needed includes
 - use the loader version of the helper

v2 [Emil Velikov]
 - Keep the includes - they are required.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-15 18:15:16 +00:00
Emil Velikov fb10c89877 Revert "dri: make use of dri_get_extensions_name(..) helper"
This reverts commit 1a21d21580.

Pushed the wrong version of the patch.
2016-11-15 18:15:15 +00:00
Christian Gmeiner 1a21d21580 dri: make use of dri_get_extensions_name(..) helper
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-11-15 15:56:52 +00:00
Emil Velikov aeaf21ab3e Revert "egl: remove explicit config_id management from dri2_add_config()"
This reverts commit 3652d1d594.

Self nack/reject on this one. The base.ConfigID is overwritten
immediately after we store the current value, thus one memcpy [further
down] the wrong value will be copied.
2016-11-09 21:48:50 +00:00
Emil Velikov 3652d1d594 egl: remove explicit config_id management from dri2_add_config()
Currently we only saved the id to memcpy the whole _EGLConfig to write
back the exact same id value.

Remove the unneeded and confusing/misleading code.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-11-09 21:18:48 +00:00
Tapani Pälli b91e1e38e8 egl/dri2: set max values for pbuffer width and height
While these max values were previously fixed for pbuffer creation, this
change makes also eglGetConfigAttrib() return correct values.

Fixes following dEQP tests:

   dEQP-EGL.functional.create_surface.pbuffer.rgb888_no_depth_no_stencil
   dEQP-EGL.functional.create_surface.pbuffer.rgb888_depth_stencil
   dEQP-EGL.functional.create_surface.pbuffer.rgba8888_no_depth_no_stencil
   dEQP-EGL.functional.create_surface.pbuffer.rgba8888_depth_stencil

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98326
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Cc: "12.0 13.0" <mesa-stable@lists.freedesktop.org>
2016-10-25 07:24:11 +03:00
Eric Engestrom 8acb79dfac egl: bring back the default glapi.so name
Earlier commit replaced the default platform specific libglapi.so name
with an #error.

This may have been overzealous since the name is the correct for the BSD
platforms, at least. Reinstate the hunk - bringing back OpenBSD, et al.
to a successful build state.

Fixes: 7a9c92d071 ("egl/dri2: non-shared glapi cleanups")
[Emil Velikov: format the patch from Eric, add commit message and tag.]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2016-10-19 15:09:26 +01:00
Emil Velikov ebffa7b6af Revert "egl/dri2: rework dri2_make_current code flow"
This reverts commit 675719817e.
2016-10-14 16:07:33 +01:00
Emil Velikov fdd373acca egl/dri2: micro optimise dri2_bind_extensions()
Do not loop over all matches if we've already found one.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2016-10-14 12:46:09 +01:00
Emil Velikov 665cad1658 egl/dri2: annotate dri2_extension_match instances as const data
v2: Rebase.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2016-10-14 12:46:05 +01:00
Emil Velikov 3948ad82ce egl/dri2: use dri2_bind_extensions to manage the optional extensions
v2: dri2_bind_extensions() now takes optional as an argument.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2016-10-14 12:46:03 +01:00
Emil Velikov 38526bd468 egl/dri2: add support for optional extensions in dri2_bind_extensions()
Will allow us to reuse the function for optional extensions and fold a
bit of code.

v2: Make dri2_bind_extensions::optional flag an argument to
dri2_bind_extensions (Kristian).

Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-10-14 12:45:24 +01:00
Emil Velikov ebc68e3849 egl/dri2: coding style cleanup
Consistently indent with space rather than a mix of tab and
spaces.

v2: Keep the structs properly aligned (Eric).

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-10-14 12:43:57 +01:00
Emil Velikov f871946594 egl/dri2: rework dri2_egl_display::extensions storage
Remove the error prone fixed size array.
While we're here also rename to loader_extensions like in the GLX code.

v2: Rebase. Keep image_loader_extension within the wayland_drm
dri2_loader_extensions list.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2016-10-14 12:42:22 +01:00
Emil Velikov 675719817e egl/dri2: rework dri2_make_current code flow
Fold duplicate conditional blocks and add a few extra comments ;-)

v2: Bring back the explicit "unbind" logic (Eric), remove NULL derefs.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-10-14 12:17:18 +01:00
Emil Velikov 07690a289a egl/dri2: drop NULL checks prior to dri2_destroy_surface
The function already have the respective check within.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-10-14 12:17:18 +01:00
Emil Velikov 8cf83f9c08 egl/dri2: call static functions directly, not via _EGLDriver::API
The indirection is meant to be used by the core EGL implementation in
main. Not in the drivers themselves.

Move the dri2_destroy_surface definition to avoid forward declaration of
the static function.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-14 12:16:08 +01:00
Emil Velikov 532ec2edd8 egl/dri2: use dri2_egl_display inline wrapper where possible
This way the only places that reference DriverData are the ones that
manipulate it.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-14 12:16:07 +01:00
Emil Velikov d6dcf3b4ca egl/dri2: bail out on NULL dpy in dri2_display_release()
Currently all callers are careful enough not to do that, yet that will
not be the case in the future.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-14 12:16:06 +01:00
Emil Velikov 8fb9ea413d egl/dri2: move surface refcounting out of the platform code
All the platforms are duplicating what should be a driver/dri2 thing -
refcounting. Just fold it accordingly.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-14 12:16:05 +01:00
Emil Velikov 02f1158746 egl/dri2: coding style fix
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-14 12:16:04 +01:00
Emil Velikov 7a9c92d071 egl/dri2: non-shared glapi cleanups
For a while now we require shared glapi for EGL, thus we can drop a
few bits from the olden days. Namely - dlopen(NULL...) is not possible,
error out at build stage if so and drop the guard around dlclose().

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-14 12:16:03 +01:00
Emil Velikov b349c11098 egl/dri2: glFlush is not optional, treat it as such
The documentation is clear - one must glFlush the old context on
eglMakeCurrent. Thus keeping it optional is not something we should be
doing. Furthermore if we cannot get the entry point we're likely having
a broken setup/stack.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-10-14 12:16:00 +01:00
Chad Versace 8044885182 egl: Unify the EGLint/EGLAttrib paths in eglCreateSync* (v3)
Pre-patch, there were two code paths for parsing EGLSync attribute
lists: one path for old-style EGLint lists, used by eglCreateSyncKHR,
and another for new-style EGLAttrib lists, used by eglCreateSync (1.5)
and eglCreateSync64 (EGL_KHR_cl_event2).

There were two attrib_list parsing functions,
  _eglParseSyncAttribList(_EGLSync *sync, const EGLint *attrib_list)
  _eglParseSyncAttribList64(_EGLSync *sync, const EGLattrib *attrib_list)
This patch unifies the two attrib_list parsing functions into one,
  _eglParseSyncAttribList(_EGLSync *sync, const EGLattrib *attrib_list)

Many internal EGLSync function signatures had *two* attrib_list
parameters to accomodate both code paths: one parameter was an EGLint
list and other an EGLAttrib list. At most one of the parameters was
allowed to be non-null.  This patch removes the `EGLint *attrib_list`
parameter, leaving only the `EGLAttrib *attrib_list` parameter, for all
internal EGLSync functions.

v2:
  - Consistently use condition (sizeof(int_list[0]) ==
    sizeof(attrib_list[0])). [for emil]
v3:
  - Don't double-unlock the display in eglCreateSyncKHR.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com> (v2)
2016-10-10 09:54:11 -07:00
Tapani Pälli 4d6d55deef egl: stop claiming support for pbuffer + msaa
This fixes a crash in egl-create-msaa-pbuffer-surface Piglit test
and same crash in many dEQP EGL tests.

I also found that some Qt example did a workaround because of this
crash: https://bugreports.qt.io/browse/QTBUG-47509

v2: Ian pointed out that v1 removed support for all multisample
    configs, including window ones. This one removes pbuffer bit
    when adding configs, now only pbuffer+msaa gets rejected and
    window+msaa continues to work. Fixed also comment (Emil)

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2016-10-03 07:56:44 +03:00
Chuanbo Weng 9e8de866f7 egl: return corresponding offset of EGLImage instead of 0.
The offset should not always be 0. For example, if EGLImage is
created from a 2D texture with EGL_GL_TEXTURE_LEVEL=1, then the
offset should be the actual start of miplevel 1 in bo.

v2: Add version check of __DRIimageExtension implementation
(Suggested by Axel Davy).

v3: Don't add version check of __DRIimageExtension implementation.
Set the offset only when queryImage() succeeds. (Suggested by Emil
Velikov)

Signed-off-by: Chuanbo Weng <chuanbo.weng@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
[Emil Velikov: coding style fixes]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2016-09-21 12:19:19 +01:00
Adam Jackson d9f5b1915b egl: Rename MESA_configless_context bit to KHR_no_config_context
Keep the old name in the extension string, but refer to the KHR
extension internally.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-09-12 11:29:09 -04:00
Frank Binns d6f669ba83 egl: only store device name when Wayland support is built
The device name is only needed for WL_bind_wayland_display so make this clear
by only storing the device name when Wayland support is built.

Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-09-01 15:47:58 +01:00
Emil Velikov 03eaa6c596 egl/dri2: check if the EGL API is valid before adding it to ClientAPIs
In the rather unlikely case that the API is considered invalid, don't
add it to the (supported) ClientAPIs bitmask.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>

---
Strictly speaking we only need this in the Android case for OpenGL.
Adding it everywhere doesn't hurt us since the compiler will const
propagate and optimise/remove these.
2016-08-30 14:50:10 +01:00
Nicolas Boichat 4f3f8bb59d egl/dri2: dri2_initialize: Do not reference-count TestOnly display
In the case where dri2_initialize is called with a TestOnly display,
the display is not actually initialized, so dri2_egl_display always
fails, and we cannot do any reference counting.

Fixes piglit spec@egl_khr_create_context@verify gl flavor (reproducible
with LIBGL_ALWAYS_SOFTWARE=1).

Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reported-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-08-23 18:08:17 +01:00
Dongwon Kim c6e97aaf75 egl/dri2: remove error checks on return values from mtx_lock and cnd_wait
This removes unnecessary error checks on return result of mtx_lock
and cnd_wait calls as in all other places in MESA source since there
is no chance that any of these functions return any of error codes
in current implementation.

This patch also removes a redundent _eglError call that follows
EGL_FALSE check in the bottom of dri2_client_wait_sync.

Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-08-23 12:00:45 +01:00
Nicolas Boichat 78e3cea419 egl/dri2: dri2_make_current: Release previous context's display
eglMakeCurrent can also be used to change the active display. In that
case, we need to decrement ref_count of the previous display (possibly
destroying it), and increment it on the next display.

Also, old_dsurf/old_rsurf cannot be non-NULL if old_ctx is NULL, so
we only need to test if old_ctx is non-NULL.

v2: Save the old display before destroying the context.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97214
Fixes: 9ee683f877 (egl/dri2: Add reference count for dri2_egl_display)
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Reported-by: Alexandr Zelinsky <mexahotabop@w1l.ru>
Tested-by: Alexandr Zelinsky <mexahotabop@w1l.ru>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
2016-08-16 17:30:35 +09:00
Haixia Shi a7c6993a33 egl: android: query native window default width and height (v2)
On android platform, the width and height of a native window surface may
be updated after initialization. It is therefore necessary to query android
framework for the current width and height.

v2: remove Android specific #ifdef's and just implement the fallback directly
if the platform query_surface() callback is not provided.

TEST=dEQP-EGL.functional.resize.surface_size#* on cyan-cheets

Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org> (v1)
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Chad Versace <chad@kiwitree.net>
Change-Id: I673f7d2f1d90c3bf572b30f63da537f2cae1496e
2016-08-09 15:49:28 -07:00
Nicolas Boichat 9ee683f877 egl/dri2: Add reference count for dri2_egl_display
android.opengl.cts.WrapperTest#testGetIntegerv1 CTS test calls
eglTerminate, followed by eglReleaseThread. A similar case is
observed in this bug: https://bugs.freedesktop.org/show_bug.cgi?id=69622,
where the test calls eglTerminate, then eglMakeCurrent(dpy, NULL, NULL, NULL).

With the current code, dri2_dpy structure is freed on eglTerminate
call, so the display is not initialized when eglReleaseThread calls
MakeCurrent with NULL parameters, to unbind the context, which
causes a a segfault in drv->API.MakeCurrent (dri2_make_current),
either in glFlush or in a latter call.

eglTerminate specifies that "If contexts or surfaces associated
with display is current to any thread, they are not released until
they are no longer current as a result of eglMakeCurrent."

However, to properly free the current context/surface (i.e., call
glFlush, unbindContext, driDestroyContext), we still need the
display vtbl (and possibly an active dri dpy connection). Therefore,
we add some reference counter to dri2_egl_display, to make sure
the structure is kept allocated as long as it is required.

One drawback of this is that eglInitialize may not completely reinitialize
the display (if eglTerminate was called with a current context), however,
this seems to meet the EGL spec quite well, and does not permanently
leak any context/display even for incorrectly written apps.

Cc: "12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-07-28 14:08:25 +01:00
Nicolas Boichat 9bebef4034 egl/dri2: dri2_make_current: Set EGL error if bindContext fails
Without this, if a configuration is, say, available only on GLES2/3, but
not on GLES1, and is rejected by the dri module's bindContext call,
eglMakeCurrent fails with error "EGL_SUCCESS".

In this patch, we set error to EGL_BAD_MATCH, which is what CTS/dEQP
dEQP-EGL.functional.surfaceless_context expect.

Cc: "11.2 12.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2016-07-20 15:10:33 +01:00
Yaakov Selkowitz 5d303867f5 Use correct names for dlopen()ed files on Cygwin
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-07-15 19:46:54 +01:00
Emil Velikov 13faddb6b8 mesa_glinterop: remove mesa_glinterop typedefs
As is there are two places that do the typedefs - dri_interface.h and
this header. As we cannot include the former in here, just drop the
typedefs and use the struct directly (as needed).

This is required because typedef redefinition is C11 feature which is
not supported on all the versions of GCC used to build mesa.

v2: Kill the typedef alltogether, as per Marek.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96236
Cc: Vinson Lee <vlee@freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2016-05-30 17:53:44 +01:00
Emil Velikov e384d75b12 mesa_glinterop: make GL interop version field bidirectional
This allows clear and easy communication between the two.

Caller: Requesting information (struct vN)
Callee: I know how to deal with older version (vN-1) only. Here is your
data and the version I support.
Caller: Older version ? Sure I'll cap all access to the fields provided
by the older version (vN-1)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Tested-by: Tom Stellard <thomas.stellard@amd.com>
2016-05-24 23:03:00 +01:00
Emil Velikov 38ef6f5f60 egl: android: directly use dri2_create_image_dma_buf()
Make the function non static so that we can use it directly from the
android platform code.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
2016-05-23 12:07:47 +01:00
Matt Turner 53f64a8404 egl/dri2: Don't check return result of mtx_unlock().
Coverity (CID 1358496) warns that the cleanup code doesn't unlock the
mutex (which is arguably kind of stupid, since the only case that can
happen is when mtx_unlock() failed!). But, mtx_unlock() isn't going to
fail -- the mutex was locked by this thread just a few lines above it.
2016-05-18 11:09:37 -07:00
Marek Olšák b6eda70843 egl: implement EGL part of interop interface (v2)
v2: - use const
2016-04-20 12:18:47 +02:00
Dongwon Kim 70299474f5 egl: add EGL_KHR_reusable_sync to egl_dri
This patch enables an EGL extension, EGL_KHR_reusable_sync.
This new extension basically provides a way for multiple APIs or
threads to be excuted synchronously via a "reusable sync"
primitive shared by those threads/API calls.

This was implemented based on the specification at

https://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_reusable_sync.txt

v2
- use thread functions defined in C11/threads.h instead of
  using direct pthread calls
- make the timeout set with reference to CLOCK_MONOTONIC
- cleaned up the way expiration time is calculated
- (bug fix) in dri2_client_wait_sync, case EGL_SYNC_CL_EVENT_KHR
  has been added.
- (bug fix) in dri2_destroy_sync, return from cond_broadcast
  call is now stored in 'err' intead of 'ret' to prevent 'ret'
  from being reset to 'EGL_FALSE' even in successful case
- corrected minor syntax problems

v3
- dri2_egl_unref_sync now became 'void' type. No more error check
  is needed for this function call as a result.
- (bug fix) resolved issue with duplicated unlocking of display in
  eglClientWaitSync when type of sync is "EGL_KHR_REUSABLE_SYNC"

Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
2016-04-05 15:24:57 +02:00
Emil Velikov 54702c2fa1 egl/dri2: expose srgb configs when KHR_gl_colorspace is available
Otherwise the user has no way of using it, and we'll try to access the
linear one.

v2:
 - Bail out when KHR_gl_colorspace is missing and srgb is set (Marek)

Cc: Chih-Wei Huang <cwhuang@android-x86.org>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
Fixes: c2c2e9ab604(egl: implement EGL_KHR_gl_colorspace (v2))
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91596
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Tested-by: Mauro Rossi <issor.oruam@gmail.com>
2016-01-22 11:55:54 +00:00
Martin Peres 4518eea065 egl: make it clear which platform x11 backend is being used (dri2 or 3)
Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Boyan Ding <boyan.j.ding@gmail.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.co.uk>
2015-11-17 17:26:20 +02:00
Boyan Ding f35198bade egl/x11: Implement dri3 support with loader's dri3 helper
v2: From Martin Peres
 - Tell we are compiling the dri3 backend in configure.ac
 - Update the Makefile.am
 - get rid of the LIBDRM_HAS_RENDERNODE_SUPPORT macro
 - fix some warnings related to EGLuint64KHR to int64_t conversions
 - use dri2_get_dri_config to get the __DRIconfig instead of open-coding it
 - replace the occasional tabs with spaces

v3: From Martin Peres
 - fix and indent problem (Matt Turner)
 - drop the authenticate function, use NULL in the vtable instead (Emil)
 - drop some useless includes (Emil Velikov)
 - mandate libdrm (Emil Velikov)
 - link to xcb-dri3 (Kristian Høgsberg)
 - convert to the new loader interface for drwable (Kristian)
 - remove some dead code after the dropping of some vfuncs (Kristian)
 - add a comment on the topic of rendering to the frontbuffer

v4: From Martin Peres
 - do not expose the preserved swap behavior (Acked by Eric Anholt)

Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.co.uk>
2015-11-17 17:26:20 +02:00
Boyan Ding a25df54571 egl_dri2: Add a function to let platform code return dri drawable from _EGLSurface
dri3 for EGL will use different struct other than dri2_egl_surface for
an EGL surface, the common code only uses __DRIdrawable from that
struct, so instead of converting _EGLSurface to dri2_egl_surface, let
the platform code return the __DRIdrawable by its own (although the
current platforms use the same function).

v2: From Martin Peres
 - convert to the new drawable interface (Kristian)

Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.co.uk>
2015-11-17 17:26:20 +02:00
Matt Turner 164c8277f0 egl/dri2: Properly dereference array.
Fixes a regression that broke EGL since

commit 858f2f2ae6
Author: Emil Velikov <emil.l.velikov@gmail.com>
Date:   Sun Sep 13 12:25:27 2015 +0100

    egl/dri2: ease srgb __DRIconfig conditionals
2015-10-07 11:48:49 -07:00
Emil Velikov 858f2f2ae6 egl/dri2: ease srgb __DRIconfig conditionals
One can simplify the if-else chain, by declaring the driconfigs as a
two sized array, whist using srgb as a index to the correct entry.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
2015-10-07 15:17:57 +01:00
Varad Gautam deb1765ec6 egl: move memcpy to bring conf->base operations together
Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Suggested-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-10-07 15:05:28 +01:00
Varad Gautam f988eff379 egl: restore surface type before linking config to its display
commit c2c2e9a (egl: implement EGL_KHR_gl_colorspace (v2)) leaves
_EGLConfig->SurfaceType set incorrectly before calling _eglLinkConfig(),
and the bad value is passed around to platform_android. set it to zero
as earlier.

v2: Set SurfaceType to 0, rather than surface_type (Suggested by Emil)

Cc: mesa-stable@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91596
Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-10-07 15:05:20 +01:00
Marek Olšák 18123a732b egl/dri2: don't require a context for ClientWaitSync (v2)
The spec doesn't require it. This fixes a crash on Android.

v2: don't set any flags if ctx == NULL
v3: add the spec note

Cc: 10.6 11.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Albert Freeman <albertwdfreeman@gmail.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
2015-10-03 22:06:08 +02:00
Emil Velikov a1ac742f70 egl/dri2: don't leak the fd on dri2_terminate
Currently the check was incorrect as it did not consider the (unlikely)
case of fd == 0. In order to fix this we should first correctly
initialize it to -1, as the swrast implementations leave it set to zero
(props to calloc()).

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Boyan Ding <boyan.j.ding@gmail.com>
2015-09-15 12:39:02 +01:00
Boyan Ding 63c4b7ee1e egl_dri2: Add support for EGL_KHR_create_contest when using swrast
This requires swrast version >= 3. Also EGL_EXT_create_context_robostness
is supported if __DRI2_ROBUSTNESS extension is found.

Reference: https://bugs.freedesktop.org/show_bug.cgi?id=80821
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
2015-09-09 11:26:48 +01:00
Boyan Ding 6345d2da60 egl_dri2: Use createContextAttribs if swrast version >= 3
v2: Change return type of the new function from int to bool

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
2015-09-09 11:25:55 +01:00
Boyan Ding b9ea608c1a egl_dri2: Move filling context_attrib array in a separate function
v2: Change return type of the new function from int to bool

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
2015-09-09 11:25:18 +01:00
Alexander von Gluck IV ba651967a2 egl/dri2: Fix include path of u_atomic.h introduced e7e29189
This was causing a failure to build on SCons due to a missing
-Isrc/egl. Instead of adding in that path, lets just -Isrc/
and include "utils/u_atomic.h".

Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-08-07 14:31:25 -05:00
Frank Binns cfc3200a35 egl/dri: Add error info needed for EGL_EXT_image_dma_buf_import extension
Update the DRI image interface error codes to reflect the needs of the
EGL_EXT_image_dma_buf_import extension. This means updating the existing error
code documentation and adding a new __DRI_IMAGE_ERROR_BAD_ACCESS error code
so that drivers can correctly reject unsupported pitches and offsets. Hook
the new error code up in EGL to return EGL_BAD_ACCESS.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-08-04 20:03:16 -07:00
Emil Velikov fa109d02dd egl/wayland: libdrm is a hard requirement, treat it as such
Prompt at configure time if it's missing otherwise we'll fail later on
in the build. Remove ambiguous HAVE_LIBDRM guard.

Cc: 10.6 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-08-01 15:41:23 +01:00
Emil Velikov 57c670a823 egl: consolidate ifdef HAVE_LIBDRM blocks
Move the code around rather than having it scattered. No functional
change.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
2015-08-01 15:41:19 +01:00
Chad Versace fd865d56d2 egl: Add support for DRM_FORMAT_R8, RG88, and GR88
The Kodi/XBMC developers want to transcode NV12 to RGB with OpenGL shaders,
importing the two source planes through EGL_EXT_image_dma_buf_import. That
requires importing the Y plane as an R8 EGLImage and the UV plane as either an
RG88 or GR88 EGLImage.

This patch teaches the driver-independent part of EGL about the new
formats. Real driver support is left for follow-up patches.

The new formats landed in airlied's kernel branch 'drm-next' on July 24.

Tested-by: Peter Frühberger <peter.fruehberger@gmail.com>
Signed-off-by: Chad Versace <chad.versace@intel.com>
2015-07-28 11:43:28 -07:00
Marek Olšák 4f57ccd02d egl,dri_interface: use DRI2rendererQueryExtension to enable 3D textures & sRGB
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-07-22 23:56:00 +02:00
Marek Olšák c2c2e9ab60 egl: implement EGL_KHR_gl_colorspace (v2)
v2: add missing "break"

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-07-22 23:56:00 +02:00
Emil Velikov dc1ece3748 egl: remove flatten HAVE_SHARED_GLAPI
It is simply not possible to use the dri backend without shared glapi,
as the alternative provider (libGL) is not always present. We have fixed
the build for a while now, so we can rip this out.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-07-22 16:35:26 +01:00
Julien Isorce e27ea99644 egl/dri2: load libglapi.0.dylib on osx
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90903
Signed-off-by: Julien Isorce <j.isorce@samsung.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-07-08 13:19:33 +01:00
Anatoli Antonovitch b193f2b9b6 egl: implement EGL_KHR_gl_texture_3D_image
Most of the code has been in place already.
2015-07-03 16:23:28 +02:00
Boyan Ding 052b3d4e2f egl_dri2: Remove trailing whitespaces
Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2015-06-26 17:05:21 +00:00
Haixia Shi 6b8accb36b egl/dri2: implement platform_surfaceless
The surfaceless platform is for off-screen rendering only. Render node support
is required.

Only consider the render nodes. Do not use normal nodes as they require
auth hooks.

v3: change platform_null to platform_surfaceless
v4: make libdrm required for surfaceless
v5: remove modified include guards with defined(HAVE_SURFACELESS_PLATFORM)
v6: use O_CLOEXEC for drm fd

Signed-off-by: Haixia Shi <hshi@chromium.org>
Signed-off-by: Zach Reizner <zachr@google.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2015-06-16 13:55:26 -07:00
Eric Anholt 932d1613d1 egl: Drop check for driver != NULL.
Back in 2013, a patch was added (with 2 reviewers!) at the end of the
block to early exit the loop in this case, without noticing that the loop
already did.  I added another early exit case, again without noticing, but
Rob caught me.  Just drop the loop condition that apparently surprises
most of us, instead of leaving the end of the loop conspicuously not
exiting on success.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
2015-06-15 10:32:23 -07:00
Chih-Wei Huang c3b5afbd4e android: try to load gallium_dri.so directly
This avoids needing hardlinks between all of the DRI driver .so names,
since we're the only loader on the system.

v2: Add early exit on success (like previous block) and log message on
    failure.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-06-09 12:25:15 -07:00
Marek Olšák d333d30632 egl: use EGL 1.5 types without suffixes
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2015-06-05 19:44:33 +02:00
Brian Paul 54070a9d1d egl/dri2: silence uninitialized variable warnings
And update assertions to be more informative.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-06-01 07:42:04 -06:00
Axel Davy 13fa84e1bc egl/swrast: Enable config extension for swrast
Enables to use dri config for swrast, like vblank_mode.

Reviewed-by: Dave Airlie <airlied@redhat.com>

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-05-11 19:31:44 +02:00
Axel Davy cdcfe48fb0 egl/wayland: Implement swrast support
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-05-11 19:31:44 +02:00
Axel Davy 6aaf09b93b egl/wayland: properly destroy wayland objects
the wl_registry and the wl_queue allocated weren't destroyed.

CC: 10.5 <mesa-stable@lists.freedesktop.org>

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>

Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-05-11 19:31:43 +02:00
Chad Versace a6bfdd7b46 egl/dri2: Fix codestyle in a comment
Pointed out by Kenneth Graunke. Trivial fix.
2015-05-07 08:09:07 -07:00
Chad Versace b0f410a2a0 egl/dri2: Check return value of __DRI2fence::create_fence()
If it returns NULL, then return early with an error.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2015-05-06 07:55:41 -07:00
Dave Airlie b5045e2991 egl: image_dma_buf_export - use KHR 64-bit type
After talking to Jon Leech he suggested this should be fine.

update spec to the version in the registry.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-05-05 12:19:40 +10:00
Marek Olšák 290a3eb750 egl/dri2: implement EGL_KHR_cl_event2 (v2)
v2: fix the SYNC_CONDITION query
2015-04-30 14:38:38 +02:00
Marek Olšák a8617cc042 egl/dri2: implement EGL_KHR_wait_sync 2015-04-30 14:38:38 +02:00
Marek Olšák 9a0bda2430 egl/dri2: implement EGL_KHR_fence_sync 2015-04-30 14:38:38 +02:00
Marek Olšák 396cbabbef egl/dri: don't expose configs with an accumulation buffer 2015-04-30 14:38:38 +02:00
Dave Airlie 8f7338f284 egl: add initial EGL_MESA_image_dma_buf_export v2.4
At the moment to get an EGL image to a dma-buf file descriptor,
you have to use EGL_MESA_drm_image, and then use libdrm to
convert this to a file descriptor.

This extension just provides an API modelled on EGL_MESA_drm_image,
to return a dma-buf file descriptor.

v2: update spec for new API proposal
add internal queries to get the fourcc back from intel driver.

v2.1: add gallium pieces.

v2.2: add offsets to spec and API, rename fd->fds, stride->strides
in API. rewrite spec a bit more, add some q/a

v2.3:
add modifiers to query interface and 64-bit type for that (Daniel Stone)
specifiy what happens to num fds vs num planes differences. (Chad Versace)

v2.4:
fix grammar (Daniel Stone)

Signed-off-by: Dave Airlie <airlied@redhat.com>
2015-04-01 14:10:04 +10:00
Emil Velikov bf0e4d219a egl/drivers: include stdint.h where needed
Currently these files are including it indirectly via eglcompiler.h
The latter of which will be removed with follow up commits.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2015-03-05 14:45:54 +00:00
Axel Davy 63986f9580 egl: Soften several HAVE_DRM_PLATFORM to HAVE_LIBDRM
To fix build when libdrm is not found,
commit a594cec7e3 did put several
parts of egl code under #ifdef HAVE_DRM_PLATFORM.

HAVE_DRM_PLATFORM means the egl drm platform is being built.
What should have been used instead is HAVE_LIBDRM.

At a few locations, the HAVE_DRM_PLATFORM introduced
have already been replaced by HAVE_LIBDRM, this patch
replaces the remaining occurences.

This patch makes for example EGL_EXT_image_dma_buf_import
be advertised by egl under x11 when the drm egl platform
is not built, whereas previously it required the drm egl
platform to be built.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-02-12 13:20:22 +00:00
Eric Anholt 70e8ccc459 egl: Inform the client API when ancillary buffers may become undefined.
This is part of the EGL spec, and is useful for a tiled renderer to avoid
the memory bandwidth cost of storing the depth/stencil buffers.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-01-06 15:40:40 -08:00
Matt Turner 0b4a688691 egl/dri2: Log a warning if no platforms are enabled.
If you hit this, you didn't compile with --with-egl-platforms=...

Recompile with something like --with-egl-platforms=x11,drm and make
clean and make again.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2014-12-04 15:13:51 -08:00
Emil Velikov 8ed08e69bc egl_dri2: add a note about dri2_create_screen
The function is not called by platform_drm. As such one needs to
pay special attention at teardown.

v2: Fix the comment block. Spotted by Ken.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-and-tested-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
2014-11-07 18:31:23 +00:00
Emil Velikov 38cec0303b egl_dri2: fix double free on drm platforms
Earlier commit failed to attribure that for drm platforms one does not
call dri2_create_screen, thus it does not create the screen and
driver_configs but inherits them from the "display" - gbm.

As such wrap cleanup in Platform != _EGL_PLATFORM_DRM to prevent
the issue and still cleanup correctly for non-drm platforms.

v2:
 - Drop the ifdef HAVE_DRM_PLATFORM, reindent the code and fix the
comment block. Suggested by Ken.

Reported-by: Kenneth Graunke <kenneth@whitecape.org>
Reported-by: Mark Janes <mark.a.janes@intel.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-and-tested-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
2014-11-07 18:29:08 +00:00
Emil Velikov ba0bb4227e egl_dri2: do not leak dri2_dpy->driver_configs
Walk through the list and free each config, and finally free the list
itself. Freeing approx 20KiB of memory, according to valgrind.
Inspired by a similar patch by enpeng xu.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-11-06 13:23:51 +00:00
Ilia Mirkin 1f4bc0c95e egl: don't exit process on initialization failure
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-08-16 17:52:54 -04:00
Pekka Paalanen 08264e5dad egl_dri2: fix EXT_image_dma_buf_import fds
The EGL_EXT_image_dma_buf_import specification was revised (according to
its revision history) on Dec 5th, 2013, for EGL to not take ownership of
the file descriptors.

Do not close the file descriptors passed in to eglCreateImageKHR with
EGL_LINUX_DMA_BUF_EXT target.

It is assumed, that the drivers, which ultimately process the file
descriptors, do not close or modify them in any way either. This avoids
the need to dup(), as it seems we would only need to just close the
dup'd file descriptors right after.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76188
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
2014-08-14 21:30:57 +03:00
Giovanni Campagna e57ad3d38c dri: Add a new capabilities for drivers that can't share buffers
The kms-dri swrast driver cannot share buffers using the GEM,
so it must tell the loader to disable extensions relying on
that, without disabling the image DRI extension altogether
(which would prevent the loader from working at all).
This requires a new gallium capability (which is queried on
the pipe_screen and for swrast drivers it's forwarded to the
winsys), and requires a new version of the DRI image extension.

[Emil Velikov]
 - Rebased on top of gallium-dri megadrivers.
 - Drop PIPE_CAP_BUFFER_SHARE and sw_winsys::get_param hook.
The can_share_buffer cap is set at InitScreen. We use a different
InitScreen (and thus value for the cap) function for kms_dri, due to
deeper differences originating from dri megadrivers.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-07-30 16:43:41 +01:00
Matt Turner 6ac5adce63 egl: Remove unused variable dri_driver_path.
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2014-06-17 10:18:12 -07:00
Emil Velikov 5cb1cad0ae egl/dri2: do not leak dri2_dpy->driver_name
Originally all hardware drivers duplicate the driver_name string
from an external source, while for the software rasterizer we set
it to "swrast". Follow the example set by hw drivers this way
we can free the string at dri2_terminate().

v2: Use strdup over strndup. Suggested by Ilia Mirkin.
v3: Handle platform_drm in a similar manner. Cleanup swrast
driver_name in error path.

Cc: Chia-I Wu <olv@lunarg.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-06-09 22:56:00 +01:00
Emil Velikov 6638c55838 egl_dri2: fix wayland_platform when drm_platform is not set
The build fails with implicit delaration of drmGetCap (xf86drm.h)
Were we're including the header only when building the DRM_PLATFORM.

Wayland backend can operate without DRM_PLATFORM so replace the
guard, and fold in drmGetCap() usage to silence compiler warnings.

Cc: Chad Versace <chad.versace@linux.intel.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-05-29 20:01:03 +01: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 a3e78bab7f egl_dri2: cleanup memory leak in dri2_create_context()
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2014-05-10 02:09:02 +01: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
Emil Velikov 9b42fd1772 dri_interface: Update __DRItexBufferExtensionRec to version 3
With commit e59fa4c46c8("dri2: release texture image.") we updated the
extension without bumping the version number. The patch itself added an
interface required to enable texture_from_pixmap on certain platforms.

The new code was effectively never build, as it depended on
__DRI_TEX_BUFFER_VERSION >= 3, which never came to be in upstream mesa.

This commit bumps the version number, drops the __DRI_TEX_BUFFER_VERSION
checks and resolves all the build conflicts. Additionally it add a version
check as egl and dri3, as require version 2 of the extension which does
not have the releaseTexBuffer hook.

Cc: Juan Zhao <juan.j.zhao@intel.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
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:11:27 +01:00
Ander Conselvan de Oliveira 17860309f1 egl: Protect use of gbm_dri with ifdef HAVE_DRM_PLATFORM
Otherwise it fails to compile if the drm egl platform is disabled.

Cc: "10.0" "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-04-25 21:17:54 +01:00
Jonathan Gray 0295953c5d egl/dri2: don't require libudev to build drm/wayland platforms
After the loader changes libudev is no longer required to
build gbm or the egl drm/wayland platforms.

Remove a libudev ifdef which allows the the drm egl driver
to be loaded on OpenBSD.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Cc: "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-04-05 13:33:48 +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 f506ef6784 egl/dri2: Consolidate eglTerminate
egl_dri2.c:dri2_terminate() handled terminating X11 and DRM displays.
The Wayland platform implemented its own dri2_wl_terminate(), which was
nearly a copy of the common one.

To implement the EGL platform extensions, we either need to dispatch
eglTerminate per display or define a common implementation for all
platforms. This patch chooses consolidation.  It removes
dri2_wl_terminate() by folding it into the common dri2_terminate().

It was necessary to invert the `if (disp->PlatformDisplay == NULL)` and
the switch statement because, unlike DRM and X11, Wayland's terminator
performed action even when EGL didn't own the native display. In the
inversion, I replaced `disp->PlatformDisplay == NULL` with
`dri2_dpy->own_device` because the two expressions are synonymous, but
the latter's meaning is clearer.

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
Neil Roberts 551d459af4 Add the EGL_MESA_configless_context extension
This extension provides a way for an application to render to multiple
surfaces with different buffer formats without having to use multiple
contexts. An EGLContext can be created without an EGLConfig by passing
EGL_NO_CONFIG_MESA. In that case there are no restrictions on the surfaces
that can be used with the context apart from that they must be using the same
EGLDisplay.

_mesa_initialze_context can now take a NULL gl_config which will mark the
context as ‘configless’. It will memset the visual to zero in that case.
Previously the i965 and i915 drivers were explicitly creating a zeroed visual
whenever 0 is passed for the EGLConfig. Mesa needs to be aware that the
context is configless because it affects the initial value to use for
glDrawBuffer. The first time the context is bound it will set the initial
value for configless contexts depending on whether the framebuffer used is
double-buffered.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2014-03-12 14:40:47 -07:00
Quanxian Wang 1413a09f34 egl: break instead of looping after driver is found
Stop searching for a driver after success.

Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
Reviewed-By: Gong, Zhigang <zhigang.gong@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2013-12-19 12:44:11 -07:00
Samuel Thibault a594cec7e3 EGL: fix build without libdrm
This fixes building EGL without libdrm support.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2013-11-10 22:11:42 +01: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
Eric Anholt a64bb7553a egl: Add an optional function call for getting the DRI driver interface.
v2: Fix asprintf error checking.

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
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
Kristian Høgsberg 1d34927061 wayland: Only pass wl_drm instance to gbm when using gbm platform 2013-10-11 15:30:09 -07:00
Kristian Høgsberg 360a141f24 wayland: Don't rely on static variable for identifying wl_drm buffers
Now that libEGL has been fixed to not leak all kinds of symbols, gbm
links to its own copy of the libwayland-drm.a helper library.  That means
we can't rely on comparing the addresses of a static vtable symbol in that
library to determine if a wl_buffer is a wl_drm_buffer.  Instead, we
move the vtable into the wl_drm struct and use that for comparing.

https://bugs.freedesktop.org/show_bug.cgi?id=69437

Cc: 9.2 <mesa-stable@lists.freedesktop.org>
2013-10-11 15:14:35 -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
Topi Pohjolainen 20de7f9f22 egl/dri2: support for creating images out of dma buffers
v2:
   - upon success close the given file descriptors

v3:
   - use specific entry for dma buffers instead of the basic for
     primes, and enable the extension based on the availability
     of the hook

v4 (Chad):
   - use ARRAY_SIZE
   - improve the comment about the number of file descriptors
   - in case of invalid format report EGL_BAD_ATTRIBUTE instead
     of EGL_BAD_MATCH
   - take into account specific error set by the driver.

v5:
   - fix error handling

v6 (Chad):
   - fix invalid plane count checking

v7 (Chad):
   - fix indentation and reset loop counter before checking
     for excess attributes

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2013-08-02 08:56:03 +03:00
Ian Romanick 74cbe6e497 egl: Drop configs with unknown or invalide __DRI_ATTRIB_RENDER_TYPE
Some render types, such as floating-point, aren't valid with EGL.
Return NULL in those cases to drop them.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2013-07-18 16:03:42 -07:00
Tomasz Lis c37c367d38 dri: Introduce new flags in __DRI_ATTRIB_RENDER_TYPE
Mark __DRI_ATTRIB_FLOAT_MODE as deprecated, and introduce new flags to
__DRI_ATTRIB_RENDER_TYPE for float modes.  Both signed float
(fbconfig_float) and unsigned (packed_float) are introduced. The old
attribute should be set for both float modes.

v2 (idr): Require that the render mode from the DRI attributes matches the
render mode of the config exactly.  This is the behavior of the old code.

Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-07-18 16:03:42 -07:00
Rob Bradford 15e64de9e6 wayland: Make eglQueryBufferWL succeed for width and height requests too
Following the addition of the EGL_WIDTH and EGL_HEIGHT this function should
return EGL_TRUE for those requested attributes too.
2013-05-02 16:46:04 -04:00
Chad Versace d3dfce3276 egl/dri2: Fix min/max swap interval of configs
The commit below exposed a bug in dri2_add_config.

    commit 3998f8c6b5
    Author: Ralf Jung <post@ralfj.de>
    Date:   Tue Apr 9 14:09:50 2013 +0200

	egl/x11: Fix initialisation of swap_interval

This little code snippet near the bottom of dri2_add_config,

    if (double_buffer) {
       ...
       conf->base.MinSwapInterval = dri2_dpy->min_swap_interval;
       conf->base.MaxSwapInterval = dri2_dpy->max_swap_interval;
    }

it never did what it claimed to do. The assignment never changed the value
of conf->base.MaxSwapInterval, because dri2_dpy->max_swap_interval was,
until the above exposing commit, unitialized here. That is,
conf->base.MaxSwapInterval was 0 before and after assignment. Ditto for
the min swap interval.

Above the troublesome code snippet, the call to _eglFilterArray rejects
the config as unmatching if its swap interval bounds differ from the base
config's.  Before the exposing commit, at the call to _eglFilterArray, the
swap interval bounds were always [0,0], and hence no config was rejected
due to swap interval.

After the exposing commit, _eglFilterArray incorrectly rejected some
configs, which prevented dri2_egl_config::dri_double_config from getting
set for the rejected config, which resulted in a NULL pointer getting
passed into dri2CreateNewDrawable, and then segfault.

The solution: set the swap interval bounds before _eglFilterArray.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63447
Tested-by: Lu Hua <huax.lu@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2013-04-24 08:05:13 +02:00
Kristian Høgsberg 1670737436 egl_dri2: Lower __DRI_IMAGE version requirement back to 1
We check the extension version manually instead and verify that we have
the createImageFromFds function before enabling prime fd passing.
2013-03-19 16:13:38 -04: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
Ian Romanick 68a147e9a9 egl: Allow 24-bit visuals for 32-bit RGBA8888 configs
Previously only the 32-bit X visual would match the 32-bit RGBA8888
configs.  This resulted in every config with alpha getting the "magic"
visual whose alpha is used by the compositor.  This also resulted in no
multisample visuals being advertised.  How many ways could we lose?

This patch inverts the problem... now you can't get the visual with
alpha used by the compositor even if you want it.  I think we need to
invent a new value for EGL_TRANSPARENT_TYPE that apps can use to get
this.  I'm surprised that there isn't already a choice for
EGL_TRANSPARENT_ALPHA.

NOTE: This is a candidate for the 9.1 branch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Tested-by: Tian Ye <yex.tian@intel.com>
Acked-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59783
2013-02-26 09:42:31 -08:00
José Fonseca 5048e69392 egl/dri: Don't invoke dri2_dpy->flush if it's NULL.
I'd like to test Mesa OpenGL ES along side with NVIDIA libGL drivers. But
without this change, I get a NULL pointer dereference.

Reviewed-by: Brian Paul <brianp@vmware.com>
2013-02-06 09:22:26 +00:00
Vinson Lee 080e91aa07 egl/dri2: Fix memory leak.
Fixes resource leak defect reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
2013-02-01 22:50:34 -08:00
Abdiel Janulgue 7b7af48e01 dri2: Create image from texture
Add create image from texture extension and bump version.

v8: - Add appropriate image errors codes in DRI interface so we don't
      have to use internal EGL functions in driver. Suggested by Chad Versace.

Reviewed-by: Eric Anholt <eric@anholt.net> (v6)
Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v8)
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
2013-02-01 11:58:12 -08:00
Ian Romanick d786bf2c2a egl/dri2: Fix typo in the previous commit
I didn't notice this due to a noobed piglit run.  It wasn't previously
noticed because the patch was only run on a driver that supported GLES3.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2013-01-15 14:19:04 -08:00
Chad Versace eb09940e55 egl/dri2: Add plumbing for EGL_OPENGL_ES3_BIT_KHR
Fixes error EGL_BAD_ATTRIBUTE in the tests below on Intel Sandybridge:
    * piglit egl-create-context-verify-gl-flavor, testcase OpenGL ES 3.0
    * gles3conform, revision 19700, when runnning GL3Tests with -fbo

This plumbing is added in order to comply with the EGL_KHR_create_context
spec. According to the EGL_KHR_create_context spec, it is illegal to call
eglCreateContext(EGL_CONTEXT_MAJOR_VERSION_KHR=3) with a config whose
EGL_RENDERABLE_TYPE does not contain the EGL_OPENGL_ES3_BIT_KHR. The
pertinent
portion of the spec is quoted below; the key word is "respectively".

  * If <config> is not a valid EGLConfig, or does not support the
    requested client API, then an EGL_BAD_CONFIG error is generated
    (this includes requesting creation of an OpenGL ES 1.x, 2.0, or
    3.0 context when the EGL_RENDERABLE_TYPE attribute of <config>
    does not contain EGL_OPENGL_ES_BIT, EGL_OPENGL_ES2_BIT, or
    EGL_OPENGL_ES3_BIT_KHR respectively).

To create this patch, I searched for all the ES2 bit plumbing by calling
`git grep "ES2_BIT\|DRI_API_GLES2" src/egl`, and then at each location
added a case for ES3.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-01-15 13:45:54 -08:00
Chad Versace 5cf8536690 egl/dri2: Set error code when dri2CreateContextAttribs fails
When dri2CreateContextContextAttribs failed, eglCreateContext returned
NULL yet set the error code to EGL_SUCCESS! The problem was that
eglCreateContext ignored the error code returned by
driCreateContextAttribs.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56706
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2012-11-19 08:18:22 -08: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
Matt Turner 6bda027e01 Use calloc instead of malloc/memset-0
This patch has been generated by the following Coccinelle semantic
patch:

@@
expression E;
identifier I;
@@
- I = malloc(E);
+ I = calloc(1, E);
...
- memset(I, 0, sizeof *I);

Reviewed-by: Brian Paul <brianp@vmware.com>
2012-09-05 22:28:50 -07:00
Matt Turner 5067506ea6 Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic
patch:

// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it

@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free(E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
type T;
@@
+ free ((T) E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free((T) E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
-   free (E);
- }

@@
expression E;
type T;
@@
+ free ((T) E);
- if (unlikely (E != NULL)) {
-   free ((T) E);
- }

Reviewed-by: Brian Paul <brianp@vmware.com>
2012-09-05 22:28:50 -07:00
Jakob Bornecrantz 6a7dea93fa dri: Rework planar image interface
As discussed with Kristian on #wayland. Pushes the decision of components into
the dri driver giving it greater freedom to allow t to implement YUV samplers
in hardware, and which mode to use.

This interface will also allow drivers like SVGA to implement YUV surfaces
without the need to sub-allocate and instead send 3 seperate buffers for each
channel, currently not implemented.

I have tested these changes on Gallium Svga. Scott tested them on both intel
and Gallium Radeon. Kristan and Pekka tested them on intel.

v2: Fix typo in dri2_from_planar.
v3: Merge in intel changes.

Tested-by: Scott Moreau <oreaus@gmail.com>
Tested-by: Pekka Paalanen <ppaalanen@gmail.com>
Tested-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
2012-08-31 19:51:02 +02:00
Paulo Alcantara b41f36bde7 egl_dri2: Fix segmentation fault
The segmentation fault occurs when DRI2 is not loaded up and
dri2_setup_screen() function deferences dri2_dpy->dri2 (since it's NULL
at this point).

This patch fixes the segmentation fault by checking if dri2 pointer is
not NULL before deferencing it.

Signed-off-by: Paulo Alcantara <pcacjr@profusion.mobi>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Brian Paul <brianp@vmware.com>
2012-08-23 09:17:23 -06:00
Ian Romanick dbecb41300 egl: Allow OpenGL ES 3.0 as a version
In the DRI2 back-end this will get the same API as GLES 2.0.

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
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
Ian Romanick 9d76ad2fac egl_dri2: Silence warnings about missing initializers
egl_dri2.c: At top level:
egl_dri2.c:325:4: warning: missing initializer [-Wmissing-field-initializers]
egl_dri2.c:325:4: warning: (near initialization for 'swrast_driver_extensions[2].version') [-Wmissing-field-initializers]
egl_dri2.c:330:4: warning: missing initializer [-Wmissing-field-initializers]
egl_dri2.c:330:4: warning: (near initialization for 'swrast_core_extensions[1].version') [-Wmissing-field-initializers]

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
Ian Romanick 3fd79dd988 egl: Rename ClientVersion to ClientMajorVersion, add ClientMinorVersion
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
Ian Romanick ce55741cbc egl_dri2: Use createContextAttribs if DRI2 version >= 3
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-08-14 15:41:02 -07:00
Ian Romanick 38f91f2b08 egl_dri2: Require DRI2 version 2
The extra block in dri2_create_context is to prevent extra white space noise
in the next patch.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-08-14 15:41:02 -07:00
Ian Romanick b50703aea5 egl: Replace KHR_surfaceless_* extensions with KHR_surfaceless_context
KHR extension name is reserved for Khronos ratified extensions, and there is
no such thing as EGL_KHR_surfaceless_{gles1,gles2,opengl}.  Replace these
three extensions with EGL_KHR_surfaceless_context since that extension
actually exists.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-08-06 15:37:04 -07:00
Ian Romanick cb77f5dd1f egl_dri2: Refactor dereference of dri2_ctx_shared
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-08-06 15:37:04 -07:00
Ian Romanick 05413ddb1d egl_dri2: Remove swrast version >= 2 checks
Since support for swrast version 2 was added (f55d027a), it has also been
required.  In swrast_driver_extensions, version 2 is set for __DRI_SWRAST
extension.  Remove the spurious version checks sprinked through the code.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-08-06 15:37:04 -07:00
Kristian Høgsberg d7522ed130 wayland: Support EGL_WIDTH and EGL_HEIGHT queries for wl_buffer
We're going to make the public wl_buffer struct as small as possible.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2012-07-19 14:03:17 -04:00
Kristian Høgsberg e23bfdb329 wayland: Use existing EGL_TEXTURE_FORMAT for querying wl_buffer texture format
We also reuse EGL_TEXTURE_RGBA and EGL_TEXTURE_RGB, adding only the new
planar YUV texture formats: EGL_TEXTURE_Y_U_V_WL, EGL_TEXTURE_Y_UV_WL and
EGL_TEXTURE_Y_XUXV_WL.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2012-07-19 14:03:17 -04:00
Kristian Høgsberg e6a33570b7 egl: Add EGL_WAYLAND_PLANE_WL attribute
This lets us specify the plane to create the image for for multiplanar
wl_buffers.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2012-07-11 15:28:36 -04:00
Kristian Høgsberg 1aaec8c609 wayland-drm: Add protocol to create planar buffers 2012-07-11 15:28:35 -04:00
Kristian Høgsberg 379eb47ea6 wayland-drm: Pass struct wl_drm_buffer to the driver
We're going to extend this to support multi-plane buffers, so pass this
to the driver so it can access the details.
2012-07-11 15:28:35 -04:00
Kristian Høgsberg 5f5746a692 egl_dri2: Reorganize the EGLImage constructors to share more code
We factor out all the EGL book-keeping into dri2_create_image() and
simplify the wayland case by using dupImage.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2012-07-05 14:22:07 -04:00
Eric Anholt 9f0f00c319 egl: Drop _EGL_MAIN entrypoint obfuscation.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2012-02-29 11:52:40 -08:00
Matt Turner 027ce0c493 Revert "Always build shared glapi"
This reverts commit adefee50d9.

Shared glapi was never tested with --enable-xlib-glx and turns out
to cause a lot of problems.

Conflicts:

	configure.ac
2012-01-24 11:34:42 -05:00
Matt Turner adefee50d9 Always build shared glapi
libglapi.so, libGL.so, libGLESv2.so, libGLESv1_CM.so must all
come from the same version of Mesa or bad things may happen.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2012-01-20 14:56:42 -05:00
Kristian Høgsberg 58dc1b28d1 wayland-drm: Drop the non-premul formats, use format codes from drm_fourcc.h 2012-01-11 14:24:00 -05:00
Kristian Høgsberg 513d1feee4 egl_dri2: Put the _eglError call in the case switch case
Log an error in case we get an unknown format, not in case for XRGB32.
I botched the edit of Roberts patch.
2012-01-11 12:44:58 -05:00
Robert Bragg 670f182a1f egl_dri2/wayland: handle creating xrgb8888 images
When creating an EGLImage from a struct wl_buffer * this ensures
that we create an XRGB8888 image if the wayland buffer doesn't have an
alpha channel. To determine if a wl_buffer has a valid alpha channel
this patch adds an internal wayland_drm_buffer_has_alpha() function.

It's important to get the internal format for an EGLImage right so that
if a GL texture is later created from the image then the GL driver will
know if it should sample the alpha from the texture or flatten it to
a constant of 1.0.

This avoids needing fragment program workarounds in wayland compositors
to manually ignore the alpha component of textures created from wayland
buffers.

krh: Edited to use wl_buffer_get_format() instead of wl_buffer_has_alpha().

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2012-01-11 12:16:47 -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
Kristian Høgsberg 7b1d94e5d1 wayland: Track changes to drop wl_visual 2011-08-31 18:33:47 -04:00
Kristian Høgsberg 447bb454d8 egl_dri2: Only clear EGL_PIXMAP_BIT if DRI config is double buffered
We don't want to set the pixmap bit in the EGL config if the DRI
config we're adding is a double buffered config.  However, don't clear
any other bits the platform might pass in in the surface_type
argument.
2011-08-31 18:33:36 -04:00
Chia-I Wu 357d3f30f3 egl_dri2: set ctx->WindowRenderBuffer
Set ctx->WindowRenderBuffer to EGL_BACK_BUFFER.  As EGL_WINDOW_BIT of a
config is set only when there is dri_double_buffer, that makes sure
window surfaces are always double-buffered and contexts will render to
the back buffer.

Reviewed-by: Chad Versace <chad@chad-versace.us>
2011-08-31 11:51:42 +08: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
Cooper Yuan f5e757ea60 Destroy context in dri2/glx driver when apps call eglDestroyContext 2011-08-14 15:14:17 +08:00
Benjamin Franzke 32f4cf3808 egl/gbm: Fix EGL_DEFAULT_DISPLAY 2011-08-04 14:09:34 +02:00