summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/dri2/platform_wayland.c
Commit message (Collapse)AuthorAgeFilesLines
...
* egl/dri2: Dispatch eglCreateWindowSurface by display, not driverChad Versace2014-03-171-1/+1
| | | | | | | | | | 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>
* egl/dri2: Dispatch eglSwapBuffersWithDamage by display, not driverChad Versace2014-03-171-1/+1
| | | | | | | | | | 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>
* egl/dri2: Dispatch eglSwapBuffers by display, not driverChad Versace2014-03-171-1/+1
| | | | | | | | | | 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>
* egl/dri2: Dispatch eglSwapInterval by display, not driverChad Versace2014-03-171-1/+2
| | | | | | | | | | 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>
* egl/wl,x11: Call dri2_swap_interval() staticallyChad Versace2014-03-171-1/+5
| | | | | | | | | | Don't call it through the driver dispatch table. Just call it statically. 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>
* egl/dri2: Put platform func names into proper namespacesChad Versace2014-03-171-54/+54
| | | | | | | | | | | | | | | | | | | | Each of the egl_dri2 platforms (except Android) prefix their function names with "dri2", not "dri2_${platform}". This means many function names have three separate definitions in the egl_dri2 directory: one in each of platform_drm.c, platform_wayland.c, and platform_x11.c. For example, each of the three files defines dri2_create_window_surface(). The name collisions make it difficult to review patches for correctness ("Is this patch hunk calling a platform_x11 function or a global egl_dri2 function?"), complicate debugging, and confuse code navigation tools. For each function in platform_x11.c prefixed with 'dri2', this patch changes its prefix to 'dri2_x11'. Likewise for platform_drm.c and 'dri2_drm'; and platform_wayland.c and 'dri2_wl'. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
* egl/dri2: Move dri2_egl_display virtual funcs to vtblChad Versace2014-03-171-1/+9
| | | | | | | | | | | 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>
* egl/wayland: explicitly set __DRIimageLoaderExtension membersEmil Velikov2014-02-231-3/+4
| | | | | Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>y
* egl_dri2: use loader util libEmil Velikov2014-01-181-1/+4
| | | | | | | Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* egl/wayland: Return -1 from get_back_bo to indicate errorKristian Høgsberg2013-12-091-1/+1
| | | | | A return value of -1 indicate failure to allocate the back buffer and means we don't segfault on the way out.
* wayland: Add support for eglSwapIntervalNeil Roberts2013-12-071-32/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Wayland EGL platform now respects the eglSwapInterval value. The value is clamped to either 0 or 1 because it is difficult (and probably not useful) to sync to more than 1 redraw. The main change is that if the swap interval is 0 then Mesa won't install a frame callback so that eglSwapBuffers can be executed as often as necessary. Instead it will do a sync request after the swap buffers. It will block for sync complete event in get_back_bo instead of the frame callback. The compositor is likely to send a release event while processing the new buffer attach and this makes sure we will receive that before deciding whether to allocate a new buffer. If there are no buffers available then instead of returning with an error, get_back_bo will now poll the compositor by repeatedly sending sync requests every 10ms. This is a last resort and in theory this shouldn't happen because there should be no reason for the compositor to hold on to more than three buffers. That means whenever we attach the fourth buffer we should always get an immediate release event which should come in with the notification for the first sync request that we are throttled to. When the compositor is directly scanning out from the application's buffer it may end up holding on to three buffers. These are the one that is is currently scanning out from, one that has been given to DRM as the next buffer to flip to, and one that has been attached and will be given to DRM as soon as the previous flip completes. When we attach a fourth buffer to the compositor it should replace that third buffer so we should get a release event immediately after that. This patch therefore also changes the number of buffer slots to 4 so that we can accomodate that situation. If DRM eventually gets a way to cancel a pending page flip then the compositors can be changed to only need to hold on to two buffers and this value can be put back to 3. This also moves the vblank configuration defines from platform_x11.c to the common egl_dri2.h header so they can be shared by both platforms.
* wayland: Block for the frame callback in get_back_bo not dri2_swap_buffersNeil Roberts2013-12-071-14/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider a typical game-style main loop which might be like this: while (1) { draw_something(); eglSwapBuffers(); } In this case the game is relying on eglSwapBuffers to throttle to a sensible frame rate. Previously this game would end up using three buffers even though it should only need two. This is because Mesa decides whether to allocate a new buffer in get_back_bo which would be before it has tried to read any events from the compositor so it wouldn't have seen any buffer release events yet. This patch just moves the block for the frame callback to get_back_bo. Typically the compositor will send a release event immediately after one of the attaches so if we block for the frame callback here then we can be sure to have completed at least one roundtrip and received that release event after attaching the previous buffer before deciding whether to allocate a new one. dri2_swap_buffers always calls get_back_bo so even if the client doesn't render anything we will still be sure to block to the frame callback. The code to create the new frame callback has been moved to after this call so that we can be sure to have cleared the previous frame callback before requesting a new one.
* wayland: Add an extension to create wl_buffers from EGLImagesNeil Roberts2013-12-041-0/+78
| | | | | | | | | | | | | | | | | | This adds an extension called EGL_WL_create_wayland_buffer_from_image which adds the following single function: struct wl_buffer * eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImageKHR image); The function creates a wl_buffer which shares its contents with the given EGLImage. The expected use case for this is in a nested Wayland compositor which is using subsurfaces to present buffers from its clients. Using this extension it can attach the client buffers directly to the subsurface without having to blit the contents into an intermediate buffer. The compositing can then be done in the parent compositor. The extension is only implemented in the Wayland EGL platform because of course it wouldn't make sense anywhere else.
* egl/wayland: Damage INT32_MAX x INT32_MAX region for eglSwapBuffersKristian Høgsberg2013-12-041-2/+2
| | | | | | | | | | | | | | | | If we're not using EGL_EXT_swap_buffers_with_damage, we have to damage the full extent. EGL operates on buffer coordinates, but wl_surface.damage takes surface coordinates. EGL doesn't know the buffer transformation (rotated or scaled) and can't post accurate damage in surface coordinates. The damage event however is clipped to the surface extents so we can just damage the maximum rectangle. In case of EGL_EXT_swap_buffers_with_damage, the application knows the buffer transform and is expected to pass in rectangles in surface space. https://bugs.freedesktop.org/show_bug.cgi?id=70250 Cc: "10.0" mesa-stable@lists.freedesktop.org
* Enable throttling in SwapBuffersAxel Davy2013-12-041-1/+13
| | | | | | | | | flush_with_flags, when available, allows the driver to throttle. Using this suppress input lag issues that can be observed in heavy rendering situations on non-intel cards. Signed-off-by: Axel Davy <axel.davy@ens.fr> Cc: "10.0" mesa-stable@lists.freedesktop.org
* egl/wayland: Send commit after flushing the driver contextKristian Høgsberg2013-12-041-2/+1
| | | | | | | | | | This typically won't make a difference, since we only send the requests at wl_display_flush() time. There might be a small race with another thread calling wl_display_flush() after our commit request, but before we flush the DRI driver. Moving the commit below the DRI driver flush call looks more natural and eliminates the small race. Cc: "10.0" mesa-stable@lists.freedesktop.org
* egl/wayland: Flush the wl_display at the end of SwapBuffersAxel Davy2013-12-041-0/+2
| | | | | | | | | | We would like the compositor to receive the commited buffer as soon as possible, so it has the time to treat it, and release old ones. We shouldn't rely on the client to flush the queue for us. Signed-off-by: Axel Davy <axel.davy@ens.fr> Cc: "10.0" mesa-stable@lists.freedesktop.org
* wayland: Use __DRIimage based getBuffers implementation when availableKristian Høgsberg2013-11-121-45/+95
| | | | | | | | | | | This lets us allocate color buffers as __DRIimages and pass them into the driver instead of having to create a __DRIbuffer with the flink that requires. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Chad Versace <chad.versace@linux.intel.com> Cc: "10.0" <mesa-stable@lists.freedesktop.org>
* egl_dri2: Remove depth argument from dri2_add_config()Kristian Høgsberg2013-10-151-3/+3
| | | | | | | | | | | | | | 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>
* egl-wayland: Add support for RGB565 pixel format for Wayland clientsSingh, Satyeshwar2013-10-151-2/+11
| | | | | | | With this patch Wayland clients can now ask EGL for RGB 565 format buffers and attach them to a Wayland compositor. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
* wayland: Handle global_remove event as wellKristian Høgsberg2013-06-181-1/+8
| | | | | | | | | | | | We need to set up a handler for the global_remove event that gets sent out when a global gets removed. Without the handler we end up calling a NULL pointer. https://bugs.freedesktop.org/show_bug.cgi?id=65910 NOTE: This is a candidate for the stable branches. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
* egl/wayland: Implement EGL_EXT_swap_buffers_with_damageRobert Bragg2013-05-071-3/+26
| | | | | Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
* egl_dri2: Lower __DRI_IMAGE version requirement back to 1Kristian Høgsberg2013-03-191-0/+9
| | | | | We check the extension version manually instead and verify that we have the createImageFromFds function before enabling prime fd passing.
* wayland: Add prime fd passing as a buffer sharing mechanismKristian Høgsberg2013-03-181-15/+54
| | | | Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
* wayland: allocate a __DRIimage for the color bufferKristian Høgsberg2013-03-181-22/+35
| | | | | | | No functional change here, but this will let us query the image for an fd handle later. Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
* egl/wayland: Don't block on EGL_DEFAULT_DISPAY under waylandKristian Høgsberg2013-02-261-0/+4
| | | | | | | Normally the application will own the main event queue and be responsible for moving events. In case of EGL_DEFAULT_DISPLAY, EGL opens the display and has to own the main queue so it can move the events itself. Call wl_display_dispatch_pending() to take ownership.
* egl-wayland: Make sure we allocate a back buffer even if nothing was renderedKristian Høgsberg2013-02-081-0/+8
| | | | | | | | | At eglSwapBuffer time, we blindly assume we have a back buffer, but the back buffer only gets allocated when somebody tries to render something. NOTE: This is a candidate for the 9.0 and 9.1 branches. https://bugs.freedesktop.org/show_bug.cgi?id=60086
* egl/wayland: Implement EGL_EXT_buffer_ageKristian Høgsberg2013-01-141-1/+24
| | | | Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
* egl/wayland: Pull color buffers from dri2_surf->color_buffers poolKristian Høgsberg2013-01-141-241/+138
| | | | | | | | | | | | | | | We used to keep the color buffers in the dri_buffers array and swap __DRI_BUFFER_BACK_LEFT and __DRI_BUFFER_FRONT_LEFT around there and swap third_buffer in in case we needed to triple buffer. That gets a little fidgety with all the swaps, so lets use the color_buffers pool like the gbm platform does. We track the color buffers, their corresponding wl_buffer and locked status here and just plug a free one into dri2_surf->buffers when we need to. This is a nice clean-up in itself, but it also sets us up to track buffer age in the color_buffers structs. Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
* egl/wayland: Remove kooky flush codeKristian Høgsberg2013-01-041-8/+0
| | | | | We used to have to jump through hoops to call glFlush at swap buffer time, but the flush extension made that unnecessary a long time ago.
* egl/wayland: Remove confusing comment about front buffer renderingKristian Høgsberg2013-01-041-10/+0
|
* wayland: Don't cancel a roundtrip when any event is receivedJonas Ådahl2013-01-031-0/+3
| | | | | | | | | | | Since wl_display_dispatch_queue() returns the number of processed events or -1 on error, only cancel the roundtrip if an -1 is returned. This also fixes a potential memory corruption bug happening when the roundtrip does an early return and the callback later writes to the then out of scope stack allocated `done' parameter. Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
* egl/wayland: Dispatch the event queue before get_buffersAnder Conselvan de Oliveira2012-11-301-0/+3
| | | | | | | | | | | | | | | | | When a client frame callback is executed and the client starts rendering again, the egl event queue might not have been dispatched so that the buffer release event for the previous frame hasn't been processed. In that case a third buffer is allocated, even though it would be possible to reuse the buffer that was just released. The wl_display_dispatch_queue_pending() entry point is available from wayland-client 1.0.2, so require that in configure.ac. Also, just let the pkg-config macro throw its own error, which will show what version we were looking for and failed to find. Note: This is a candidate for stable branches. Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
* egl/wayland: Add invalidate back in eglSwapBuffers()Kristian Høgsberg2012-11-301-0/+1
| | | | | | | | | | | | | Commit ca3ed3e024864e91ca3cccc59fb96950e1d079b5 fixed the problem where eglMakeCurrent would trigger a getbuffer callback that then breaks the following wl_egl_window_resize() call. However, we still need to invalidate buffers in eglSwapBuffers, since in wayland we always swap buffers, so the dri driver needs to come out and ask us for the next buffer after each swapbuffer. Note: this is a candidate for stable branches. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
* egl/wayland: Don't invalidate drawable on swap buffersAnder Conselvan de Oliveira2012-11-301-1/+19
| | | | | | | | | | | | | | | | | | | We used to invalidate the drawable after a call to eglSwapBuffers(), so that a wl_egl_window_resize() would take effect for the next frame. However, that leads to calling dri2_get_buffers() when eglMakeCurrent() is called with the current context and surface, and a later call to wl_egl_window_resize() would not take effect until the next buffer swap. Instead, add a callback from wl_egl_window_resize() back to the wayland egl platform, and invalidate the drawable only when it is resized. This solves a bug on wayland clients when going back to windowed mode from fullscreen when clicking a pop up menu, where the window size after this would be the fullscreen size. Note: this is a candidate for stable branches. CC: wayland-devel@lists.freedesktop.org
* wayland: Destroy frame callback when destroying surfaceJonas Ådahl2012-11-071-0/+3
| | | | | | | | | | | | | | If a frame callback is not destroyed when destroying a surface, its handler function will be invoked if the surface was destroyed after the callback was requested but before it was invoked, causing a write on free:ed memory. This can happen if eglDestroySurface() is called shortly after eglSwapBuffers(). Note: This is a candidate for stable branches. Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
* wayland: Drop support for ill-defined, unused wl_egl_pixmapKristian Høgsberg2012-10-171-143/+4
| | | | | | It doesn't provide the cross-process buffer sharing that a window system pixmap could otherwise support and we don't have anything left that uses this type of surface.
* egl/wayland: Update to Wayland 0.99 APIKristian Høgsberg2012-10-171-27/+75
| | | | | | | | | The 0.99.0 Wayland release changes the event API to provide a thread-safe mechanism for receiving events specific to a subsystem (such as EGL) and we need to use it in the EGL platform. The Wayland protocol now also requires a commit request to make changes take effect, issue that from eglSwapBuffers.
* Use calloc instead of malloc/memset-0Matt Turner2012-09-051-3/+1
| | | | | | | | | | | | | | | | 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>
* wayland: Stop using wl_buffer.damageKristian Høgsberg2012-03-271-2/+0
|
* Set close on exec flag FD_CLOEXECDavid Fries2012-03-111-1/+10
| | | | | | | | | Set the close on exec flag when opening dri character devices, so they will be closed and free any resouces allocated in exec. Signed-off-by: David Fries <David@Fries.net> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
* wayland: Use new wl_display_disconnectBenjamin Franzke2012-03-051-1/+1
| | | | | | This replaces the previously used wl_display_destroy. wl_display_destroy was povided by wayland-client.so and wayland-server.so, to resolve that conflict its renamed client-side.
* wayland-drm: Drop the non-premul formats, use format codes from drm_fourcc.hKristian Høgsberg2012-01-111-20/+11
|
* egl_dri2: Fix some valgrind reported leaksBenjamin Franzke2011-12-131-0/+5
| | | | | | | Free the device_name, reported by Pekka Paalanen. Destroy wayland display and drm resources, if created by dri2_initialize_wayland.
* wayland: Flush before blocking in swapbuffers.Jørgen Lind2011-09-151-2/+5
| | | | Make sure that we've sent the frame request that we're going to block on.
* egl_dri2: Destroy callback in release_pending_bufferBenjamin Franzke2011-09-011-0/+2
|
* wayland: Track changes to drop wl_visualKristian Høgsberg2011-08-311-12/+54
|
* wayland: Track server side wayland changesKristian Høgsberg2011-08-311-1/+1
|
* wayland: Use new wl_callback mechanismKristian Høgsberg2011-08-311-31/+24
|
* egl_dri2: Drop dri2_surface_type enumBenjamin Franzke2011-08-311-11/+9
| | | | | Was only used in platform_wayland, and the remaining egl stack uses _EGLSurface::Type with one of EGL_{WINDOW,PIXMAP,PBUFFER}_BIT.