Re: [Mesa-dev] [PATCH 1/4] vl/dri: add 10 bits format supports
On 2018-09-10 10:42 p.m., Leo Liu wrote: > v2: Tell B10G10R10X2 and R10G10B10X2 formats for different HW. > > Signed-off-by: Leo Liu This patch and patch 2 are Reviewed-by: Michel Dänzer -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] vl/dri: add 10 bits format supports
On 09/10/2018 04:49 PM, Ilia Mirkin wrote: On Mon, Sep 10, 2018 at 4:27 PM, Leo Liu wrote: v2: Tell B10G10R10X2 and R10G10B10X2 formats for different HW. Signed-off-by: Leo Liu --- src/gallium/auxiliary/vl/vl_winsys.h | 5 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c | 69 2 files changed, 64 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..49c8325866f 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(, 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,57 @@ 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(_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: Probably do a "return PIPE_FORMAT_B8G8R8X8_UNORM" here? Yeah. Already re-sent. Thanks Leo + 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 +378,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 +409,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 +426,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 +447,8 @@ vl_dri2_screen_create(Display *display, int screen) if (drmGetMagic(fd, )) goto close_fd; - authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn, - xcb_screen->root, - magic); +
Re: [Mesa-dev] [PATCH 1/4] vl/dri: add 10 bits format supports
On Mon, Sep 10, 2018 at 4:27 PM, Leo Liu wrote: > v2: Tell B10G10R10X2 and R10G10B10X2 formats for different HW. > > Signed-off-by: Leo Liu > --- > src/gallium/auxiliary/vl/vl_winsys.h | 5 ++ > src/gallium/auxiliary/vl/vl_winsys_dri.c | 69 > 2 files changed, 64 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..49c8325866f 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(, 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,57 @@ 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(_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: Probably do a "return PIPE_FORMAT_B8G8R8X8_UNORM" here? > + 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 +378,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 +409,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 +426,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 +447,8 @@ vl_dri2_screen_create(Display *display, int screen) > if (drmGetMagic(fd, )) >goto close_fd; > > - authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn, >
Re: [Mesa-dev] [PATCH 1/4] vl/dri: add 10 bits format supports
Forget the Patch 1, will re-send shortly. It's ming case 24: +vl_dri2_format_for_depth(struct vl_screen *vscreen, int depth) +{ + switch (depth) { + case 24: + case 30: Leo On 09/10/2018 04:27 PM, Leo Liu wrote: v2: Tell B10G10R10X2 and R10G10B10X2 formats for different HW. Signed-off-by: Leo Liu --- src/gallium/auxiliary/vl/vl_winsys.h | 5 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c | 69 2 files changed, 64 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..49c8325866f 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(, 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,57 @@ 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(_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: + 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 +378,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 +409,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 +426,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 +447,8 @@ vl_dri2_screen_create(Display *display, int screen) if (drmGetMagic(fd, )) goto close_fd; - authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn, - xcb_screen->root, -