From b6f201b1734bffd7023de3fb4caf26fe27b752fe Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 5 Sep 2024 10:41:07 -0400 Subject: [PATCH] meson: require dri3 modifiers the year is 2024 and we have the technology Reviewed-by: Faith Ekstrand Reviewed-by: Daniel Stone Part-of: --- meson.build | 13 ++----------- src/egl/drivers/dri2/platform_x11.c | 2 +- src/egl/drivers/dri2/platform_x11_dri3.c | 6 +++--- .../frontends/dri/loader_dri3_helper.c | 14 +++++++------- .../frontends/dri/loader_dri3_helper.h | 2 +- src/glx/dri3_glx.c | 2 +- src/vulkan/wsi/wsi_common_display.c | 2 +- src/vulkan/wsi/wsi_common_x11.c | 19 +++++++------------ src/x11/loader_x11.c | 4 ++-- 9 files changed, 25 insertions(+), 39 deletions(-) diff --git a/meson.build b/meson.build index b55a4a91227..1f6edd153d6 100644 --- a/meson.build +++ b/meson.build @@ -2145,7 +2145,6 @@ if host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc' endif endif -with_dri3_modifiers = false with_dri3_explicit_sync = false with_xcb_keysyms = false if with_platform_x11 @@ -2182,13 +2181,8 @@ if with_platform_x11 if with_dri_platform == 'drm' dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8', required : with_x11_dri2) - dep_xcb_dri3 = dependency('xcb-dri3') - dep_xcb_present = dependency('xcb-present') - # until xcb-dri3 has been around long enough to make a hard-dependency: - if (dep_xcb_dri3.version().version_compare('>= 1.13') and - dep_xcb_present.version().version_compare('>= 1.13')) - with_dri3_modifiers = true - endif + dep_xcb_dri3 = dependency('xcb-dri3', version : '>= 1.13') + dep_xcb_present = dependency('xcb-present', version : '>= 1.13') if (dep_xcb_dri3.version().version_compare('>= 1.17') and dep_xcb_present.version().version_compare('>= 1.17')) with_dri3_explicit_sync = true @@ -2232,9 +2226,6 @@ endif if with_x11_dri2 pre_args += '-DHAVE_X11_DRI2' endif -if with_dri3_modifiers - pre_args += '-DHAVE_DRI3_MODIFIERS' -endif if with_dri3_explicit_sync pre_args += '-DHAVE_DRI3_EXPLICIT_SYNC' endif diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index ce4d3ec78ad..56ac2ee37e4 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -1787,7 +1787,7 @@ dri2_x11_check_multibuffers(_EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM bool err; dri2_dpy->multibuffers_available = x11_dri3_check_multibuffer(dri2_dpy->conn, &err, &dri2_dpy->explicit_modifiers); diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c index 5982ff1e972..bd7bcef5d2c 100644 --- a/src/egl/drivers/dri2/platform_x11_dri3.c +++ b/src/egl/drivers/dri2/platform_x11_dri3.c @@ -331,7 +331,7 @@ dri3_create_image_khr_pixmap(_EGLDisplay *disp, _EGLContext *ctx, return &dri2_img->base; } -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM static _EGLImage * dri3_create_image_khr_pixmap_from_buffers(_EGLDisplay *disp, _EGLContext *ctx, EGLClientBuffer buffer, @@ -390,13 +390,13 @@ static _EGLImage * dri3_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list) { -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); #endif switch (target) { case EGL_NATIVE_PIXMAP_KHR: -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (dri2_dpy->multibuffers_available) return dri3_create_image_khr_pixmap_from_buffers(disp, ctx, buffer, attr_list); diff --git a/src/gallium/frontends/dri/loader_dri3_helper.c b/src/gallium/frontends/dri/loader_dri3_helper.c index 49cff99174e..4597defe397 100644 --- a/src/gallium/frontends/dri/loader_dri3_helper.c +++ b/src/gallium/frontends/dri/loader_dri3_helper.c @@ -512,7 +512,7 @@ dri3_handle_present_event(struct loader_dri3_drawable *draw, /* If the server tells us that our allocation is suboptimal, we * reallocate once. */ -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (ce->mode == XCB_PRESENT_COMPLETE_MODE_SUBOPTIMAL_COPY && draw->last_present_mode != ce->mode) { for (int b = 0; b < ARRAY_SIZE(draw->buffers); b++) { @@ -1113,7 +1113,7 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw, */ if (draw->cur_blit_source != -1) options |= XCB_PRESENT_OPTION_COPY; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (draw->multiplanes_available) options |= XCB_PRESENT_OPTION_SUBOPTIMAL; #endif @@ -1316,7 +1316,7 @@ dri3_linear_format_for_format(struct loader_dri3_drawable *draw, uint32_t format } } -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM static bool has_supported_modifier(struct loader_dri3_drawable *draw, unsigned int format, uint64_t *modifiers, uint32_t count) @@ -1400,7 +1400,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int fourcc, goto no_image; if (draw->dri_screen_render_gpu == draw->dri_screen_display_gpu) { -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (draw->multiplanes_available) { xcb_dri3_get_supported_modifiers_cookie_t mod_cookie; xcb_dri3_get_supported_modifiers_reply_t *mod_reply; @@ -1573,7 +1573,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int fourcc, } pixmap = xcb_generate_id(draw->conn); -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (draw->multiplanes_available && buffer->modifier != DRM_FORMAT_MOD_INVALID) { xcb_dri3_pixmap_from_buffers(draw->conn, @@ -1805,7 +1805,7 @@ loader_dri3_create_image(xcb_connection_t *c, return ret; } -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM __DRIimage * loader_dri3_create_image_from_buffers(xcb_connection_t *c, xcb_dri3_buffers_from_pixmap_reply_t *bp_reply, @@ -1854,7 +1854,7 @@ loader_dri3_get_pixmap_buffer(xcb_connection_t *conn, xcb_drawable_t pixmap, __D int *width, int *height, void *loader_data) { __DRIimage *image; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (multiplanes_available) { xcb_dri3_buffers_from_pixmap_cookie_t bps_cookie; xcb_dri3_buffers_from_pixmap_reply_t *bps_reply; diff --git a/src/gallium/frontends/dri/loader_dri3_helper.h b/src/gallium/frontends/dri/loader_dri3_helper.h index 2d669117741..f462d51b480 100644 --- a/src/gallium/frontends/dri/loader_dri3_helper.h +++ b/src/gallium/frontends/dri/loader_dri3_helper.h @@ -256,7 +256,7 @@ loader_dri3_create_image(xcb_connection_t *c, __DRIscreen *dri_screen, void *loaderPrivate); -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM PUBLIC __DRIimage * loader_dri3_create_image_from_buffers(xcb_connection_t *c, xcb_dri3_buffers_from_pixmap_reply_t *bp_reply, diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 717994c81d0..65c0d5e02cc 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -189,7 +189,7 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable, pdraw->base.drawable = drawable; pdraw->base.psc = &psc->base; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM has_multibuffer = base->display->has_multibuffer; #endif diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index f2049101a3f..ff57a259046 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -2825,7 +2825,7 @@ wsi_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, if (!crtc) return VK_ERROR_INITIALIZATION_FAILED; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM xcb_randr_lease_t lease = xcb_generate_id(connection); xcb_randr_create_lease_cookie_t cl_c = xcb_randr_create_lease(connection, root, lease, 1, 1, diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 9cc4b25ad2e..03980b8d583 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -293,7 +293,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, } wsi_conn->has_dri3 = dri3_reply->present != 0; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (wsi_conn->has_dri3) { xcb_dri3_query_version_cookie_t ver_cookie; xcb_dri3_query_version_reply_t *ver_reply; @@ -309,7 +309,7 @@ wsi_x11_connection_create(struct wsi_device *wsi_dev, #endif wsi_conn->has_present = pres_reply->present != 0; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (wsi_conn->has_present) { xcb_present_query_version_cookie_t ver_cookie; xcb_present_query_version_reply_t *ver_reply; @@ -1236,7 +1236,7 @@ x11_get_wsi_image(struct wsi_swapchain *wsi_chain, uint32_t image_index) struct x11_swapchain *chain = (struct x11_swapchain *)wsi_chain; return &chain->images[image_index].base; } -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM static bool wsi_x11_swapchain_query_dri3_modifiers_changed(struct x11_swapchain *chain); #endif @@ -1339,7 +1339,7 @@ x11_handle_dri3_present_event(struct x11_swapchain *chain, */ chain->copy_is_suboptimal = true; break; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM case XCB_PRESENT_COMPLETE_MODE_SUBOPTIMAL_COPY: /* The winsys is now trying to flip directly and cannot due to our * configuration. Request the user reallocate. @@ -1399,10 +1399,8 @@ x11_present_to_x11_dri3(struct x11_swapchain *chain, uint32_t image_index, && chain->has_async_may_tear) options |= XCB_PRESENT_OPTION_ASYNC_MAY_TEAR; -#ifdef HAVE_DRI3_MODIFIERS if (chain->has_dri3_modifiers) options |= XCB_PRESENT_OPTION_SUBOPTIMAL; -#endif xshmfence_reset(image->shm_fence); @@ -2101,7 +2099,6 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, } image->pixmap = xcb_generate_id(chain->conn); -#ifdef HAVE_DRI3_MODIFIERS if (image->base.drm_modifier != DRM_FORMAT_MOD_INVALID) { /* If the image has a modifier, we must have DRI3 v1.2. */ assert(chain->has_dri3_modifiers); @@ -2136,9 +2133,7 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, chain->depth, bpp, image->base.drm_modifier, fds); - } else -#endif - { + } else { /* Without passing modifiers, we can't have multi-plane RGB images. */ assert(image->base.num_planes == 1); @@ -2282,7 +2277,7 @@ wsi_x11_get_dri3_modifiers(struct wsi_x11_connection *wsi_conn, if (!wsi_conn->has_dri3_modifiers) goto out; -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM xcb_generic_error_t *error = NULL; xcb_dri3_get_supported_modifiers_cookie_t mod_cookie = xcb_dri3_get_supported_modifiers(conn, window, depth, bpp); @@ -2346,7 +2341,7 @@ wsi_x11_get_dri3_modifiers(struct wsi_x11_connection *wsi_conn, out: *num_tranches_in = 0; } -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM static bool wsi_x11_swapchain_query_dri3_modifiers_changed(struct x11_swapchain *chain) { diff --git a/src/x11/loader_x11.c b/src/x11/loader_x11.c index 338c705cda6..75eb560595f 100644 --- a/src/x11/loader_x11.c +++ b/src/x11/loader_x11.c @@ -84,7 +84,7 @@ x11_dri3_open(xcb_connection_t *conn, #define DRI3_SUPPORTED_MAJOR 1 #define PRESENT_SUPPORTED_MAJOR 1 -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM #define DRI3_SUPPORTED_MINOR 2 #define PRESENT_SUPPORTED_MINOR 2 #else @@ -139,7 +139,7 @@ x11_dri3_check_multibuffer(xcb_connection_t *c, bool *err, bool *explicit_modifi int presentMinor = present_reply->minor_version; free(present_reply); -#ifdef HAVE_DRI3_MODIFIERS +#ifdef HAVE_X11_DRM if (presentMajor > 1 || (presentMajor == 1 && presentMinor >= 2)) { *explicit_modifiers = dri3Major > 1 || (dri3Major == 1 && dri3Minor >= 2); if (dri3Major >= 1)