summaryrefslogtreecommitdiffstats
path: root/src/egl
Commit message (Collapse)AuthorAgeFilesLines
* egl_dri2: swrastGetDrawableInfo: set *x, *y [v2]Ben Crocker2017-06-261-1/+3
| | | | | | | | | | | | | | | | | | | 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: [email protected] Signed-off-by: Ben Crocker <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl: fold _eglError() + return EGL_FALSEEmil Velikov2017-06-269-130/+65
| | | | | | | | | | | 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 <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl: drop _eglInitImage() return typeEmil Velikov2017-06-267-42/+12
| | | | | | | | | Function cannot fail and always returns true. v2: Inline the one line function in the header Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl: Rename 'count' in ${platform}_add_configs_for_visuals (v2)Chad Versace2017-06-224-25/+28
| | | | | | | | | | 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 <[email protected]> (v1)
* egl/x11: Declare EGLConfig attrib array inside loopChad Versace2017-06-221-12/+12
| | | | | | | | | 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 <[email protected]>
* egl/drm: Declare EGLConfig attrib array inside loopChad Versace2017-06-221-5/+5
| | | | | | | | | 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 <[email protected]>
* egl/android: Declare EGLConfig attrib array inside loop (v2)Chad Versace2017-06-221-9/+7
| | | | | | | | | | | 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 <[email protected]> (v1)
* egl/dri2: Declare loop vars inside the loopChad Versace2017-06-221-24/+19
| | | | | | | | | | | That is, consistently do this: for (int i = 0; ...) No behavioral change. This patch touches only egl_dri2.c. Reviewed-by: Eric Engestrom <[email protected]>
* egl/wayland: Declare loop vars inside the loopChad Versace2017-06-221-27/+17
| | | | | | | | | | That is, consistently do this: for (int i = 0; ...) No behavioral change. Reviewed-by: Eric Engestrom <[email protected]>
* egl/surfaceless: Move loop vars inside the loopChad Versace2017-06-221-7/+5
| | | | | | | | | | That is, consistently do this: for (int i = 0; ...) No behavioral change. Reviewed-by: Eric Engestrom <[email protected]>
* egl/x11: Declare loop vars inside the loopChad Versace2017-06-221-8/+7
| | | | | | | | | | That is, consistently do this: for (int i = 0; ...) No behavioral change. Reviewed-by: Eric Engestrom <[email protected]>
* egl/drm: Move loop vars inside the loopChad Versace2017-06-221-22/+15
| | | | | | | | | | That is, consistently do this: for (int i = 0; ...) No behavioral change. Reviewed-by: Eric Engestrom <[email protected]>
* egl/android: Declare loop vars inside their loops (v2)Chad Versace2017-06-221-19/+15
| | | | | | | | | | | | That is, consistently do this: for (int i = 0; ...) No behavioral change. v2: Rebase. Reviewed-by: Eric Engestrom <[email protected]> (v1)
* egl: properly count configsEric Engestrom2017-06-225-6/+12
| | | | | | | | | | dri2_conf represents another config (which shouldn't be counted) if it doesn't have the requested ID. Reported-by: Liu Zhiquan <[email protected]> Signed-off-by: Eric Engestrom <[email protected]> Cc: <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl/android: Change order of EGLConfig generation (v2)Chad Versace2017-06-221-7/+25
| | | | | | | | | | | | | | | | | | | | | | | | | 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: [email protected] Cc: Tomasz Figa <[email protected]> Cc: Rob Herring <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl: simplify dri_config conditionalsEric Engestrom2017-06-222-17/+11
| | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl: turn one more boolean `int` into a `bool`Eric Engestrom2017-06-211-1/+1
| | | | | | | | | | 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 <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl: turn boolean `int`s into `bool`sEric Engestrom2017-06-215-24/+25
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl/display: make platform detection thread-safeEric Engestrom2017-06-161-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Imagine there are 2 threads that both call _eglGetNativePlatform() simultaneously: - thread 1 completes the first "if (native_platform == _EGL_INVALID_PLATFORM)" check and is preempted to do something else - thread 2 executes the whole function, does "native_platform = _EGL_NATIVE_PLATFORM" and just before returning it's preempted - thread 1 wakes up and calls _eglGetNativePlatformFromEnv() which returns _EGL_INVALID_PLATFORM because no env vars are set, updates native_platform and then gets preempted again - thread 2 wakes up and returns wrong _EGL_INVALID_PLATFORM Solve this by doing the detection in a local var and only overwriting the global one at the end, if no other thread has updated it since. This means the platform detected in the thread might not be the platform returned by the function, but this is a different issue that will need to be discussed when this becomes possible. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101252 Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]> Acked-by: Emil Velikov <[email protected]>
* egl/display: only detect the platform onceEric Engestrom2017-06-161-14/+17
| | | | | | | | | | | | | | My refactor missed the fact that `native_platform` is static. Add the proper guard around the detection code, as it might not be necessary, and only print the debug message when a detection was actually performed. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101252 Fixes: 7adb9b094894a512c019 ("egl/display: remove unnecessary code and make it easier to read") Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Grazvydas Ignotas <[email protected]> Acked-by: Emil Velikov <[email protected]>
* egl/android: Fix typ-oRobert Foss2017-06-151-1/+1
| | | | | Signed-off-by: Robert Foss <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* Fix khrplatform.h not installed if EGL is disabled.Eric Le Bihan2017-06-141-3/+0
| | | | | | | | | | | KHR/khrplatform.h is required by the EGL, GLES and VG headers, but is only installed if Mesa3d is compiled with EGL support. This patch installs this header file unconditionally. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77240 Signed-off-by: Eric Le Bihan <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl: improve dri2_fallback_swap_buffers_with_damage()Eric Engestrom2017-06-131-0/+1
| | | | | | | Let's (try to) set damages before swapping buffers. Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* egl/android: support for EGL_KHR_partial_updateHarish Krupo2017-06-1116-0/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* egl: fix _eglQuerySurface in EGL_BUFFER_AGE_EXT caseTapani Pälli2017-06-094-5/+9
| | | | | | | | | | | | | | | | | | Specification states that in case of error, value should not be written, patch changes buffer age queries to return -1 in case of error so that we can skip changing the value. In addition, small change to droid_query_buffer_age to return 0 in case buffer does not have a back buffer available. Fixes: dEQP-EGL.functional.negative_partial_update.not_postable_surface Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Chad Versace <[email protected]> Cc: [email protected]
* egl/dri2: Avoid sign extension when building modifierDaniel Stone2017-06-081-3/+2
| | | | | | | | | 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 <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* egl/android: Drop unused 'format' param in get_back_bo()Chad Versace2017-05-311-2/+2
| | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl/android: Align channel masks in HAL_PIXEL_FORMAT tableChad Versace2017-05-311-4/+4
| | | | | | | Improves readability. No change in behavior. Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl/drm: remove temporary fd variableEric Engestrom2017-05-311-8/+6
| | | | | | | | | | | | In all codepaths, this var ends up assigned to the struct, except one: a cleanup codepath, where the `close()` was removed, leading to fd leaks. Remove the temp fd and assign to the struct field directly instead. CovID: 1213930 Fixes: 7ec07beedf486d8ab901 ("egl/drm: make use of the dri2_display_destroy() helper") Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Eric Engestrom <[email protected]>
* egl: advertise EGL_EXT_image_dma_buf_import_modifiersVarad Gautam2017-05-302-0/+7
| | | | | | | | | v2: check for DRIimageExtension version 15 (Jason Ekstrand) Signed-off-by: Varad Gautam <[email protected]> Reviewed-by: Daniel Stone <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl: implement eglQueryDmaBufModifiersEXTVarad Gautam2017-05-304-0/+59
| | | | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Daniel Stone <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl: implement eglQueryDmaBufFormatsEXTVarad Gautam2017-05-304-0/+45
| | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Varad Gautam <[email protected]> Reviewed-by: Daniel Stone <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl/dri2: Create EGLImages with dmabuf modifiersVarad Gautam2017-05-303-11/+147
| | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Varad Gautam <[email protected]> Signed-off-by: Louis-Francis Ratté-Boulianne <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Daniel Stone <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl/main: add support for fourth plane tokensPekka Paalanen2017-05-304-3/+23
| | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Varad Gautam <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
* egl: introduce DMA_BUF_MAX_PLANESPekka Paalanen2017-05-302-7/+9
| | | | | | | | | | Rather than hardcoding 3, use a #define. Makes it easier to bump this later to 4. Signed-off-by: Pekka Paalanen <[email protected]> Signed-off-by: Varad Gautam <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
* egl: implement __DRIbackgroundCallableExtension.isThreadSafeGregory Hainaut2017-05-291-1/+33
| | | | | | | | | | | | | | | | | 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 <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* egl/wayland: use the image_driver alongside the image_loaderEmil Velikov2017-05-291-6/+14
| | | | | | | | | | Analogous to earlier commits - image_driver and image_loader are meant to be used hand in hand. v2: Rebase Cc: Derek Foreman <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
* egl/wayland: set the resize_callback if the flush extension is availableEmil Velikov2017-05-291-3/+3
| | | | | | | Strictly speaking __DRI_DRI2 implies __DRI2_FLUSH. Although since we're using the latter in the callback, we want to use the correct guard. Signed-off-by: Emil Velikov <[email protected]>
* egl/wayland: select the format based on the interface usedEmil Velikov2017-05-291-1/+2
| | | | | | | | Rather than misleadingly depending on DRI2 for the WL_DRM vs WL_SHM formats, use the wl_drm and wl_shm interface respectively. Fixes: a1727aa75ed ("egl/wayland: Don't use DRM format codes for SHM") Signed-off-by: Emil Velikov <[email protected]>
* egl/surfaceless: use the image_driver for image_loaderEmil Velikov2017-05-291-4/+4
| | | | | | | | Analogous to previous commit. Cc: Chad Versace <[email protected]> Cc: Gurchetan Singh <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
* egl/android: use the image_driver alongside the image_loaderEmil Velikov2017-05-291-11/+20
| | | | | | | | | | | They are meant to be used together. Otherwise we'll need workarounds like egl/wayland. Namely register an image_loader_extension even thought we should be using only DRI2. v2: Add missing the bracket to fix the build (Tapani). Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* egl/x11: flatten codeflowEmil Velikov2017-05-291-9/+7
| | | | Signed-off-by: Emil Velikov <[email protected]>
* egl/x11: check for dri2_dpy->flush before using the flush extensionEmil Velikov2017-05-291-5/+3
| | | | | | | | | | | | | Analogous to earlier commit. Note that the dri2_x11_post_sub_buffer and dri2_x11_swap_buffers_region paths already implicitly require __DRI2_FLUSH. The corresponding extensions (NV_post_sub_buffer and NOK_swap_region) are enabled only with DRI2. v2: Split cosmetic changes into separate patch. Signed-off-by: Emil Velikov <[email protected]>
* egl/drm: flatten codeflowEmil Velikov2017-05-291-19/+20
| | | | | | | Rework the code to return early and drop an indentation level. It should be easier to read. Signed-off-by: Emil Velikov <[email protected]>
* egl/drm: check for dri2_dpy->flush before using the flush extensionEmil Velikov2017-05-291-1/+1
| | | | | | | | | | | | | The current __DRI_DRI2 imples __DRI2_FLUSH. At the same time, one can use __DRI_IMAGE_DRIVER alongside the latter, so the current check is confusing at best. Check for what we use. v2: Split out from whitespace changes Reviewed-by: Chad Versace <[email protected]> (v1) Signed-off-by: Emil Velikov <[email protected]>
* egl: annotate dri2_egl_display_vtbl as const dataEmil Velikov2017-05-295-7/+7
| | | | | | | | With the final place that modifies the vtbl removed as of last commit we can annotate the symbols accordingly. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl/wayland: don't modify the vtbl if an extension is not availableEmil Velikov2017-05-291-5/+2
| | | | | | | | With previous commit we'll error out should one be using the extension when it's not available. Thus we no longer need to modify the vtbl. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl: error out on eglCreateWaylandBufferFromImageWLEmil Velikov2017-05-291-1/+2
| | | | | | | | | | | | | Currently f one does the silly thing by probing the entry point w/o checking the extension they will attempt to use the extension even though it cannot work. That is due our of of an assert which gets removed in release builds. Simply error out if the extension is not enabled. Thus we can apply some cleanups with next commits. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* egl/drm: use dri2_setup_extensions() over the extensions provided by GBMEmil Velikov2017-05-291-4/+5
| | | | | | | | | | | Allows us to keep things in sync easier and lets us simplify the interface between the two even further. v2: Don't set GBM's extensions. Cc: Rob Herring <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Tested-by: Rob Herring <[email protected]>
* egl: refactor dri2_create_screen() into three separate functionsEmil Velikov2017-05-296-19/+58
| | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Tested-by: Rob Herring <[email protected]>