[Mesa-dev] [PATCH 4/4] gallivm: Rudimentary native integer support.

jfonseca at vmware.com jfonseca at vmware.com
Thu Dec 6 09:35:39 PST 2012


From: José Fonseca <jfonseca at vmware.com>

Just enough for draw module to work ok.

This improves "piglit attribs GL3", though something fishy is still
happening with certain unsigned integer values.
---
 src/gallium/auxiliary/gallivm/lp_bld_format_aos.c  |    4 ++--
 .../auxiliary/gallivm/lp_bld_format_aos_array.c    |   21 +++++++++++++++++---
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
index c7fdb6e..e5c93f0 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c
@@ -234,7 +234,6 @@ lp_build_unpack_arith_rgba_aos(struct gallivm_state *gallivm,
    shifted = LLVMBuildLShr(builder, packed, LLVMConstVector(shifts, 4), "");
    masked = LLVMBuildAnd(builder, shifted, LLVMConstVector(masks, 4), "");
 
-
    if (!needs_uitofp) {
       /* UIToFP can't be expressed in SSE2 */
       casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatTypeInContext(gallivm->context), 4), "");
@@ -438,7 +437,8 @@ lp_build_fetch_rgba_aos(struct gallivm_state *gallivm,
        format_desc->is_bitmask &&
        !format_desc->is_mixed &&
        (format_desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED ||
-        format_desc->channel[1].type == UTIL_FORMAT_TYPE_UNSIGNED)) {
+        format_desc->channel[1].type == UTIL_FORMAT_TYPE_UNSIGNED) &&
+       !format_desc->channel[0].pure_integer) {
 
       LLVMValueRef tmps[LP_MAX_VECTOR_LENGTH/4];
       LLVMValueRef res;
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
index cf29617..1eb9446 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
@@ -113,6 +113,8 @@ lp_build_fetch_rgba_aos_array(struct gallivm_state *gallivm,
    LLVMTypeRef src_vec_type;
    LLVMValueRef ptr, res = NULL;
    struct lp_type src_type;
+   boolean pure_integer = format_desc->channel[0].pure_integer;
+   struct lp_type tmp_type;
 
    lp_type_from_format_desc(&src_type, format_desc);
 
@@ -144,10 +146,23 @@ lp_build_fetch_rgba_aos_array(struct gallivm_state *gallivm,
       src_type.length = dst_type.length;
    }
 
+   tmp_type = dst_type;
+   if (pure_integer) {
+      assert(dst_type.floating);
+      tmp_type.floating = 0;
+   }
+
    /* Convert to correct format */
-   lp_build_conv(gallivm, src_type, dst_type, &res, 1, &res, 1);
+   lp_build_conv(gallivm, src_type, tmp_type, &res, 1, &res, 1);
 
    /* Swizzle it */
-   lp_build_context_init(&bld, gallivm, dst_type);
-   return lp_build_format_swizzle_aos(format_desc, &bld, res);
+   lp_build_context_init(&bld, gallivm, tmp_type);
+   res = lp_build_format_swizzle_aos(format_desc, &bld, res);
+
+   /* Bitcast to floats (for pure integers) */
+   if (pure_integer) {
+      res = LLVMBuildBitCast(builder, res, lp_build_vec_type(gallivm, dst_type), "");
+   }
+
+   return res;
 }
-- 
1.7.9.5



More information about the mesa-dev mailing list