From eb20c57f03f7f6a43dedb9c317f3648087e6d1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 2 Jul 2010 16:59:39 +0100 Subject: [PATCH] gallivm: Move lp_build_rgba8_to_f32_soa() to lp_bld_format_soa.c It will be more useful here. --- src/gallium/auxiliary/gallivm/lp_bld_format.h | 5 +++ .../auxiliary/gallivm/lp_bld_format_soa.c | 35 +++++++++++++++++++ .../auxiliary/gallivm/lp_bld_sample_soa.c | 32 ----------------- 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h b/src/gallium/auxiliary/gallivm/lp_bld_format.h index a853d7ca411..9056eae9403 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h @@ -83,6 +83,11 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder, LLVMValueRef packed, LLVMValueRef rgba_out[4]); +void +lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder, + struct lp_type dst_type, + LLVMValueRef packed, + LLVMValueRef *rgba); void lp_build_fetch_rgba_soa(LLVMBuilderRef builder, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c index 687bce43487..e4004fbb7b5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c @@ -251,6 +251,41 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder, } +void +lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder, + struct lp_type dst_type, + LLVMValueRef packed, + LLVMValueRef *rgba) +{ + LLVMValueRef mask = lp_build_const_int_vec(dst_type, 0xff); + unsigned chan; + + packed = LLVMBuildBitCast(builder, packed, + lp_build_int_vec_type(dst_type), ""); + + /* Decode the input vector components */ + for (chan = 0; chan < 4; ++chan) { + unsigned start = chan*8; + unsigned stop = start + 8; + LLVMValueRef input; + + input = packed; + + if (start) + input = LLVMBuildLShr(builder, input, + lp_build_const_int_vec(dst_type, start), ""); + + if (stop < 32) + input = LLVMBuildAnd(builder, input, mask, ""); + + input = lp_build_unsigned_norm_to_float(builder, 8, dst_type, input); + + rgba[chan] = input; + } +} + + + /** * Fetch a texels from a texture, returning them in SoA layout. * diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index a33231ddc4e..8cca3f639a5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1712,36 +1712,6 @@ lp_build_sample_general(struct lp_build_sample_context *bld, -static void -lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder, - struct lp_type dst_type, - LLVMValueRef packed, - LLVMValueRef *rgba) -{ - LLVMValueRef mask = lp_build_const_int_vec(dst_type, 0xff); - unsigned chan; - - /* Decode the input vector components */ - for (chan = 0; chan < 4; ++chan) { - unsigned start = chan*8; - unsigned stop = start + 8; - LLVMValueRef input; - - input = packed; - - if(start) - input = LLVMBuildLShr(builder, input, lp_build_const_int_vec(dst_type, start), ""); - - if(stop < 32) - input = LLVMBuildAnd(builder, input, mask, ""); - - input = lp_build_unsigned_norm_to_float(builder, 8, dst_type, input); - - rgba[chan] = input; - } -} - - static void lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, LLVMValueRef s, @@ -1936,8 +1906,6 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, * Convert to SoA and swizzle. */ - packed = LLVMBuildBitCast(builder, packed, i32_vec_type, ""); - lp_build_rgba8_to_f32_soa(bld->builder, bld->texel_type, packed, unswizzled);