Commit Graph

833 Commits

Author SHA1 Message Date
Tapani Pälli b65a91e582 egl/dri2: refactor dri2_query_surface, swrastGetDrawableInfo
Currently swrastGetDrawableInfo always initializes w and h, patch
refactors function as x11_get_drawable_info that returns success and
sets the values only if no error happened. Add swrastGetDrawableInfo
wrapper function as expected by DRI extension.

v2: init w,y,w,h in swrastGetDrawableInfo (Eric)

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reported-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-08-09 08:42:11 +03:00
Gurchetan Singh 12181b5017 egl/dri2: add image extension such it's usable by swrast driver
Otherwise, this extension is not visible to the EGL users who
use the swrast driver.

This will allow the swrast driver to use eglCreateImageKHR,
provided the target is EGL_GL_TEXTURE_2D_KHR or
EGL_GL_RENDERBUFFER_KHR.  Note we still have to implement the
create from render buffer path.

v2: add it to optional_core_extensions instead of swrast_core_extensions,
    so it's not a requirement (Emil)
v3: Merge egl/dri2 changes together, also add support for
    platform_wayland (Emil)

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v2)
2017-08-07 18:17:17 +01:00
Emil Velikov 9777c4234b loader: drop the [gs]et_swap_interval callbacks
Having two callbacks to manage a single int seems like an overkill.
Use a cached copy and update that when needed.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
Might want to look if the dimensions dance in .query_surface ...
speaking of which close to nobody implements that ...
2017-08-04 23:57:22 +01:00
Emil Velikov c961b679fe egl/x11: don't leak xfixes_query in the error path
If we get a xfixes v1.x we'll error out, without freeing the
xfixes_query reply.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-08-04 23:56:33 +01:00
Eric Engestrom dd9eb8db13 egl: check the correct function pointer
`.swap_interval` != `.SwapInterval`...

Fixes: 991ec1b81a "egl: make platform's SwapInterval() optional"
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102015
Cc: Cedric Sodhi <manday@openmail.cc>
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Tested-by: Cedric Sodhi <manday@openmail.cc>
2017-08-02 18:03:47 +01:00
Gwan-gyeong Mun fe2a6281b3 egl/drm: Fix misused x and y offsets in swrast_get_image()
It fixes misused x and y variables on the calculation of the memory copy regions.

Cc: Giovanni Campagna <gcampagna@src.gnome.org>
Fixes: 8430af5ebe "Add support for swrast to the DRM EGL platform"
Signed-off-by: Mun Gwan-gyeong <elongbug@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

[Eric: use gbm_bo_get_bpp() instead of local function, split clamp patch]
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-08-01 18:37:58 +01:00
Gwan-gyeong Mun 3a5e3aa5a5 egl/drm: Fix misused x and y offsets in swrast_put_image2()
It fixes misused x and y variables on the calculation of the memory copy regions.

Cc: Giovanni Campagna <gcampagna@src.gnome.org>
Fixes: 8430af5ebe "Add support for swrast to the DRM EGL platform"
Signed-off-by: Mun Gwan-gyeong <elongbug@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

[Eric: use gbm_bo_get_bpp() instead of local function, split clamp patch]
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-08-01 18:37:58 +01:00
Eric Engestrom 991ec1b81a egl: make platform's SwapInterval() optional
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2017-08-01 17:36:57 +01:00
Eric Engestrom 97eadb07e7 loader: remove clamp_swap_interval()
As of last commit, no invalid swap interval can be stored, so there's
no need to sanitize the values when reading them anymore.

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2017-08-01 17:36:57 +01:00
Eric Engestrom 2714a8f3e9 egl: deduplicate swap interval clamping logic
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
2017-08-01 17:36:57 +01:00
Rob Herring be5773fa8d Android: fix compile error for DRI2 loader getCapability
Fix compile failure from commit 1bf703e4ea ("dri_interface,egl,gallium:
only expose RGBA visuals on Android").

Fixes: 1bf703e4ea ("dri_interface,egl,gallium: only expose RGBA visuals on Android")
Cc: 17.2 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Rob Herring <robh@kernel.org>
2017-07-31 10:33:15 -05:00
Marek Olšák 1bf703e4ea dri_interface,egl,gallium: only expose RGBA visuals on Android
X/GLX can't handle them. This removes almost 500 GLX visuals that were
incorrectly exposed.

Add an optional getCapability callback for querying what the loader can do.

I'm not splitting this patch, because it's already too small.

v2: also add the callback to __DRIimageLoaderExtension

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Cc: 17.2 <mesa-stable@lists.freedesktop.org>
2017-07-31 12:49:30 +02:00
Daniel Stone dd072cf4b1 egl/wayland: Ignore invalid modifiers
If the underlying driver does not support modifiers, dmabuf will still
advertise formats through the 'modifier' event, but send them with an
invalid modifier. Ignore them if this is the case, rather than passing
them through to the driver.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Fixes: 02cc359372 ("egl/wayland: Use linux-dmabuf interface for buffers")
2017-07-24 16:42:28 +01:00
Miguel A. Vico 2d5d61bc49 wayland-egl: Make wl_egl_window a versioned struct
We need wl_egl_window to be a versioned struct in order to keep track of
ABI changes.

This change makes the first member of wl_egl_window the version number.

An heuristic in the wayland driver is added so that we don't break
backwards compatibility:

 - If the first field (version) is an actual pointer, it is an old
   implementation of wl_egl_window, and version points to the wl_surface
   proxy.

 - Else, the first field is the version number, and we have
   wl_egl_window::surface pointing to the wl_surface proxy.

Signed-off-by: Miguel A. Vico <mvicomoya@nvidia.com>
Reviewed-by: James Jones <jajones@nvidia.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-24 10:27:52 +01:00
Gwan-gyeong Mun 3f6cc931eb egl/dri2: remove unused buffer_count variable
It removes unused buffer_count variable from dri2_egl_surface.
And it polishes the assert of dri2_drm_get_buffers_with_format().

Signed-off-by: Mun Gwan-gyeong <elongbug@gmail.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-19 13:06:50 +01:00
Gwan-gyeong Mun faada25f47 egl/drm: Format code in platform_drm.c according to style guide.
This is a tiny housekeeping patch which does the following:
  * Limit lines to 78 or fewer characters.
According to the mesa coding style guidelines.

Signed-off-by: Mun Gwan-gyeong <elongbug@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-19 13:06:50 +01:00
Gwan-gyeong Mun 7c89585551 egl/drm: add going out of the loop when the designated buffer is found
Because the color_buffers have a each unique bo, if the designated buffer is
found, release_buffer() can go out the loop which seaches the buffer.

Signed-off-by: Mun Gwan-gyeong <elongbug@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-19 13:06:50 +01:00
Daniel Stone 02cc359372 egl/wayland: Use linux-dmabuf interface for buffers
When available, use the zwp_linux_dambuf_v1 interface to create buffers,
which allows multiple planes and buffer modifiers to be used.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-18 22:16:21 +01:00
Daniel Stone cfaca5742e egl/wayland: Remove duplicate wl_buffer creation code
Now create_wl_buffer is generic enough, we can use it for the
EGL_WL_create_wayland_buffer_from_image extension.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-18 22:16:21 +01:00
Daniel Stone 6595c69951 egl/wayland: Remove more surface specifics from create_wl_buffer
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-18 22:16:21 +01:00
Daniel Stone c4a1c7a2eb egl/wayland: Make create_wl_buffer more generic
Remove surface-specific code from create_wl_buffer, so it's now just a
generic translation from DRIimage to wl_buffer.

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-18 22:16:20 +01:00
Kenneth Graunke c7af6d2690 egl: Fix predecence problem when setting __DRI_CTX_FLAG_NO_ERROR
This accidentally set __DRI_CTX_FLAG_NO_ERROR whenever any flags were
present.  Just needs extra parenthesis.

Fixes: 4909519a66 (egl: Add EGL_KHR_create_context_no_error support)

Reviewed-by: Grigori Goronzy <greg@chown.ath.cx>
Tested-by: Mark Janes <mark.a.janes@intel.com>
2017-07-14 15:25:44 -07:00
Grigori Goronzy 4909519a66 egl: Add EGL_KHR_create_context_no_error support
This only adds the EGL side, needs to be plumbed into Mesa frontend.

v2: Add check for extension availability.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-07-14 21:23:44 +02:00
Daniel Stone 5295df63ad egl/wayland: Use MIN2 for wl_drm version
Use a slightly more explicit version cap for binding wl_drm, so we can
add other interfaces with different versioning schemes later.

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-14 14:14:05 +01:00
Daniel Stone 4b8ef27e84 egl/wayland: Fix whitespace damage
Convert tabs to spaces, fix misalignments.

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-14 14:14:05 +01:00
Alejandro Piñeiro 57671025b0 egl: remove unused err variable
Fixes: 81e95924ea ("egl: call _eglError within _eglParseImageAttribList")

Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-07-13 13:36:37 +02:00
Emil Velikov 4506a74cc6 egl: set KHR_gl_texture_3D_image only when the requirements are met.
DRI_IMAGE's createImageFromTexture is used to implement the extension,
so we should check for it prior to advertising.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-07-12 15:45:27 +01:00
Emil Velikov 962110fa57 egl: enhance KHR_gl_image extensions checks
Drop the (duplicate) top-level check in dri2_create_image_khr() and add
the respective checks in dri2_create_image_khr_{texture,renderbuffer}

v2: use unreachable instead of assert in dri2_create_image_khr_texture

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-07-12 15:44:26 +01:00
Emil Velikov a2ae8e6076 egl: don't set modifier if no modifiers are available
If no modifiers are available, the variable will never be used. Thus
there's no point in initialising it.

Cc: Varad Gautam <varad.gautam@collabora.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-07-12 15:43:15 +01:00
Emil Velikov 81e95924ea egl: call _eglError within _eglParseImageAttribList
As per EGL_KHR_image_base:

   If an attribute specified in <attrib_list> is not one of the
   attributes listed in Table bbb, the error EGL_BAD_PARAMETER is
   generated.

We should set the error as opposed to simply log it.

Currently we have a partial solution, whereby only some of the callers
call _eglError().

Since that has proven to be less robust, simply set the error by the
function itself and change the return type to EGLBoolean, updating the
callers.

So now the code is slightly simpler. Plus the follow-up fixes will be
easier to manage.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-07-12 15:42:51 +01:00
Emil Velikov 9365ff4b88 egl: move eglCreateDRMImageMESA's malloc later
Don't bother allocating any memory until we're finished parsing and
sanitising all the attributes.

As a nice side effect we now consistently set eglError when any of
the attrib/values are not correct.

Strangely enough the spec does not mention _anything_ about what error
should be set where, even if the implementation already sets the odd
one.

Cc: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-07-12 15:42:03 +01:00
Tomasz Figa 0ede0f9dff egl: android: Fix potential use of unitialized variable
If dri2_setup_extensions() fails, the "err" variable would not be assigned
causing the error path to access an unitialized variable. Fix it by
assigning an error message.

Fixes: 2c341f2bda ("egl: refactor dri2_create_screen() into three separate functions")
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-07-05 18:49:22 +01:00
Rob Herring a3d98ca62f Android: use symlinks for driver loading
Instead of having special driver loading logic for Android, create
symlinks to gallium_dri.so so we can use the standard loading logic.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Rob Herring <robh@kernel.org>
2017-06-29 09:09:49 -05:00
Ben Crocker 162c42f8ed egl_dri2: swrastGetDrawableInfo: set *x, *y [v2]
In swrastGetDrawableInfo, set *x and *y, not just *w and *h;
this fixes a crash later in drisw_update_tex_buffer when the
(formerly) uninitialized x and y values are used to construct
an address in a call to llvmpipe_transfer_map.

Fixes crash in Piglit test
"spec@egl 1.4@eglcreatepbuffersurface and then glclear"
(<piglit dir>/bin/egl-create-pbuffer-surface -auto)
that occurred intermittently, e.g. when the uninitialized x and y in
drisw_update_tex_buffer just happened to contain absurd non-zero values.

v2: Initialize in case if function succeeds or fails, just like *w/*h.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Ben Crocker <bcrocker@redhat.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-26 12:48:19 +01:00
Emil Velikov c58af5cbb2 egl: fold _eglError() + return EGL_FALSE
The function _eglError() already explicitly returns EGL_FALSE,
explicitly to simplify the callers. Make use of it.

While EGL_FALSE is numerically identical to false, NULL, EGL_NO_FOO,
storage is not the same so we cannot use it for "everything".

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-06-26 12:41:00 +01:00
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 ffbf50b1c6 egl: Rename 'count' in ${platform}_add_configs_for_visuals (v2)
Rename 'count' to 'config_count'. I didn't understand what the variable
did until I untangled the for-loops. Now the next person won't have that
problem.

v2: Rebase. Fix typo. Apply to all platforms (for emil).

Reviewed-by: Eric Engestrom <eric@engestrom.ch>  (v1)
2017-06-22 12:35:49 -07:00
Chad Versace a6fad55961 egl/x11: Declare EGLConfig attrib array inside loop
No behavioral change. Just a readability cleanup.

Instead of modifying this small array on each loop iteration, we now
initialize it in-place with the values it needs.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-06-22 12:35:49 -07:00
Chad Versace f8ad7f4054 egl/drm: Declare EGLConfig attrib array inside loop
No behavioral change. Just a readability cleanup.

Instead of modifying this small array on each loop iteration, we now
initialize it in-place with the values it needs.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-06-22 12:35:49 -07:00
Chad Versace bd789098a5 egl/android: Declare EGLConfig attrib array inside loop (v2)
No behavioral change. Just a readability cleanup.

Instead of modifying this small array on each loop iteration, we now
initialize it in-place with the values it needs.

v2: Rebase.

Reviewed-by: Eric Engestrom <eric@engestrom.ch> (v1)
2017-06-22 12:35:49 -07: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
Chad Versace 98497dfd6a egl/wayland: Declare loop vars inside the loop
That is, consistently do this:

    for (int i = 0; ...)

No behavioral change.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-06-22 12:35:49 -07:00
Chad Versace 927625ca60 egl/surfaceless: Move loop vars inside the loop
That is, consistently do this:

    for (int i = 0; ...)

No behavioral change.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-06-22 12:35:49 -07:00
Chad Versace 263d4b8b1c egl/x11: Declare loop vars inside the loop
That is, consistently do this:

    for (int i = 0; ...)

No behavioral change.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-06-22 12:35:49 -07:00
Chad Versace c31146f080 egl/drm: Move loop vars inside the loop
That is, consistently do this:

    for (int i = 0; ...)

No behavioral change.

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
2017-06-22 12:35:49 -07:00
Chad Versace 09455123f3 egl/android: Declare loop vars inside their loops (v2)
That is, consistently do this:

    for (int i = 0; ...)

No behavioral change.

v2: Rebase.

Reviewed-by: Eric Engestrom <eric@engestrom.ch> (v1)
2017-06-22 12:35:49 -07:00
Eric Engestrom c87f73724e egl: properly count configs
dri2_conf represents another config (which shouldn't be counted)
if it doesn't have the requested ID.

Reported-by: Liu Zhiquan <zhiquan.liu@intel.com>
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-22 17:32:31 +01:00
Chad Versace 5e884353e6 egl/android: Change order of EGLConfig generation (v2)
Many Android apps (such as Google's official NDK GLES2 example app), and
even portions the core framework code (such as SystemServiceManager in
Nougat), incorrectly choose their EGLConfig.  They neglect to match the
EGLConfig's EGL_NATIVE_VISUAL_ID against the window's native format, and
instead choose the first EGLConfig whose channel sizes match those of
the native window format while ignoring the channel *ordering*.

We can detect such buggy clients in logcat when they call
eglCreateSurface, by detecting the mismatch between the EGLConfig's
format and the window's format.

As a workaround, this patch changes the order of EGLConfig generation
such that all EGLConfigs for HAL pixel format i precede those for HAL
pixel format i+1. In my (chadversary) testing on Android Nougat, this
was good enough to pacify the buggy clients.

v2: Rebase to make patch cherry-pickable to stable.

Cc: mesa-stable@lists.freedesktop.org
Cc: Tomasz Figa <tfiga@chromium.org>
Cc: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-22 08:58:45 -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 4a1238a452 egl: turn one more boolean `int` into a `bool`
Same as the previous commit, but this one was split out because it's
a bit more complicated: this field is given as a pointer to a function,
so the function had to be changed as well, and the function was use in
a bunch of places, which needed updating as well.

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-21 21:42:14 +01:00