From: Dave Airlie Date: Tue, 13 Mar 2018 20:06:00 +0000 (+1000) Subject: dri3: allow building against older xcb (v3) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7aeef2d4efdc809a698e9b983c8be8e4ccb27134;p=mesa.git dri3: allow building against older xcb (v3) I'm not sure everyone wants to be updating their dri3 in a forced march setting, this allows a nicer approach, esp when you want to build on distro that aren't brand new. I'm sure there are plenty of ways this patch could be cleaner, and I've also not built it against an updated dri3. For meson I've just left it alone, since if you are using meson you probably don't mind xcb updates, and if you are using meson you can fix this better than me. v3: just don't put a version in for dri3/present without modifiers, should allow building with 1.11 as well (feel free to supply meson followups) Signed-off-by: Dave Airlie Signed-off-by: Marek Olšák --- diff --git a/configure.ac b/configure.ac index 8ec5b26b6dc..d1c8bb82dae 100644 --- a/configure.ac +++ b/configure.ac @@ -92,9 +92,9 @@ WAYLAND_REQUIRED=1.11 WAYLAND_PROTOCOLS_REQUIRED=1.8 XCB_REQUIRED=1.9.3 XCBDRI2_REQUIRED=1.8 -XCBDRI3_REQUIRED=1.13 +XCBDRI3_MODIFIERS_REQUIRED=1.13 XCBGLX_REQUIRED=1.8.1 -XCBPRESENT_REQUIRED=1.13 +XCBPRESENT_MODIFIERS_REQUIRED=1.13 XDAMAGE_REQUIRED=1.1 XSHMFENCE_REQUIRED=1.1 XVMC_REQUIRED=1.0.6 @@ -1850,8 +1850,14 @@ fi if test x"$enable_dri3" = xyes; then DEFINES="$DEFINES -DHAVE_DRI3" - dri3_modules="x11-xcb xcb >= $XCB_REQUIRED xcb-dri3 >= $XCBDRI3_REQUIRED xcb-xfixes xcb-present >= $XCBPRESENT_REQUIRED xcb-sync xshmfence >= $XSHMFENCE_REQUIRED" + dri3_modules="x11-xcb xcb >= $XCB_REQUIRED xcb-dri3 xcb-xfixes xcb-present xcb-sync xshmfence >= $XSHMFENCE_REQUIRED" PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules]) + dri3_modifier_modules="xcb-dri3 >= $XCBDRI3_MODIFIERS_REQUIRED xcb-present >= $XCBPRESENT_MODIFIERS_REQUIRES" + PKG_CHECK_MODULES([XCB_DRI3_MODIFIERS], [$dri3_modifier_modules], [have_dri3_modifiers=yes], [have_dri3_modifiers=no]) + + if test "x$have_dri3_modifiers" == xyes; then + DEFINES="$DEFINES -DHAVE_DRI3_MODIFIERS" + fi fi AM_CONDITIONAL(HAVE_PLATFORM_X11, echo "$platforms" | grep -q 'x11') diff --git a/meson.build b/meson.build index e21ac74a1e3..557e9ef3397 100644 --- a/meson.build +++ b/meson.build @@ -1235,7 +1235,7 @@ if with_platform_x11 dep_xcb_dri2 = dependency('xcb-dri2', version : '>= 1.8') if with_dri3 - pre_args += '-DHAVE_DRI3' + pre_args += '-DHAVE_DRI3 -DHAVE_DRI3_MODIFIERS' dep_xcb_dri3 = dependency('xcb-dri3', version : '>= 1.13') dep_xcb_present = dependency('xcb-present', version: '>= 1.13') dep_xcb_sync = dependency('xcb-sync') diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c index dce33561a6f..de60e952da8 100644 --- a/src/egl/drivers/dri2/platform_x11_dri3.c +++ b/src/egl/drivers/dri2/platform_x11_dri3.c @@ -327,6 +327,7 @@ dri3_create_image_khr_pixmap_from_buffers(_EGLDisplay *disp, _EGLContext *ctx, EGLClientBuffer buffer, const EGLint *attr_list) { +#ifdef HAVE_DRI3_MODIFIERS struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img; xcb_dri3_buffers_from_pixmap_cookie_t bp_cookie; @@ -376,6 +377,9 @@ dri3_create_image_khr_pixmap_from_buffers(_EGLDisplay *disp, _EGLContext *ctx, } return &dri2_img->base; +#else + return NULL; +#endif } static _EGLImage * diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c index 585f7ce3ece..c1d94c3c21e 100644 --- a/src/loader/loader_dri3_helper.c +++ b/src/loader/loader_dri3_helper.c @@ -389,6 +389,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 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++) { @@ -396,7 +397,7 @@ dri3_handle_present_event(struct loader_dri3_drawable *draw, draw->buffers[b]->reallocate = true; } } - +#endif draw->last_present_mode = ce->mode; if (draw->vtable->show_fps) @@ -903,10 +904,10 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw, */ if (!loader_dri3_have_image_blit(draw) && draw->cur_blit_source != -1) options |= XCB_PRESENT_OPTION_COPY; - +#ifdef HAVE_DRI3_MODIFIERS if (draw->multiplanes_available) options |= XCB_PRESENT_OPTION_SUBOPTIMAL; - +#endif back->busy = 1; back->last_swap = draw->send_sbc; xcb_present_pixmap(draw->conn, @@ -1053,6 +1054,7 @@ image_format_to_fourcc(int format) return 0; } +#ifdef HAVE_DRI3_MODIFIERS static bool has_supported_modifier(struct loader_dri3_drawable *draw, unsigned int format, uint64_t *modifiers, uint32_t count) @@ -1087,6 +1089,7 @@ has_supported_modifier(struct loader_dri3_drawable *draw, unsigned int format, free(supported_modifiers); return found; } +#endif /** loader_dri3_alloc_render_buffer * @@ -1132,6 +1135,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, goto no_image; if (!draw->is_different_gpu) { +#ifdef HAVE_DRI3_MODIFIERS if (draw->multiplanes_available && draw->ext->image->base.version >= 15 && draw->ext->image->queryDmaBufModifiers && @@ -1195,7 +1199,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, buffer); free(modifiers); } - +#endif if (!buffer->image) buffer->image = draw->ext->image->createImage(draw->dri_screen, width, height, @@ -1272,6 +1276,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, pixmap = xcb_generate_id(draw->conn); if (draw->multiplanes_available && buffer->modifier != DRM_FORMAT_MOD_INVALID) { +#ifdef HAVE_DRI3_MODIFIERS xcb_dri3_pixmap_from_buffers(draw->conn, pixmap, draw->drawable, @@ -1284,6 +1289,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, depth, buffer->cpp * 8, buffer->modifier, buffer_fds); +#endif } else { xcb_dri3_pixmap_from_buffer(draw->conn, pixmap, @@ -1473,6 +1479,7 @@ loader_dri3_create_image(xcb_connection_t *c, return ret; } +#ifdef HAVE_DRI3_MODIFIERS __DRIimage * loader_dri3_create_image_from_buffers(xcb_connection_t *c, xcb_dri3_buffers_from_pixmap_reply_t *bp_reply, @@ -1514,6 +1521,7 @@ loader_dri3_create_image_from_buffers(xcb_connection_t *c, return ret; } +#endif /** dri3_get_pixmap_buffer * @@ -1567,7 +1575,7 @@ dri3_get_pixmap_buffer(__DRIdrawable *driDrawable, unsigned int format, (sync_fence = xcb_generate_id(draw->conn)), false, fence_fd); - +#ifdef HAVE_DRI3_MODIFIERS if (draw->multiplanes_available && draw->ext->image->base.version >= 15 && draw->ext->image->createImageFromDmaBufs2) { @@ -1586,7 +1594,9 @@ dri3_get_pixmap_buffer(__DRIdrawable *driDrawable, unsigned int format, width = bps_reply->width; height = bps_reply->height; free(bps_reply); - } else { + } else +#endif + { xcb_dri3_buffer_from_pixmap_cookie_t bp_cookie; xcb_dri3_buffer_from_pixmap_reply_t *bp_reply; diff --git a/src/loader/loader_dri3_helper.h b/src/loader/loader_dri3_helper.h index de22c19a578..7e3d82947bc 100644 --- a/src/loader/loader_dri3_helper.h +++ b/src/loader/loader_dri3_helper.h @@ -243,6 +243,7 @@ loader_dri3_create_image(xcb_connection_t *c, const __DRIimageExtension *image, void *loaderPrivate); +#ifdef HAVE_DRI3_MODIFIERS __DRIimage * loader_dri3_create_image_from_buffers(xcb_connection_t *c, xcb_dri3_buffers_from_pixmap_reply_t *bp_reply, @@ -250,7 +251,7 @@ loader_dri3_create_image_from_buffers(xcb_connection_t *c, __DRIscreen *dri_screen, const __DRIimageExtension *image, void *loaderPrivate); - +#endif int loader_dri3_get_buffers(__DRIdrawable *driDrawable, unsigned int format, diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 0667aa1dbc9..71d62cb4cb7 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -759,9 +759,11 @@ x11_handle_dri3_present_event(struct x11_swapchain *chain, /* The winsys is now trying to flip directly and cannot due to our * configuration. Request the user reallocate. */ +#ifdef HAVE_DRI3_MODIFIERS if (complete->mode == XCB_PRESENT_COMPLETE_MODE_SUBOPTIMAL_COPY && chain->last_present_mode != XCB_PRESENT_COMPLETE_MODE_SUBOPTIMAL_COPY) result = VK_SUBOPTIMAL_KHR; +#endif /* When we go from flipping to copying, the odds are very likely that * we could reallocate in a more optimal way if we didn't have to care @@ -908,8 +910,10 @@ x11_present_to_x11(struct x11_swapchain *chain, uint32_t image_index, if (chain->base.present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR) options |= XCB_PRESENT_OPTION_ASYNC; +#ifdef HAVE_DRI3_MODIFIERS if (chain->has_dri3_modifiers) options |= XCB_PRESENT_OPTION_SUBOPTIMAL; +#endif xshmfence_reset(image->shm_fence); @@ -1046,6 +1050,7 @@ 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); @@ -1068,7 +1073,9 @@ x11_image_init(VkDevice device_h, struct x11_swapchain *chain, chain->depth, bpp, image->base.drm_modifier, image->base.fds); - } else { + } else +#endif + { /* Without passing modifiers, we can't have multi-plane RGB images. */ assert(image->base.num_planes == 1); @@ -1151,6 +1158,7 @@ wsi_x11_get_dri3_modifiers(struct wsi_x11_connection *wsi_conn, if (!wsi_conn->has_dri3_modifiers) goto out; +#ifdef HAVE_DRI3_MODIFIERS xcb_generic_error_t *error = NULL; xcb_dri3_get_supported_modifiers_cookie_t mod_cookie = xcb_dri3_get_supported_modifiers(conn, window, depth, bpp); @@ -1210,7 +1218,7 @@ wsi_x11_get_dri3_modifiers(struct wsi_x11_connection *wsi_conn, free(mod_reply); return; - +#endif out: *num_tranches_in = 0; }