backend/x11: add support for DRI3 1.0
Add fallbacks when DRI3 1.2 isn't supported. Closes: https://github.com/swaywm/wlroots/issues/2586
This commit is contained in:
parent
284233c34f
commit
e537382991
|
@ -297,6 +297,10 @@ static int query_dri3_drm_fd(struct wlr_x11_backend *x11) {
|
||||||
|
|
||||||
static bool query_dri3_modifiers(struct wlr_x11_backend *x11,
|
static bool query_dri3_modifiers(struct wlr_x11_backend *x11,
|
||||||
const struct wlr_x11_format *format) {
|
const struct wlr_x11_format *format) {
|
||||||
|
if (x11->dri3_major_version == 1 && x11->dri3_minor_version < 2) {
|
||||||
|
return true; // GetSupportedModifiers requires DRI3 1.2
|
||||||
|
}
|
||||||
|
|
||||||
// Query the root window's supported modifiers, because we only care about
|
// Query the root window's supported modifiers, because we only care about
|
||||||
// screen_modifiers for now
|
// screen_modifiers for now
|
||||||
xcb_dri3_get_supported_modifiers_cookie_t modifiers_cookie =
|
xcb_dri3_get_supported_modifiers_cookie_t modifiers_cookie =
|
||||||
|
@ -415,13 +419,14 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
|
||||||
xcb_dri3_query_version(x11->xcb, 1, 2);
|
xcb_dri3_query_version(x11->xcb, 1, 2);
|
||||||
xcb_dri3_query_version_reply_t *dri3_reply =
|
xcb_dri3_query_version_reply_t *dri3_reply =
|
||||||
xcb_dri3_query_version_reply(x11->xcb, dri3_cookie, NULL);
|
xcb_dri3_query_version_reply(x11->xcb, dri3_cookie, NULL);
|
||||||
if (!dri3_reply || dri3_reply->major_version < 1 ||
|
if (!dri3_reply || dri3_reply->major_version < 1) {
|
||||||
dri3_reply->minor_version < 2) {
|
|
||||||
wlr_log(WLR_ERROR, "X11 does not support required DRI3 version "
|
wlr_log(WLR_ERROR, "X11 does not support required DRI3 version "
|
||||||
"(has %"PRIu32".%"PRIu32", want 1.2)",
|
"(has %"PRIu32".%"PRIu32", want 1.0)",
|
||||||
dri3_reply->major_version, dri3_reply->minor_version);
|
dri3_reply->major_version, dri3_reply->minor_version);
|
||||||
goto error_display;
|
goto error_display;
|
||||||
}
|
}
|
||||||
|
x11->dri3_major_version = dri3_reply->major_version;
|
||||||
|
x11->dri3_minor_version = dri3_reply->minor_version;
|
||||||
free(dri3_reply);
|
free(dri3_reply);
|
||||||
|
|
||||||
// Present extension
|
// Present extension
|
||||||
|
|
|
@ -164,11 +164,23 @@ static struct wlr_x11_buffer *create_x11_buffer(struct wlr_x11_output *output,
|
||||||
|
|
||||||
const struct wlr_x11_format *x11_fmt = x11->x11_format;
|
const struct wlr_x11_format *x11_fmt = x11->x11_format;
|
||||||
xcb_pixmap_t pixmap = xcb_generate_id(x11->xcb);
|
xcb_pixmap_t pixmap = xcb_generate_id(x11->xcb);
|
||||||
xcb_dri3_pixmap_from_buffers(x11->xcb, pixmap, output->win,
|
|
||||||
attrs.n_planes, attrs.width, attrs.height, attrs.stride[0],
|
if (x11->dri3_major_version > 1 || x11->dri3_minor_version >= 2) {
|
||||||
attrs.offset[0], attrs.stride[1], attrs.offset[1], attrs.stride[2],
|
xcb_dri3_pixmap_from_buffers(x11->xcb, pixmap, output->win,
|
||||||
attrs.offset[2], attrs.stride[3], attrs.offset[3], x11_fmt->depth,
|
attrs.n_planes, attrs.width, attrs.height, attrs.stride[0],
|
||||||
x11_fmt->bpp, attrs.modifier, dup_attrs.fd);
|
attrs.offset[0], attrs.stride[1], attrs.offset[1], attrs.stride[2],
|
||||||
|
attrs.offset[2], attrs.stride[3], attrs.offset[3], x11_fmt->depth,
|
||||||
|
x11_fmt->bpp, attrs.modifier, dup_attrs.fd);
|
||||||
|
} else {
|
||||||
|
// PixmapFromBuffers requires DRI3 1.2
|
||||||
|
if (attrs.n_planes != 1 || attrs.modifier != DRM_FORMAT_MOD_INVALID) {
|
||||||
|
wlr_dmabuf_attributes_finish(&dup_attrs);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
xcb_dri3_pixmap_from_buffer(x11->xcb, pixmap, output->win,
|
||||||
|
attrs.height * attrs.stride[0], attrs.width, attrs.height,
|
||||||
|
attrs.stride[0], x11_fmt->depth, x11_fmt->bpp, dup_attrs.fd[0]);
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_x11_buffer *buffer = calloc(1, sizeof(struct wlr_x11_buffer));
|
struct wlr_x11_buffer *buffer = calloc(1, sizeof(struct wlr_x11_buffer));
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct wlr_x11_backend {
|
||||||
xcb_depth_t *depth;
|
xcb_depth_t *depth;
|
||||||
xcb_visualid_t visualid;
|
xcb_visualid_t visualid;
|
||||||
xcb_colormap_t colormap;
|
xcb_colormap_t colormap;
|
||||||
|
uint32_t dri3_major_version, dri3_minor_version;
|
||||||
|
|
||||||
size_t requested_outputs;
|
size_t requested_outputs;
|
||||||
size_t last_output_num;
|
size_t last_output_num;
|
||||||
|
|
Loading…
Reference in New Issue