gallivm: Move lp_build_rgba8_to_f32_soa() to lp_bld_format_soa.c

It will be more useful here.
This commit is contained in:
José Fonseca 2010-07-02 16:59:39 +01:00
parent bb1546f55b
commit eb20c57f03
3 changed files with 40 additions and 32 deletions

View File

@ -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,

View File

@ -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.
*

View File

@ -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);