diff options
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_format_soa.c')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_format_soa.c | 62 |
1 files changed, 9 insertions, 53 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c index 2b66162eb4..c7b20f4201 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c @@ -307,70 +307,28 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, } else { /* - * Fallback to calling util_format_description::fetch_rgba_float for each - * pixel. + * Fallback to calling lp_build_fetch_rgba_aos for each pixel. * - * This is definitely not the most efficient way of fetching pixels, as - * we miss the opportunity to do vectorization, but this it is a + * This is not the most efficient way of fetching pixels, as + * we miss some opportunities to do vectorization, but this it is a * convenient for formats or scenarios for which there was no opportunity * or incentive to optimize. */ - LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder))); - char name[256]; - LLVMValueRef function; - LLVMValueRef tmp; unsigned k, chan; assert(type.floating); - util_snprintf(name, sizeof name, "util_format_%s_fetch_rgba_float", format_desc->short_name); - - /* - * Declare and bind format_desc->fetch_rgba_float(). - */ - - function = LLVMGetNamedFunction(module, name); - if (!function) { - LLVMTypeRef ret_type; - LLVMTypeRef arg_types[4]; - LLVMTypeRef function_type; - - ret_type = LLVMVoidType(); - arg_types[0] = LLVMPointerType(LLVMFloatType(), 0); - arg_types[1] = LLVMPointerType(LLVMInt8Type(), 0); - arg_types[3] = arg_types[2] = LLVMIntType(sizeof(unsigned) * 8); - function_type = LLVMFunctionType(ret_type, arg_types, Elements(arg_types), 0); - function = LLVMAddFunction(module, name, function_type); - - LLVMSetFunctionCallConv(function, LLVMCCallConv); - LLVMSetLinkage(function, LLVMExternalLinkage); - - assert(LLVMIsDeclaration(function)); - - LLVMAddGlobalMapping(lp_build_engine, function, format_desc->fetch_rgba_float); - } - for (chan = 0; chan < 4; ++chan) { rgba[chan] = lp_build_undef(type); } - tmp = LLVMBuildArrayAlloca(builder, - LLVMFloatType(), - LLVMConstInt(LLVMInt32Type(), 4, 0), - ""); - - /* - * Invoke format_desc->fetch_rgba_float() for each pixel and insert the result - * in the SoA vectors. - */ - for(k = 0; k < type.length; ++k) { LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), k, 0); LLVMValueRef offset_elem; LLVMValueRef ptr; LLVMValueRef i_elem, j_elem; - LLVMValueRef args[4]; + LLVMValueRef tmp; offset_elem = LLVMBuildExtractElement(builder, offset, index, ""); ptr = LLVMBuildGEP(builder, base_ptr, &offset_elem, 1, ""); @@ -378,17 +336,15 @@ lp_build_fetch_rgba_soa(LLVMBuilderRef builder, i_elem = LLVMBuildExtractElement(builder, i, index, ""); j_elem = LLVMBuildExtractElement(builder, j, index, ""); - args[0] = tmp; - args[1] = ptr; - args[2] = i_elem; - args[3] = j_elem; + tmp = lp_build_fetch_rgba_aos(builder, format_desc, ptr, i_elem, j_elem); - LLVMBuildCall(builder, function, args, 4, ""); + /* + * AoS to SoA + */ for (chan = 0; chan < 4; ++chan) { LLVMValueRef chan_val = LLVMConstInt(LLVMInt32Type(), chan, 0), - tmp_chan = LLVMBuildGEP(builder, tmp, &chan_val, 1, ""); - tmp_chan = LLVMBuildLoad(builder, tmp_chan, ""); + tmp_chan = LLVMBuildExtractElement(builder, tmp, chan_val, ""); rgba[chan] = LLVMBuildInsertElement(builder, rgba[chan], tmp_chan, index, ""); } } |