st/va: clean up post process includes
[mesa.git] / src / gallium / state_trackers / va / postproc.c
1 /**************************************************************************
2 *
3 * Copyright 2015 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include "util/u_handle_table.h"
29
30 #include "va_private.h"
31
32 VAStatus
33 vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)
34 {
35 struct u_rect src_rect;
36 struct u_rect dst_rect;
37 vlVaSurface *src_surface;
38 VAProcPipelineParameterBuffer *pipeline_param;
39 struct pipe_surface **surfaces;
40 struct pipe_screen *screen;
41 struct pipe_surface *psurf;
42
43 if (!drv || !context)
44 return VA_STATUS_ERROR_INVALID_CONTEXT;
45
46 if (!buf || !buf->data)
47 return VA_STATUS_ERROR_INVALID_BUFFER;
48
49 if (!context->target)
50 return VA_STATUS_ERROR_INVALID_SURFACE;
51
52 pipeline_param = (VAProcPipelineParameterBuffer *)buf->data;
53
54 src_surface = handle_table_get(drv->htab, pipeline_param->surface);
55 if (!src_surface || !src_surface->buffer)
56 return VA_STATUS_ERROR_INVALID_SURFACE;
57
58 surfaces = context->target->get_surfaces(context->target);
59
60 if (!surfaces || !surfaces[0])
61 return VA_STATUS_ERROR_INVALID_SURFACE;
62
63 screen = drv->pipe->screen;
64
65 psurf = surfaces[0];
66
67 src_rect.x0 = pipeline_param->surface_region->x;
68 src_rect.y0 = pipeline_param->surface_region->y;
69 src_rect.x1 = pipeline_param->surface_region->x + pipeline_param->surface_region->width;
70 src_rect.y1 = pipeline_param->surface_region->y + pipeline_param->surface_region->height;
71
72 dst_rect.x0 = pipeline_param->output_region->x;
73 dst_rect.y0 = pipeline_param->output_region->y;
74 dst_rect.x1 = pipeline_param->output_region->x + pipeline_param->output_region->width;
75 dst_rect.y1 = pipeline_param->output_region->y + pipeline_param->output_region->height;
76
77 vl_compositor_clear_layers(&drv->cstate);
78 vl_compositor_set_buffer_layer(&drv->cstate, &drv->compositor, 0, src_surface->buffer, &src_rect, NULL, VL_COMPOSITOR_WEAVE);
79 vl_compositor_set_layer_dst_area(&drv->cstate, 0, &dst_rect);
80 vl_compositor_render(&drv->cstate, &drv->compositor, psurf, NULL, false);
81
82 screen->fence_reference(screen, &src_surface->fence, NULL);
83 drv->pipe->flush(drv->pipe, &src_surface->fence, 0);
84
85 return VA_STATUS_SUCCESS;
86 }
87
88