diff options
author | Jonathan Marek <[email protected]> | 2019-09-06 09:26:08 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-01-15 02:20:00 +0000 |
commit | a554b45d736073bbea4978118c02f7929f75cd77 (patch) | |
tree | a984afa3d41575dc4868757597e63ace6f2cd6d4 /src/gallium | |
parent | 4e3c81517bafe73015e4af4bdce0eae0cab7751c (diff) |
st/mesa: don't lower YUV when driver supports it natively
This fixes YUYV support on etnaviv.
Fixes: 7404833c "gallium: add handling for YUV planar surfaces"
Signed-off-by: Jonathan Marek <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1896>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/state_trackers/dri/dri2.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 54a05c916f1..e6f0e40465a 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -738,7 +738,7 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, struct pipe_resource templ; unsigned tex_usage = 0; int i; - bool is_yuv = util_format_is_yuv(map->pipe_format); + bool use_lowered = false; if (pscreen->is_format_supported(pscreen, map->pipe_format, screen->target, 0, 0, PIPE_BIND_RENDER_TARGET)) @@ -747,13 +747,14 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, PIPE_BIND_SAMPLER_VIEW)) tex_usage |= PIPE_BIND_SAMPLER_VIEW; - if (!tex_usage && is_yuv) { + if (!tex_usage && util_format_is_yuv(map->pipe_format)) { /* YUV format sampling can be emulated by the Mesa state tracker by * using multiple samplers of varying formats. * If no tex_usage is set and we detect a YUV format, * test for support of the first plane's sampler format and * add sampler view usage. */ + use_lowered = true; if (pscreen->is_format_supported(pscreen, dri2_get_pipe_format_for_dri_format(map->planes[0].dri_format), screen->target, 0, 0, @@ -775,19 +776,20 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, templ.depth0 = 1; templ.array_size = 1; - for (i = num_handles - 1; i >= 0; i--) { + for (i = (use_lowered ? map->nplanes : num_handles) - 1; i >= 0; i--) { struct pipe_resource *tex; templ.width0 = width >> map->planes[i].width_shift; templ.height0 = height >> map->planes[i].height_shift; - if (is_yuv) + if (use_lowered) templ.format = dri2_get_pipe_format_for_dri_format(map->planes[i].dri_format); else templ.format = map->pipe_format; assert(templ.format != PIPE_FORMAT_NONE); tex = pscreen->resource_from_handle(pscreen, - &templ, &whandle[i], PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE); + &templ, &whandle[use_lowered ? map->planes[i].buffer_index : i], + PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE); if (!tex) { pipe_resource_reference(&img->texture, NULL); FREE(img); @@ -911,25 +913,23 @@ dri2_create_image_from_fd(__DRIscreen *_screen, memset(whandles, 0, sizeof(whandles)); - for (i = 0; i < num_handles; i++) { - int fdnum = i >= num_fds ? 0 : i; - int index = i >= map->nplanes ? i : map->planes[i].buffer_index; - if (fds[fdnum] < 0) { + for (i = 0; i < num_fds; i++) { + if (fds[i] < 0) { err = __DRI_IMAGE_ERROR_BAD_ALLOC; goto exit; } whandles[i].type = WINSYS_HANDLE_TYPE_FD; - whandles[i].handle = (unsigned)fds[fdnum]; - whandles[i].stride = (unsigned)strides[index]; - whandles[i].offset = (unsigned)offsets[index]; + whandles[i].handle = (unsigned)fds[i]; + whandles[i].stride = (unsigned)strides[i]; + whandles[i].offset = (unsigned)offsets[i]; whandles[i].format = map->pipe_format; whandles[i].modifier = modifier; - whandles[i].plane = index; + whandles[i].plane = i; } img = dri2_create_image_from_winsys(_screen, width, height, map, - num_handles, whandles, loaderPrivate); + num_fds, whandles, loaderPrivate); if(img == NULL) { err = __DRI_IMAGE_ERROR_BAD_ALLOC; goto exit; |