aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/vl
diff options
context:
space:
mode:
authorLeo Liu <[email protected]>2018-09-07 15:17:31 -0400
committerLeo Liu <[email protected]>2018-09-13 14:28:32 -0400
commit902358de4b9c55f4a5acdc75924c58755274679b (patch)
tree61fdf838062062ec673cebd922cd66773612ae95 /src/gallium/auxiliary/vl
parentaaafae4f55a4b2cf5ddc59ad026f337cae524c8b (diff)
vl/dri: add 10 bits format supports
v2: Tell B10G10R10X2 and R10G10B10X2 formats for different HW. Signed-off-by: Leo Liu <[email protected]> Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/vl')
-rw-r--r--src/gallium/auxiliary/vl/vl_winsys.h5
-rw-r--r--src/gallium/auxiliary/vl/vl_winsys_dri.c70
2 files changed, 65 insertions, 10 deletions
diff --git a/src/gallium/auxiliary/vl/vl_winsys.h b/src/gallium/auxiliary/vl/vl_winsys.h
index 77277cefe8b..bfb60180079 100644
--- a/src/gallium/auxiliary/vl/vl_winsys.h
+++ b/src/gallium/auxiliary/vl/vl_winsys.h
@@ -68,9 +68,14 @@ struct vl_screen
struct pipe_screen *pscreen;
struct pipe_loader_device *dev;
+
+ void *xcb_screen;
};
#ifdef HAVE_X11_PLATFORM
+uint32_t
+vl_dri2_format_for_depth(struct vl_screen *vscreen, int depth);
+
struct vl_screen *
vl_dri2_screen_create(Display *display, int screen);
#else
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index bb1ff504886..cb779010a9c 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -186,6 +186,7 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable)
xcb_dri2_get_buffers_reply_t *reply;
xcb_dri2_dri2_buffer_t *buffers, *back_left;
+ unsigned depth = ((xcb_screen_t *)(vscreen->xcb_screen))->root_depth;
unsigned i;
assert(scrn);
@@ -237,7 +238,7 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable)
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
- templ.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+ templ.format = vl_dri2_format_for_depth(vscreen, depth);
templ.last_level = 0;
templ.width0 = reply->width;
templ.height0 = reply->height;
@@ -314,6 +315,58 @@ get_xcb_screen(xcb_screen_iterator_t iter, int screen)
return NULL;
}
+static xcb_visualtype_t *
+get_xcb_visualtype_for_depth(struct vl_screen *vscreen, int depth)
+{
+ xcb_visualtype_iterator_t visual_iter;
+ xcb_screen_t *screen = vscreen->xcb_screen;
+ xcb_depth_iterator_t depth_iter;
+
+ if (!screen)
+ return NULL;
+
+ depth_iter = xcb_screen_allowed_depths_iterator(screen);
+ for (; depth_iter.rem; xcb_depth_next(&depth_iter)) {
+ if (depth_iter.data->depth != depth)
+ continue;
+
+ visual_iter = xcb_depth_visuals_iterator(depth_iter.data);
+ if (visual_iter.rem)
+ return visual_iter.data;
+ }
+
+ return NULL;
+}
+
+static uint32_t
+get_red_mask_for_depth(struct vl_screen *vscreen, int depth)
+{
+ xcb_visualtype_t *visual = get_xcb_visualtype_for_depth(vscreen, depth);
+
+ if (visual) {
+ return visual->red_mask;
+ }
+
+ return 0;
+}
+
+uint32_t
+vl_dri2_format_for_depth(struct vl_screen *vscreen, int depth)
+{
+ switch (depth) {
+ case 24:
+ return PIPE_FORMAT_B8G8R8X8_UNORM;
+ case 30:
+ /* Different preferred formats for different hw */
+ if (get_red_mask_for_depth(vscreen, 30) == 0x3ff)
+ return PIPE_FORMAT_R10G10B10X2_UNORM;
+ else
+ return PIPE_FORMAT_B10G10R10X2_UNORM;
+ default:
+ return PIPE_FORMAT_NONE;
+ }
+}
+
struct vl_screen *
vl_dri2_screen_create(Display *display, int screen)
{
@@ -326,7 +379,6 @@ vl_dri2_screen_create(Display *display, int screen)
xcb_dri2_authenticate_cookie_t authenticate_cookie;
xcb_dri2_authenticate_reply_t *authenticate = NULL;
xcb_screen_iterator_t s;
- xcb_screen_t *xcb_screen;
xcb_generic_error_t *error = NULL;
char *device_name;
int fd, device_name_length;
@@ -358,8 +410,8 @@ vl_dri2_screen_create(Display *display, int screen)
goto free_query;
s = xcb_setup_roots_iterator(xcb_get_setup(scrn->conn));
- xcb_screen = get_xcb_screen(s, screen);
- if (!xcb_screen)
+ scrn->base.xcb_screen = get_xcb_screen(s, screen);
+ if (!scrn->base.xcb_screen)
goto free_query;
driverType = XCB_DRI2_DRIVER_TYPE_DRI;
@@ -375,9 +427,8 @@ vl_dri2_screen_create(Display *display, int screen)
}
}
- connect_cookie = xcb_dri2_connect_unchecked(scrn->conn,
- xcb_screen->root,
- driverType);
+ connect_cookie = xcb_dri2_connect_unchecked(
+ scrn->conn, ((xcb_screen_t *)(scrn->base.xcb_screen))->root, driverType);
connect = xcb_dri2_connect_reply(scrn->conn, connect_cookie, NULL);
if (connect == NULL ||
connect->driver_name_length + connect->device_name_length == 0)
@@ -397,9 +448,8 @@ vl_dri2_screen_create(Display *display, int screen)
if (drmGetMagic(fd, &magic))
goto close_fd;
- authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn,
- xcb_screen->root,
- magic);
+ authenticate_cookie = xcb_dri2_authenticate_unchecked(
+ scrn->conn, ((xcb_screen_t *)(scrn->base.xcb_screen))->root, magic);
authenticate = xcb_dri2_authenticate_reply(scrn->conn, authenticate_cookie, NULL);
if (authenticate == NULL || !authenticate->authenticated)