[Mesa-dev] [PATCH 10/15] st/va: implement vlVaPutSurface
Christian König
deathsimple at vodafone.de
Tue Jun 18 02:27:40 PDT 2013
From: Christian König <christian.koenig at amd.com>
Signed-off-by: Christian König <christian.koenig at amd.com>
---
src/gallium/state_trackers/va/context.c | 6 ++++
src/gallium/state_trackers/va/surface.c | 50 ++++++++++++++++++++++++++--
src/gallium/state_trackers/va/va_private.h | 6 ++++
3 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c
index d535a6b..b3c5757 100644
--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -107,6 +107,12 @@ __vaDriverInit_0_32(VADriverContextP ctx)
if (!drv->htab)
goto error_htab;
+ vl_compositor_init(&drv->compositor, drv->pipe);
+ vl_compositor_init_state(&drv->cstate, drv->pipe);
+
+ vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &drv->csc);
+ vl_compositor_set_csc_matrix(&drv->cstate, (const vl_csc_matrix *)&drv->csc);
+
ctx->pDriverData = (void *)drv;
ctx->version_major = 0;
ctx->version_minor = 1;
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index 7641ded..58303c6 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -31,6 +31,9 @@
#include "util/u_memory.h"
#include "util/u_handle_table.h"
+#include "util/u_rect.h"
+
+#include "vl/vl_compositor.h"
#include "vl/vl_winsys.h"
#include "va_private.h"
@@ -136,15 +139,58 @@ vlVaQuerySurfaceError(VADriverContextP ctx, VASurfaceID render_target, VAStatus
}
VAStatus
-vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface, void* draw, short srcx, short srcy,
+vlVaPutSurface(VADriverContextP ctx, VASurfaceID surface_id, void* draw, short srcx, short srcy,
unsigned short srcw, unsigned short srch, short destx, short desty,
unsigned short destw, unsigned short desth, VARectangle *cliprects,
unsigned int number_cliprects, unsigned int flags)
{
+ vlVaDriver *drv;
+ vlVaSurface *surf;
+ struct pipe_resource *tex;
+ struct pipe_surface surf_templ, *surf_draw;
+ struct u_rect src_rect, *dirty_area;
+
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
- return VA_STATUS_ERROR_UNIMPLEMENTED;
+ drv = VL_VA_DRIVER(ctx);
+ surf = handle_table_get(drv->htab, surface_id);
+ if (!surf)
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+
+ tex = vl_screen_texture_from_drawable(drv->vscreen, (Drawable)draw);
+ if (!tex)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+
+ dirty_area = vl_screen_get_dirty_area(drv->vscreen);
+
+ memset(&surf_templ, 0, sizeof(surf_templ));
+ surf_templ.format = tex->format;
+ surf_draw = drv->pipe->create_surface(drv->pipe, tex, &surf_templ);
+ if (!surf_draw) {
+ pipe_resource_reference(&tex, NULL);
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+ }
+
+ src_rect.x0 = srcx;
+ src_rect.y0 = srcy;
+ src_rect.x1 = srcw + srcx;
+ src_rect.y1 = srch + srcy;
+
+ vl_compositor_clear_layers(&drv->cstate);
+ vl_compositor_set_buffer_layer(&drv->cstate, &drv->compositor, 0, surf->buffer, &src_rect, NULL, VL_COMPOSITOR_WEAVE);
+ vl_compositor_render(&drv->cstate, &drv->compositor, surf_draw, dirty_area, true);
+
+ drv->pipe->screen->flush_frontbuffer
+ (
+ drv->pipe->screen, tex, 0, 0,
+ vl_screen_get_private(drv->vscreen)
+ );
+
+ pipe_resource_reference(&tex, NULL);
+ pipe_surface_reference(&surf_draw, NULL);
+
+ return VA_STATUS_SUCCESS;
}
VAStatus
diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h
index 58b787d..ebbbedd 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -37,6 +37,9 @@
#include "pipe/p_video_enums.h"
#include "pipe/p_video_state.h"
+#include "vl/vl_compositor.h"
+#include "vl/vl_csc.h"
+
#define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)
#define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)
@@ -119,6 +122,9 @@ typedef struct {
struct vl_screen *vscreen;
struct pipe_context *pipe;
struct handle_table *htab;
+ struct vl_compositor compositor;
+ struct vl_compositor_state cstate;
+ vl_csc_matrix csc;
} vlVaDriver;
typedef struct {
--
1.7.9.5
More information about the mesa-dev
mailing list