Mesa (master): gallivm: New function to fetch a pixel into a 4xfloat AoS vector.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Apr 20 12:02:51 UTC 2010


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

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Apr 20 13:58:45 2010 +0200

gallivm: New function to fetch a pixel into a 4xfloat AoS vector.

---

 src/gallium/auxiliary/gallivm/lp_bld_format.h     |   28 +++++++++++------
 src/gallium/auxiliary/gallivm/lp_bld_format_aos.c |   32 +++++++++++++++++++++
 2 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h b/src/gallium/auxiliary/gallivm/lp_bld_format.h
index bb1298e..13d0de8 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h
@@ -42,16 +42,9 @@ struct util_format_description;
 struct lp_type;
 
 
-boolean
-lp_format_is_rgba8(const struct util_format_description *desc);
-
-
-void
-lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
-                            struct lp_type type,
-                            const LLVMValueRef *unswizzled,
-                            LLVMValueRef *swizzled);
-
+/*
+ * AoS
+ */
 
 LLVMValueRef
 lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
@@ -71,6 +64,21 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
                        const struct util_format_description *desc,
                        LLVMValueRef rgba);
 
+LLVMValueRef
+lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
+                        const struct util_format_description *format_desc,
+                        LLVMValueRef ptr);
+
+
+/*
+ * SoA
+ */
+
+void
+lp_build_format_swizzle_soa(const struct util_format_description *format_desc,
+                            struct lp_type type,
+                            const LLVMValueRef *unswizzled,
+                            LLVMValueRef *swizzled);
 
 void
 lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index e55ac6f..4cf285e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -378,3 +378,35 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder,
 
    return packed;
 }
+
+
+/**
+ * Fetch a pixel into a 4 float AoS.
+ */
+LLVMValueRef
+lp_build_fetch_rgba_aos(LLVMBuilderRef builder,
+                        const struct util_format_description *format_desc,
+                        LLVMValueRef ptr)
+{
+   if (format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
+       (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
+        format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) &&
+       format_desc->block.width == 1 &&
+       format_desc->block.height == 1 &&
+       format_desc->block.bits <= 32 &&
+       format_desc->channel[0].type != UTIL_FORMAT_TYPE_FLOAT)
+   {
+      LLVMValueRef packed;
+
+      ptr = LLVMBuildBitCast(builder, ptr,
+                             LLVMPointerType(LLVMIntType(format_desc->block.bits), 0) , "");
+
+      packed = LLVMBuildLoad(builder, ptr, "packed");
+
+      return lp_build_unpack_rgba_aos(builder, format_desc, packed);
+   }
+   else {
+      assert(0);
+      return LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
+   }
+}




More information about the mesa-commit mailing list