[Mesa-dev] [PATCH] [rfc] dri3: allow building against older xcb

Marek Olšák maraeo at gmail.com
Mon Mar 12 17:59:04 UTC 2018


This is good, though some older distros only have libxcb 1.11.

Marek

On Sun, Mar 11, 2018 at 7:26 PM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> 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.
> ---
>  configure.ac                             |  4 ++--
>  src/egl/drivers/dri2/platform_x11_dri3.c |  4 ++++
>  src/loader/loader_dri3_helper.c          | 22 ++++++++++++++++------
>  src/loader/loader_dri3_helper.h          |  3 ++-
>  4 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 1553ce9..6a1f139 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_REQUIRED=1.12
>  XCBGLX_REQUIRED=1.8.1
> -XCBPRESENT_REQUIRED=1.13
> +XCBPRESENT_REQUIRED=1.12
>  XDAMAGE_REQUIRED=1.1
>  XSHMFENCE_REQUIRED=1.1
>  XVMC_REQUIRED=1.0.6
> diff --git a/src/egl/drivers/dri2/platform_x11_dri3.c b/src/egl/drivers/dri2/platform_x11_dri3.c
> index dce3356..efe030a 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)
>  {
> +#if XCB_DRI3_MAJOR_VERSION == 1 && XCB_DRI3_MINOR_VERSION > 0
>     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 585f7ce..624ef1b 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 XCB_PRESENT_COMPLETE_MODE_SUBOPTIMAL_COPY
>           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 XCB_PRESENT_OPTION_SUBOPTIMAL
>        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;
>  }
>
> +#if XCB_DRI3_MAJOR_VERSION == 1 && XCB_DRI3_MINOR_VERSION > 0
>  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) {
> +#if XCB_DRI3_MAJOR_VERSION == 1 && XCB_DRI3_MINOR_VERSION > 0
>        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) {
> + #if XCB_DRI3_MAJOR_VERSION == 1 && XCB_DRI3_MINOR_VERSION > 0
>        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;
>  }
>
> +#if XCB_DRI3_MAJOR_VERSION == 1 && XCB_DRI3_MINOR_VERSION > 0
>  __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);
> -
> +#if XCB_DRI3_MAJOR_VERSION == 1 && XCB_DRI3_MINOR_VERSION > 0
>     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 de22c19..46f3d09 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);
>
> +#if XCB_DRI3_MAJOR_VERSION == 1 && XCB_DRI3_MINOR_VERSION > 0
>  __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,
> --
> 2.9.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list