st/xa: Update xa_yuv_planar_blit semantics

Change and document the interpretation of the color conversion matrix
in order to make the function more versatile and to simplify the
generated shader.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
This commit is contained in:
Thomas Hellstrom 2011-12-07 20:11:23 +01:00
parent d4976158c7
commit 340c0f6f9e
5 changed files with 16 additions and 12 deletions

View file

@ -40,6 +40,14 @@ extern struct xa_context *xa_context_create(struct xa_tracker *xa);
extern void xa_context_destroy(struct xa_context *r);
/**
* xa_yuv_planar_blit - 2D blit with color conversion and scaling.
*
* Performs a scaled blit with color conversion according to
* (R,G,B,A)^T = (CM)^T (Y,U,V,1)^T, where @conversion_matrix or CM in the
* formula is a four by four coefficient matrix. The input variable
* @yuv is an array of three xa_yuv_component surfaces.
*/
extern int xa_yuv_planar_blit(struct xa_context *r,
int src_x,
int src_y,

View file

@ -320,7 +320,7 @@ create_yuv_shader(struct pipe_context *pipe, struct ureg_program *ureg)
{
struct ureg_src y_sampler, u_sampler, v_sampler;
struct ureg_src pos;
struct ureg_src matrow0, matrow1, matrow2;
struct ureg_src matrow0, matrow1, matrow2, matrow3;
struct ureg_dst y, u, v, rgb;
struct ureg_dst out = ureg_DECL_output(ureg,
TGSI_SEMANTIC_COLOR,
@ -342,24 +342,20 @@ create_yuv_shader(struct pipe_context *pipe, struct ureg_program *ureg)
matrow0 = ureg_DECL_constant(ureg, 0);
matrow1 = ureg_DECL_constant(ureg, 1);
matrow2 = ureg_DECL_constant(ureg, 2);
matrow3 = ureg_DECL_constant(ureg, 3);
ureg_TEX(ureg, y, TGSI_TEXTURE_2D, pos, y_sampler);
ureg_TEX(ureg, u, TGSI_TEXTURE_2D, pos, u_sampler);
ureg_TEX(ureg, v, TGSI_TEXTURE_2D, pos, v_sampler);
ureg_SUB(ureg, u, ureg_src(u), ureg_scalar(matrow0, TGSI_SWIZZLE_W));
ureg_SUB(ureg, v, ureg_src(v), ureg_scalar(matrow0, TGSI_SWIZZLE_W));
ureg_MUL(ureg, rgb, ureg_scalar(ureg_src(y), TGSI_SWIZZLE_X), matrow0);
ureg_MOV(ureg, rgb, matrow3);
ureg_MAD(ureg, rgb,
ureg_scalar(ureg_src(y), TGSI_SWIZZLE_X), matrow0, ureg_src(rgb));
ureg_MAD(ureg, rgb,
ureg_scalar(ureg_src(u), TGSI_SWIZZLE_X), matrow1, ureg_src(rgb));
ureg_MAD(ureg, rgb,
ureg_scalar(ureg_src(v), TGSI_SWIZZLE_X), matrow2, ureg_src(rgb));
/* rgb.a = 1; */
ureg_MOV(ureg, ureg_writemask(rgb, TGSI_WRITEMASK_W),
ureg_scalar(matrow0, TGSI_SWIZZLE_X));
ureg_MOV(ureg, out, ureg_src(rgb));
ureg_release_temporary(ureg, rgb);

View file

@ -37,7 +37,7 @@
#include <stdint.h>
#define XA_TRACKER_VERSION_MAJOR 0
#define XA_TRACKER_VERSION_MINOR 5
#define XA_TRACKER_VERSION_MINOR 6
#define XA_TRACKER_VERSION_PATCH 0
#define XA_FLAG_SHARED (1 << 0)

View file

@ -99,7 +99,7 @@ xa_yuv_bind_samplers(struct xa_context *r, struct xa_surface *yuv[])
static void
xa_yuv_fs_constants(struct xa_context *r, const float conversion_matrix[])
{
const int param_bytes = 12 * sizeof(float);
const int param_bytes = 16 * sizeof(float);
renderer_set_constants(r, PIPE_SHADER_FRAGMENT,
conversion_matrix, param_bytes);

View file

@ -4,7 +4,7 @@ include $(TOP)/configs/current
##### MACROS #####
XA_MAJOR = 0
XA_MINOR = 5
XA_MINOR = 6
XA_TINY = 0
XA_CFLAGS = -Wall -pedantic