diff --git a/src/gallium/frontends/va/context.c b/src/gallium/frontends/va/context.c index 47642aa18ab..7be3490d7cc 100644 --- a/src/gallium/frontends/va/context.c +++ b/src/gallium/frontends/va/context.c @@ -551,8 +551,6 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id) } context->decoder->destroy(context->decoder); } - if (context->blit_cs) - drv->pipe->delete_compute_state(drv->pipe, context->blit_cs); if (context->deint) { vl_deint_filter_cleanup(context->deint); FREE(context->deint); diff --git a/src/gallium/frontends/va/postproc.c b/src/gallium/frontends/va/postproc.c index 10223d5fb02..a5c1e5ac4c7 100644 --- a/src/gallium/frontends/va/postproc.c +++ b/src/gallium/frontends/va/postproc.c @@ -27,7 +27,6 @@ #include "util/u_handle_table.h" #include "util/u_memory.h" -#include "util/u_compute.h" #include "vl/vl_defines.h" #include "vl/vl_video_buffer.h" @@ -77,11 +76,28 @@ vlVaPostProcCompositor(vlVaDriver *drv, vlVaContext *context, dst_rect.x1 = dst_region->x + dst_region->width; dst_rect.y1 = dst_region->y + dst_region->height; - vl_compositor_clear_layers(&drv->cstate); - vl_compositor_set_buffer_layer(&drv->cstate, &drv->compositor, 0, src, - &src_rect, NULL, deinterlace); - vl_compositor_set_layer_dst_area(&drv->cstate, 0, &dst_rect); - vl_compositor_render(&drv->cstate, &drv->compositor, surfaces[0], NULL, false); + if (util_format_is_yuv(dst->buffer_format)) { + if (util_format_is_yuv(src->buffer_format)) { + /* YUV -> YUV */ + if (src->interlaced == dst->interlaced) + deinterlace = VL_COMPOSITOR_NONE; + vl_compositor_yuv_deint_full(&drv->cstate, &drv->compositor, + src, dst, &src_rect, &dst_rect, + deinterlace); + } else { + /* RGB -> YUV */ + vl_compositor_convert_rgb_to_yuv(&drv->cstate, &drv->compositor, 0, + ((struct vl_video_buffer *)src)->resources[0], + dst, &src_rect, &dst_rect); + } + } else { + /* YUV/RGB -> RGB */ + vl_compositor_clear_layers(&drv->cstate); + vl_compositor_set_buffer_layer(&drv->cstate, &drv->compositor, 0, src, + &src_rect, NULL, deinterlace); + vl_compositor_set_layer_dst_area(&drv->cstate, 0, &dst_rect); + vl_compositor_render(&drv->cstate, &drv->compositor, surfaces[0], NULL, false); + } drv->pipe->flush(drv->pipe, NULL, 0); return VA_STATUS_SUCCESS; @@ -351,133 +367,6 @@ static VAStatus vlVaVidEngineBlit(vlVaDriver *drv, vlVaContext *context, return VA_STATUS_SUCCESS; } -static VAStatus vlVaPostProcBlit(vlVaDriver *drv, vlVaContext *context, - const VARectangle *src_region, - const VARectangle *dst_region, - struct pipe_video_buffer *src, - struct pipe_video_buffer *dst, - enum vl_compositor_deinterlace deinterlace) -{ - struct pipe_surface **src_surfaces; - struct pipe_surface **dst_surfaces; - struct u_rect src_rect; - struct u_rect dst_rect; - bool grab = false; - unsigned i, src_num_planes, dst_num_planes; - - src_num_planes = util_format_get_num_planes(src->buffer_format); - dst_num_planes = util_format_get_num_planes(dst->buffer_format); - - if ((src->buffer_format == PIPE_FORMAT_B8G8R8X8_UNORM || - src->buffer_format == PIPE_FORMAT_B8G8R8A8_UNORM || - src->buffer_format == PIPE_FORMAT_R8G8B8X8_UNORM || - src->buffer_format == PIPE_FORMAT_R8G8B8A8_UNORM || - src->buffer_format == PIPE_FORMAT_B10G10R10X2_UNORM || - src->buffer_format == PIPE_FORMAT_B10G10R10A2_UNORM || - src->buffer_format == PIPE_FORMAT_R10G10B10X2_UNORM || - src->buffer_format == PIPE_FORMAT_R10G10B10A2_UNORM) && - !src->interlaced) - grab = true; - - src_surfaces = src->get_surfaces(src); - if (!src_surfaces || !src_surfaces[0]) - return VA_STATUS_ERROR_INVALID_SURFACE; - - dst_surfaces = dst->get_surfaces(dst); - if (!dst_surfaces || !dst_surfaces[0]) - return VA_STATUS_ERROR_INVALID_SURFACE; - - src_rect.x0 = src_region->x; - src_rect.y0 = src_region->y; - src_rect.x1 = src_region->x + src_region->width; - src_rect.y1 = src_region->y + src_region->height; - - dst_rect.x0 = dst_region->x; - dst_rect.y0 = dst_region->y; - dst_rect.x1 = dst_region->x + dst_region->width; - dst_rect.y1 = dst_region->y + dst_region->height; - - if (grab) { - vl_compositor_convert_rgb_to_yuv(&drv->cstate, &drv->compositor, 0, - ((struct vl_video_buffer *)src)->resources[0], - dst, &src_rect, &dst_rect); - - return VA_STATUS_SUCCESS; - } - - if (src->buffer_format == PIPE_FORMAT_YUYV || - src->buffer_format == PIPE_FORMAT_UYVY || - src->buffer_format == PIPE_FORMAT_YV12 || - src->buffer_format == PIPE_FORMAT_IYUV || - (src->interlaced == dst->interlaced && - src_num_planes != dst_num_planes)) { - vl_compositor_yuv_deint_full(&drv->cstate, &drv->compositor, - src, dst, &src_rect, &dst_rect, - VL_COMPOSITOR_NONE); - - return VA_STATUS_SUCCESS; - } - - if (src->interlaced != dst->interlaced) { - deinterlace = deinterlace ? deinterlace : VL_COMPOSITOR_WEAVE; - vl_compositor_yuv_deint_full(&drv->cstate, &drv->compositor, - src, dst, &src_rect, &dst_rect, - deinterlace); - - return VA_STATUS_SUCCESS; - } - - for (i = 0; i < VL_MAX_SURFACES; ++i) { - struct pipe_surface *from = src_surfaces[i]; - struct pipe_blit_info blit; - - if (src->interlaced) { - /* Not 100% accurate, but close enough */ - switch (deinterlace) { - case VL_COMPOSITOR_BOB_TOP: - from = src_surfaces[i & ~1]; - break; - case VL_COMPOSITOR_BOB_BOTTOM: - from = src_surfaces[(i & ~1) + 1]; - break; - default: - break; - } - } - - if (!from || !dst_surfaces[i]) - continue; - - memset(&blit, 0, sizeof(blit)); - blit.src.resource = from->texture; - blit.src.format = from->format; - blit.src.level = 0; - blit.src.box.z = from->u.tex.first_layer; - blit.src.box.depth = 1; - vlVaGetBox(src, i, &blit.src.box, src_region); - - blit.dst.resource = dst_surfaces[i]->texture; - blit.dst.format = dst_surfaces[i]->format; - blit.dst.level = 0; - blit.dst.box.z = dst_surfaces[i]->u.tex.first_layer; - blit.dst.box.depth = 1; - vlVaGetBox(dst, i, &blit.dst.box, dst_region); - - blit.mask = PIPE_MASK_RGBA; - blit.filter = PIPE_TEX_MIPFILTER_LINEAR; - - if (drv->pipe->screen->caps.prefer_compute_for_multimedia) - util_compute_blit(drv->pipe, &blit, &context->blit_cs); - else - drv->pipe->blit(drv->pipe, &blit); - } - - // TODO: figure out why this is necessary for DMA-buf sharing - drv->pipe->flush(drv->pipe, NULL, 0); - - return VA_STATUS_SUCCESS; -} - static struct pipe_video_buffer * vlVaApplyDeint(vlVaDriver *drv, vlVaContext *context, VAProcPipelineParameterBuffer *param, @@ -685,13 +574,8 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *contex vlVaSetProcParameters(drv, src_surface, dst_surface, param); - /* Try other post proc implementations */ - if (!util_format_is_yuv(context->target->buffer_format)) - ret = vlVaPostProcCompositor(drv, context, src_region, dst_region, - src, context->target, deinterlace); - else - ret = vlVaPostProcBlit(drv, context, src_region, dst_region, - src, context->target, deinterlace); + ret = vlVaPostProcCompositor(drv, context, src_region, dst_region, + src, context->target, deinterlace); /* Reset chroma location */ drv->cstate.chroma_location = VL_COMPOSITOR_LOCATION_NONE; diff --git a/src/gallium/frontends/va/va_private.h b/src/gallium/frontends/va/va_private.h index d7bff14f606..8a14aadf4fb 100644 --- a/src/gallium/frontends/va/va_private.h +++ b/src/gallium/frontends/va/va_private.h @@ -422,7 +422,6 @@ typedef struct vlVaContext { int target_id; int gop_coeff; bool needs_begin_frame; - void *blit_cs; int packed_header_type; bool packed_header_emulation_bytes; struct set *surfaces;