diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-01-29 11:52:33 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2019-01-29 11:52:33 +0000 |
commit | 37bbf6a1792773f11c15a4da1588a7520ee2fb4e (patch) | |
tree | 64944d4aa665a1e479cfc004e446593062254550 /lib/mesa/src/gallium/auxiliary/vl | |
parent | 6b139c2063623e9310025247cd966490b9aa57ea (diff) |
Merge Mesa 18.3.2
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/vl')
12 files changed, 129 insertions, 49 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c index a3dc6c8c5..f3f8cbee7 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_bicubic_filter.c @@ -262,7 +262,9 @@ vl_bicubic_filter_init(struct vl_bicubic_filter *filter, struct pipe_context *pi memset(&rs_state, 0, sizeof(rs_state)); rs_state.half_pixel_center = true; rs_state.bottom_edge_rule = true; - rs_state.depth_clip = 1; + rs_state.depth_clip_near = 1; + rs_state.depth_clip_far = 1; + filter->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); if (!filter->rs_state) goto error_rs_state; diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c index 67ad7f5be..159a2952a 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_compositor.c @@ -611,7 +611,8 @@ init_pipe_state(struct vl_compositor *c) rast.offset_scale = 1; rast.half_pixel_center = 1; rast.bottom_edge_rule = 1; - rast.depth_clip = 1; + rast.depth_clip_near = 1; + rast.depth_clip_far = 1; c->rast = c->pipe->create_rasterizer_state(c->pipe, &rast); @@ -1437,7 +1438,7 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip * Const buffer contains the color conversion matrix and bias vectors */ /* XXX: Create with IMMUTABLE/STATIC... although it does change every once in a long while... */ - s->csc_matrix = pipe_buffer_create + s->csc_matrix = pipe_buffer_create_const0 ( pipe->screen, PIPE_BIND_CONSTANT_BUFFER, diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c index d2c48bda7..dbd6be534 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_deint_filter.c @@ -273,7 +273,9 @@ vl_deint_filter_init(struct vl_deint_filter *filter, struct pipe_context *pipe, memset(&rs_state, 0, sizeof(rs_state)); rs_state.half_pixel_center = true; rs_state.bottom_edge_rule = true; - rs_state.depth_clip = 1; + rs_state.depth_clip_near = 1; + rs_state.depth_clip_far = 1; + filter->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); if (!filter->rs_state) goto error_rs_state; diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c index 1dacc7c60..4a24c6a3f 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_matrix_filter.c @@ -151,7 +151,9 @@ vl_matrix_filter_init(struct vl_matrix_filter *filter, struct pipe_context *pipe memset(&rs_state, 0, sizeof(rs_state)); rs_state.half_pixel_center = true; rs_state.bottom_edge_rule = true; - rs_state.depth_clip = 1; + rs_state.depth_clip_near = 1; + rs_state.depth_clip_far = 1; + filter->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); if (!filter->rs_state) goto error_rs_state; diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c b/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c index 273afaf2f..b10237d1e 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_median_filter.c @@ -262,7 +262,9 @@ vl_median_filter_init(struct vl_median_filter *filter, struct pipe_context *pipe memset(&rs_state, 0, sizeof(rs_state)); rs_state.half_pixel_center = true; rs_state.bottom_edge_rule = true; - rs_state.depth_clip = 1; + rs_state.depth_clip_near = 1; + rs_state.depth_clip_far = 1; + filter->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); if (!filter->rs_state) goto error_rs_state; diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 8a2dae34e..9589b1e89 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -908,20 +908,20 @@ find_format_config(struct vl_mpeg12_decoder *dec, const struct format_config con for (i = 0; i < num_configs; ++i) { if (!screen->is_format_supported(screen, configs[i].zscan_source_format, PIPE_TEXTURE_2D, - 1, PIPE_BIND_SAMPLER_VIEW)) + 1, 1, PIPE_BIND_SAMPLER_VIEW)) continue; if (configs[i].idct_source_format != PIPE_FORMAT_NONE) { if (!screen->is_format_supported(screen, configs[i].idct_source_format, PIPE_TEXTURE_2D, - 1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET)) + 1, 1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET)) continue; if (!screen->is_format_supported(screen, configs[i].mc_source_format, PIPE_TEXTURE_3D, - 1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET)) + 1, 1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET)) continue; } else { if (!screen->is_format_supported(screen, configs[i].mc_source_format, PIPE_TEXTURE_2D, - 1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET)) + 1, 1, PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET)) continue; } return &configs[i]; diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c b/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c index 3b97ac81a..5b54ee1dd 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_video_buffer.c @@ -192,11 +192,11 @@ vl_video_buffer_is_format_supported(struct pipe_screen *screen, continue; /* we at least need to sample from it */ - if (!screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)) + if (!screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW)) return false; format = vl_video_buffer_surface_format(format); - if (!screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET)) + if (!screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_RENDER_TARGET)) return false; } diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h index 77277cefe..3a35cb6a8 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys.h @@ -68,9 +68,15 @@ struct vl_screen struct pipe_screen *pscreen; struct pipe_loader_device *dev; + + void *xcb_screen; + uint32_t color_depth; }; #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/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c index 79ebf750c..1905516a7 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -29,7 +29,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> #include <X11/Xlib-xcb.h> #include <X11/extensions/dri2tokens.h> @@ -186,6 +185,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); @@ -231,13 +231,13 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable) } memset(&dri2_handle, 0, sizeof(dri2_handle)); - dri2_handle.type = DRM_API_HANDLE_TYPE_SHARED; + dri2_handle.type = WINSYS_HANDLE_TYPE_SHARED; dri2_handle.handle = back_left->name; dri2_handle.stride = back_left->pitch; 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; @@ -249,7 +249,7 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable) tex = scrn->base.pscreen->resource_from_handle(scrn->base.pscreen, &templ, &dri2_handle, - PIPE_HANDLE_USAGE_READ_WRITE); + PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE); free(reply); return tex; @@ -314,6 +314,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 +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, &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) @@ -421,6 +470,8 @@ vl_dri2_screen_create(Display *display, int screen) vl_compositor_reset_dirty_area(&scrn->dirty_areas[0]); vl_compositor_reset_dirty_area(&scrn->dirty_areas[1]); + /* The pipe loader duplicates the fd */ + close(fd); free(authenticate); free(connect); free(dri2_query); @@ -429,15 +480,12 @@ vl_dri2_screen_create(Display *display, int screen) return &scrn->base; release_pipe: - if (scrn->base.dev) { + if (scrn->base.dev) pipe_loader_release(&scrn->base.dev, 1); - fd = -1; - } free_authenticate: free(authenticate); close_fd: - if (fd != -1) - close(fd); + close(fd); free_connect: free(connect); free_query: @@ -465,5 +513,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen) vl_dri2_destroy_drawable(scrn); scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); + /* There is no user provided fd */ FREE(scrn); } diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c index 8251087f3..152d28e59 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_dri3.c @@ -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) ? @@ -271,8 +271,8 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn) pixmap_buffer_texture = buffer->texture; } memset(&whandle, 0, sizeof(whandle)); - whandle.type= DRM_API_HANDLE_TYPE_FD; - usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ; + whandle.type= WINSYS_HANDLE_TYPE_FD; + usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH; scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL, pixmap_buffer_texture, &whandle, usage); @@ -492,12 +492,12 @@ dri3_get_front_buffer(struct vl_dri3_screen *scrn) goto free_reply; memset(&whandle, 0, sizeof(whandle)); - whandle.type = DRM_API_HANDLE_TYPE_FD; + whandle.type = WINSYS_HANDLE_TYPE_FD; whandle.handle = (unsigned)fds[0]; 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; @@ -507,7 +507,7 @@ dri3_get_front_buffer(struct vl_dri3_screen *scrn) scrn->front_buffer->texture = scrn->base.pscreen->resource_from_handle(scrn->base.pscreen, &templ, &whandle, - PIPE_HANDLE_USAGE_READ_WRITE); + PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE); close(fds[0]); if (!scrn->front_buffer->texture) goto free_reply; @@ -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, @@ -712,7 +726,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen) if (scrn->front_buffer) { dri3_free_front_buffer(scrn, scrn->front_buffer); scrn->front_buffer = NULL; - return; } for (i = 0; i < BACK_BUFFER_NUM; ++i) { @@ -809,11 +822,19 @@ 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; } + scrn->base.color_depth = geom_reply->depth; free(geom_reply); if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd)) diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c index df8809c50..9014b97bd 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -26,7 +26,6 @@ **************************************************************************/ #include <assert.h> -#include <fcntl.h> #include "pipe/p_screen.h" #include "pipe-loader/pipe_loader.h" @@ -42,16 +41,12 @@ struct vl_screen * vl_drm_screen_create(int fd) { struct vl_screen *vscreen; - int new_fd; vscreen = CALLOC_STRUCT(vl_screen); if (!vscreen) return NULL; - if (fd < 0 || (new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0) - goto free_screen; - - if (pipe_loader_drm_probe_fd(&vscreen->dev, new_fd)) + if (pipe_loader_drm_probe_fd(&vscreen->dev, fd)) vscreen->pscreen = pipe_loader_create_screen(vscreen->dev); if (!vscreen->pscreen) @@ -68,10 +63,7 @@ vl_drm_screen_create(int fd) release_pipe: if (vscreen->dev) pipe_loader_release(&vscreen->dev, 1); - else - close(new_fd); -free_screen: FREE(vscreen); return NULL; } @@ -83,5 +75,6 @@ vl_drm_screen_destroy(struct vl_screen *vscreen) vscreen->pscreen->destroy(vscreen->pscreen); pipe_loader_release(&vscreen->dev, 1); + /* CHECK: The VAAPI loader/user preserves ownership of the original fd */ FREE(vscreen); } diff --git a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c index 75013c42b..769fc71ff 100644 --- a/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c +++ b/lib/mesa/src/gallium/auxiliary/vl/vl_zscan.c @@ -297,7 +297,9 @@ init_state(struct vl_zscan *zscan) memset(&rs_state, 0, sizeof(rs_state)); rs_state.half_pixel_center = true; rs_state.bottom_edge_rule = true; - rs_state.depth_clip = 1; + rs_state.depth_clip_near = 1; + rs_state.depth_clip_far = 1; + zscan->rs_state = zscan->pipe->create_rasterizer_state(zscan->pipe, &rs_state); if (!zscan->rs_state) goto error_rs_state; |