st/xa: Update xa_yuv_planar_blit semantics
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 7 Dec 2011 19:11:23 +0000 (20:11 +0100)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 8 Dec 2011 08:51:19 +0000 (09:51 +0100)
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>
src/gallium/state_trackers/xa/xa_context.h
src/gallium/state_trackers/xa/xa_tgsi.c
src/gallium/state_trackers/xa/xa_tracker.h
src/gallium/state_trackers/xa/xa_yuv.c
src/gallium/targets/xa-vmwgfx/Makefile

index d9bb86c828ae6e7fac61a62e00f1a51793ed5b6e..b547abf96a33d7f5ecd98232c08dc5e78ba9c75e 100644 (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,
index ed1690ed3692926faa158eb7b8238d705cc06709..c7454c9d6ac5fae3625d15a6918bc11cf24bca0a 100644 (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);
index abc2457a0569259a68416b1afd08ad0b3893ccd0..d3adedb88df716d0e9fb15779dd8868b88043fe0 100644 (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)
index da00b116ade1f7ed67e78c8f6e0c50ea0ad78824..36213593d1580dc7aecd6b7e2e9bdc3dfa91d628 100644 (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);
index 6ca446a15dcce6ddb385ca6584eccd24dd32dc4f..26d95cbb8f590dafbbad28170a4733ac2b633b13 100644 (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