Commit fb53f193 authored by Eric Engestrom's avatar Eric Engestrom Committed by Dylan Baker

egl/x11_dri3: implement EGL_KHR_swap_buffers_with_damage

Passes all of `dEQP-EGL.functional.swap_buffers_with_damage.*`:

    Passed:        36/54 (66.7%)
    Failed:        0/54 (0.0%)
    Not supported: 18/54 (33.3%)
    Warnings:      0/54 (0.0%)
    Waived:        0/54 (0.0%)

The "not supported" ones are the `preserve_buffer_*` tests, which is not
supported on X11/DRI3.

Cc: 20.2 <mesa-stable>
Closes: #3030Signed-off-by: Eric Engestrom's avatarEric Engestrom <eric@engestrom.ch>
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <mdaenzer@redhat.com>
Part-of: <!6132>
(cherry picked from commit 326eb567)
parent 93659e4e
......@@ -3316,7 +3316,7 @@
"description": "egl/x11_dri3: implement EGL_KHR_swap_buffers_with_damage",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": null
},
......
<<<<<<< HEAD
GL_ARB_compute_variable_group_size on Iris.
GL_ARB_gpu_shader5 on llvmpipe
GL_ARB_post_depth_coverage on llvmpipe
......@@ -27,3 +26,4 @@ VK_EXT_shader_atomic_float on ANV
VK_EXT_4444_formats on ANV and RADV.
VK_KHR_memory_model on RADV.
GL 4.5 on llvmpipe
EGL_KHR_swap_buffers_with_damage on X11 (DRI3)
......@@ -1403,6 +1403,7 @@ dri2_initialize_x11_dri3(const _EGLDriver *drv, _EGLDisplay *disp)
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
disp->Extensions.EXT_buffer_age = EGL_TRUE;
disp->Extensions.EXT_swap_buffers_with_damage = EGL_TRUE;
dri2_set_WL_bind_wayland_display(drv, disp);
......
......@@ -422,15 +422,23 @@ const __DRIimageLoaderExtension dri3_image_loader_extension = {
};
static EGLBoolean
dri3_swap_buffers(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
dri3_swap_buffers_with_damage(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw,
const EGLint *rects, EGLint n_rects)
{
struct dri3_egl_surface *dri3_surf = dri3_egl_surface(draw);
return loader_dri3_swap_buffers_msc(&dri3_surf->loader_drawable,
0, 0, 0, 0,
rects, n_rects,
draw->SwapBehavior == EGL_BUFFER_PRESERVED) != -1;
}
static EGLBoolean
dri3_swap_buffers(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
return dri3_swap_buffers_with_damage(drv, disp, draw, NULL, 0);
}
static EGLBoolean
dri3_copy_buffers(const _EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
void *native_pixmap_target)
......@@ -499,6 +507,7 @@ struct dri2_egl_display_vtbl dri3_x11_display_vtbl = {
.create_image = dri3_create_image_khr,
.swap_interval = dri3_set_swap_interval,
.swap_buffers = dri3_swap_buffers,
.swap_buffers_with_damage = dri3_swap_buffers_with_damage,
.copy_buffers = dri3_copy_buffers,
.query_buffer_age = dri3_query_buffer_age,
.query_surface = dri3_query_surface,
......
......@@ -593,7 +593,7 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
return loader_dri3_swap_buffers_msc(&priv->loader_drawable,
target_msc, divisor, remainder,
flags, false);
flags, NULL, 0, false);
}
static int
......
......@@ -30,6 +30,7 @@
#include <xcb/xcb.h>
#include <xcb/dri3.h>
#include <xcb/present.h>
#include <xcb/xfixes.h>
#include <X11/Xlib-xcb.h>
......@@ -908,6 +909,7 @@ int64_t
loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
int64_t target_msc, int64_t divisor,
int64_t remainder, unsigned flush_flags,
const int *rects, int n_rects,
bool force_copy)
{
struct loader_dri3_buffer *back;
......@@ -1006,12 +1008,29 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
#endif
back->busy = 1;
back->last_swap = draw->send_sbc;
xcb_xfixes_region_t region = 0;
xcb_rectangle_t xcb_rects[64];
if (n_rects > 0 && n_rects <= ARRAY_SIZE(xcb_rects)) {
for (int i = 0; i < n_rects; i++) {
const int *rect = &rects[i * 4];
xcb_rects[i].x = rect[0];
xcb_rects[i].y = draw->height - rect[1] - rect[3];
xcb_rects[i].width = rect[2];
xcb_rects[i].height = rect[3];
}
region = xcb_generate_id(draw->conn);
xcb_xfixes_create_region(draw->conn, region, n_rects, xcb_rects);
}
xcb_present_pixmap(draw->conn,
draw->drawable,
back->pixmap,
(uint32_t) draw->send_sbc,
0, /* valid */
0, /* update */
region, /* update */
0, /* x_off */
0, /* y_off */
None, /* target_crtc */
......@@ -1023,6 +1042,9 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
remainder, 0, NULL);
ret = (int64_t) draw->send_sbc;
if (region)
xcb_xfixes_destroy_region(draw->conn, region);
/* Schedule a server-side back-preserving blit if necessary.
* This happens iff all conditions below are satisfied:
* a) We have a fake front,
......
......@@ -205,6 +205,7 @@ int64_t
loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
int64_t target_msc, int64_t divisor,
int64_t remainder, unsigned flush_flags,
const int *rects, int n_rects,
bool force_copy);
int
......
......@@ -28,6 +28,7 @@ if with_platform_x11 and with_dri3
include_directories : [inc_include, inc_src],
dependencies : [
dep_libdrm, dep_xcb_dri3, dep_xcb_present, dep_xcb_sync, dep_xshmfence,
dep_xcb_xfixes,
],
build_by_default : false,
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment