vl/dri3: add support for 10 bits format
authorLeo Liu <leo.liu@amd.com>
Mon, 10 Sep 2018 19:33:28 +0000 (15:33 -0400)
committerLeo Liu <leo.liu@amd.com>
Thu, 13 Sep 2018 18:28:32 +0000 (14:28 -0400)
Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/auxiliary/vl/vl_winsys_dri3.c

index 8e3c4a0e04dae255172a85be83f45367795edf94..30e732e38eb240e8bbaccac29dca885dc8bf0a34 100644 (file)
@@ -238,7 +238,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
 
    memset(&templ, 0, sizeof(templ));
    templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
-   templ.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+   templ.format = vl_dri2_format_for_depth(&scrn->base, scrn->depth);
    templ.target = PIPE_TEXTURE_2D;
    templ.last_level = 0;
    templ.width0 = (scrn->output_texture) ?
@@ -497,7 +497,7 @@ dri3_get_front_buffer(struct vl_dri3_screen *scrn)
    whandle.stride = bp_reply->stride;
    memset(&templ, 0, sizeof(templ));
    templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
-   templ.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+   templ.format = vl_dri2_format_for_depth(&scrn->base, bp_reply->depth);
    templ.target = PIPE_TEXTURE_2D;
    templ.last_level = 0;
    templ.width0 = bp_reply->width;
@@ -539,6 +539,20 @@ free_buffer:
    return NULL;
 }
 
+static xcb_screen_t *
+dri3_get_screen_for_root(xcb_connection_t *conn, xcb_window_t root)
+{
+   xcb_screen_iterator_t screen_iter =
+   xcb_setup_roots_iterator(xcb_get_setup(conn));
+
+   for (; screen_iter.rem; xcb_screen_next (&screen_iter)) {
+      if (screen_iter.data->root == root)
+         return screen_iter.data;
+   }
+
+   return NULL;
+}
+
 static void
 vl_dri3_flush_frontbuffer(struct pipe_screen *screen,
                           struct pipe_resource *resource,
@@ -809,8 +823,15 @@ vl_dri3_screen_create(Display *display, int screen)
    geom_reply = xcb_get_geometry_reply(scrn->conn, geom_cookie, NULL);
    if (!geom_reply)
       goto close_fd;
-   /* TODO support depth other than 24 */
-   if (geom_reply->depth != 24) {
+
+   scrn->base.xcb_screen = dri3_get_screen_for_root(scrn->conn, geom_reply->root);
+   if (!scrn->base.xcb_screen) {
+      free(geom_reply);
+      goto close_fd;
+   }
+
+   /* TODO support depth other than 24 or 30 */
+   if (geom_reply->depth != 24 && geom_reply->depth != 30) {
       free(geom_reply);
       goto close_fd;
    }