From 340c0f6f9ece070e3f3245134eabe80d7551a870 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 7 Dec 2011 20:11:23 +0100 Subject: [PATCH] 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 Reviewed-by: Jakob Bornecrantz --- src/gallium/state_trackers/xa/xa_context.h | 8 ++++++++ src/gallium/state_trackers/xa/xa_tgsi.c | 14 +++++--------- src/gallium/state_trackers/xa/xa_tracker.h | 2 +- src/gallium/state_trackers/xa/xa_yuv.c | 2 +- src/gallium/targets/xa-vmwgfx/Makefile | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/gallium/state_trackers/xa/xa_context.h b/src/gallium/state_trackers/xa/xa_context.h index d9bb86c828a..b547abf96a3 100644 --- a/src/gallium/state_trackers/xa/xa_context.h +++ b/src/gallium/state_trackers/xa/xa_context.h @@ -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, diff --git a/src/gallium/state_trackers/xa/xa_tgsi.c b/src/gallium/state_trackers/xa/xa_tgsi.c index ed1690ed369..c7454c9d6ac 100644 --- a/src/gallium/state_trackers/xa/xa_tgsi.c +++ b/src/gallium/state_trackers/xa/xa_tgsi.c @@ -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); diff --git a/src/gallium/state_trackers/xa/xa_tracker.h b/src/gallium/state_trackers/xa/xa_tracker.h index abc2457a056..d3adedb88df 100644 --- a/src/gallium/state_trackers/xa/xa_tracker.h +++ b/src/gallium/state_trackers/xa/xa_tracker.h @@ -37,7 +37,7 @@ #include #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) diff --git a/src/gallium/state_trackers/xa/xa_yuv.c b/src/gallium/state_trackers/xa/xa_yuv.c index da00b116ade..36213593d15 100644 --- a/src/gallium/state_trackers/xa/xa_yuv.c +++ b/src/gallium/state_trackers/xa/xa_yuv.c @@ -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); diff --git a/src/gallium/targets/xa-vmwgfx/Makefile b/src/gallium/targets/xa-vmwgfx/Makefile index 6ca446a15dc..26d95cbb8f5 100644 --- a/src/gallium/targets/xa-vmwgfx/Makefile +++ b/src/gallium/targets/xa-vmwgfx/Makefile @@ -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 -- 2.30.2