Mesa (master): gallivm: Added lp_build_const_mask_aos_swizzled

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed May 2 09:25:58 UTC 2012


Module: Mesa
Branch: master
Commit: c23fd547c060c4137eab0f878a1028c5903384eb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c23fd547c060c4137eab0f878a1028c5903384eb

Author: James Benton <jbenton at vmware.com>
Date:   Wed Apr 25 11:19:07 2012 +0100

gallivm: Added lp_build_const_mask_aos_swizzled

Allows the creation of const aos masks which have the mask swizzled
to match the correct format.

Updated existing mask creation code to use the swizzled version where
necessary (tgsi register masks and llvmpipe aos blending).

Signed-off-by: José Fonseca <jfonseca at vmware.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_const.c    |   19 +++++++++++++++++++
 src/gallium/auxiliary/gallivm/lp_bld_const.h    |    7 +++++++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |    6 ++++--
 src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c |   10 +---------
 4 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c
index 6d8b7c2..77ec1a7 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c
@@ -409,3 +409,22 @@ lp_build_const_mask_aos(struct gallivm_state *gallivm,
 
    return LLVMConstVector(masks, type.length);
 }
+
+
+/**
+ * Performs lp_build_const_mask_aos, but first swizzles the mask
+ */
+LLVMValueRef
+lp_build_const_mask_aos_swizzled(struct gallivm_state *gallivm,
+                        struct lp_type type,
+                        unsigned mask,
+                        const unsigned char *swizzle)
+{
+   mask =
+           ((mask & (1 << swizzle[0])) >> swizzle[0])
+        | (((mask & (1 << swizzle[1])) >> swizzle[1]) << 1)
+        | (((mask & (1 << swizzle[2])) >> swizzle[2]) << 2)
+        | (((mask & (1 << swizzle[3])) >> swizzle[3]) << 3);
+
+   return lp_build_const_mask_aos(gallivm, type, mask);
+}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.h b/src/gallium/auxiliary/gallivm/lp_bld_const.h
index 69718eb..fd39851 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_const.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_const.h
@@ -111,6 +111,13 @@ lp_build_const_mask_aos(struct gallivm_state *gallivm,
                         unsigned mask);
 
 
+LLVMValueRef
+lp_build_const_mask_aos_swizzled(struct gallivm_state *gallivm,
+                        struct lp_type type,
+                        unsigned mask,
+                        const unsigned char *swizzle);
+
+
 static INLINE LLVMValueRef
 lp_build_const_int32(struct gallivm_state *gallivm, int i)
 {
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index 19652d1..24bc13a 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -325,8 +325,10 @@ lp_emit_store_aos(
    if (reg->Register.WriteMask != TGSI_WRITEMASK_XYZW) {
       LLVMValueRef writemask;
 
-      writemask = lp_build_const_mask_aos(bld->bld_base.base.gallivm, bld->bld_base.base.type,
-                                          reg->Register.WriteMask);
+      writemask = lp_build_const_mask_aos_swizzled(bld->bld_base.base.gallivm,
+                                                   bld->bld_base.base.type,
+                                                   reg->Register.WriteMask,
+                                                   bld->swizzles);
 
       if (mask) {
          mask = LLVMBuildAnd(builder, mask, writemask, "");
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index e67286b..59d5f54 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -380,16 +380,8 @@ lp_build_blend_aos(struct gallivm_state *gallivm,
 
    if (!fullcolormask) {
       LLVMValueRef color_mask;
-      unsigned color_mask_swizzle;
 
-      /* Swizzle the color mask to ensure it matches target format */
-      color_mask_swizzle =
-               ((blend->rt[rt].colormask & (1 << swizzle[0])) >> swizzle[0])
-            | (((blend->rt[rt].colormask & (1 << swizzle[1])) >> swizzle[1]) << 1)
-            | (((blend->rt[rt].colormask & (1 << swizzle[2])) >> swizzle[2]) << 2)
-            | (((blend->rt[rt].colormask & (1 << swizzle[3])) >> swizzle[3]) << 3);
-
-      color_mask = lp_build_const_mask_aos(gallivm, bld.base.type, color_mask_swizzle);
+      color_mask = lp_build_const_mask_aos_swizzled(gallivm, bld.base.type, blend->rt[rt].colormask, swizzle);
       lp_build_name(color_mask, "color_mask");
 
       /* Combine with input mask if necessary */




More information about the mesa-commit mailing list