diff options
author | José Fonseca <[email protected]> | 2010-06-02 09:56:05 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-06-02 13:24:25 +0100 |
commit | 147dc2354c21f098a2a63a085c21ec10252cab24 (patch) | |
tree | 607f84ae6882bb198f4722cd8a7549928a9f8ba2 /src/gallium/drivers/llvmpipe/lp_bld_interp.c | |
parent | 53beea574ffb19156e86d891f54316f9fabdd62a (diff) |
llvmpipe: Centralize all position interpolation in lp_bld_interp.c.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_interp.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_bld_interp.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_interp.c b/src/gallium/drivers/llvmpipe/lp_bld_interp.c index d1f0185684d..49af8289954 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_interp.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_interp.c @@ -75,6 +75,10 @@ */ +static const unsigned char quad_offset_x[4] = {0, 1, 0, 1}; +static const unsigned char quad_offset_y[4] = {0, 0, 1, 1}; + + static void attrib_name(LLVMValueRef val, unsigned attrib, unsigned chan, const char *suffix) { @@ -281,18 +285,46 @@ attribs_update(struct lp_build_interp_soa_context *bld, int quad_index) /** * Generate the position vectors. * - * Parameter x0, y0 are the integer values with the quad upper left coordinates. + * Parameter x0, y0 are the integer values with upper left coordinates. */ static void pos_init(struct lp_build_interp_soa_context *bld, LLVMValueRef x0, LLVMValueRef y0) { - lp_build_name(x0, "pos.x"); - lp_build_name(y0, "pos.y"); + LLVMBuilderRef builder = bld->base.builder; + LLVMTypeRef int_elem_type = LLVMInt32Type(); + LLVMTypeRef int_vec_type = LLVMVectorType(int_elem_type, QUAD_SIZE); + LLVMTypeRef elem_type = LLVMFloatType(); + LLVMTypeRef vec_type = LLVMVectorType(elem_type, QUAD_SIZE); + LLVMValueRef x_offsets[QUAD_SIZE]; + LLVMValueRef y_offsets[QUAD_SIZE]; + unsigned i; + + /* + * Derive from the quad's upper left scalar coordinates the coordinates for + * all other quad pixels + */ + + x0 = lp_build_broadcast(builder, int_vec_type, x0); + y0 = lp_build_broadcast(builder, int_vec_type, y0); + + for(i = 0; i < QUAD_SIZE; ++i) { + x_offsets[i] = LLVMConstInt(int_elem_type, quad_offset_x[i], 0); + y_offsets[i] = LLVMConstInt(int_elem_type, quad_offset_y[i], 0); + } + + x0 = LLVMBuildAdd(builder, x0, LLVMConstVector(x_offsets, QUAD_SIZE), ""); + y0 = LLVMBuildAdd(builder, y0, LLVMConstVector(y_offsets, QUAD_SIZE), ""); + + bld->x0 = LLVMBuildSIToFP(builder, x0, vec_type, ""); + bld->y0 = LLVMBuildSIToFP(builder, y0, vec_type, ""); + + lp_build_name(bld->x0, "pos.x"); + lp_build_name(bld->y0, "pos.y"); - bld->attribs[0][0] = x0; - bld->attribs[0][1] = y0; + bld->attribs[0][0] = bld->x0; + bld->attribs[0][1] = bld->y0; } |