*/
+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)
{
/**
* 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;
}
unsigned mask[1 + PIPE_MAX_SHADER_INPUTS]; /**< TGSI_WRITE_MASK_x */
enum lp_interp interp[1 + PIPE_MAX_SHADER_INPUTS];
+ LLVMValueRef x0;
+ LLVMValueRef y0;
+
LLVMValueRef a0 [1 + PIPE_MAX_SHADER_INPUTS][NUM_CHANNELS];
LLVMValueRef dadx[1 + PIPE_MAX_SHADER_INPUTS][NUM_CHANNELS];
LLVMValueRef dady[1 + PIPE_MAX_SHADER_INPUTS][NUM_CHANNELS];
LLVMValueRef a0_ptr,
LLVMValueRef dadx_ptr,
LLVMValueRef dady_ptr,
- LLVMValueRef x0,
- LLVMValueRef y0);
+ LLVMValueRef x,
+ LLVMValueRef y);
void
lp_build_interp_soa_update(struct lp_build_interp_soa_context *bld,
#include <llvm-c/Analysis.h>
-static const unsigned char quad_offset_x[4] = {0, 1, 0, 1};
-static const unsigned char quad_offset_y[4] = {0, 0, 1, 1};
-
-
-/*
- * Derive from the quad's upper left scalar coordinates the coordinates for
- * all other quad pixels
- */
-static void
-generate_pos0(LLVMBuilderRef builder,
- LLVMValueRef x,
- LLVMValueRef y,
- LLVMValueRef *x0,
- LLVMValueRef *y0)
-{
- 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;
-
- x = lp_build_broadcast(builder, int_vec_type, x);
- y = lp_build_broadcast(builder, int_vec_type, y);
-
- 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);
- }
-
- x = LLVMBuildAdd(builder, x, LLVMConstVector(x_offsets, QUAD_SIZE), "");
- y = LLVMBuildAdd(builder, y, LLVMConstVector(y_offsets, QUAD_SIZE), "");
-
- *x0 = LLVMBuildSIToFP(builder, x, vec_type, "");
- *y0 = LLVMBuildSIToFP(builder, y, vec_type, "");
-}
-
-
/**
* Generate the depth /stencil test code.
*/
LLVMValueRef c0, c1, c2, step0_ptr, step1_ptr, step2_ptr, counter = NULL;
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
- LLVMValueRef x0;
- LLVMValueRef y0;
struct lp_build_sampler_soa *sampler;
struct lp_build_interp_soa_context interp;
LLVMValueRef fs_mask[LP_MAX_VECTOR_LENGTH];
builder = LLVMCreateBuilder();
LLVMPositionBuilderAtEnd(builder, block);
- generate_pos0(builder, x, y, &x0, &y0);
-
/*
* The shader input interpolation info is not explicitely baked in the
* shader key, but everything it derives from (TGSI, and flatshade) is
lp->inputs,
builder, fs_type,
a0_ptr, dadx_ptr, dady_ptr,
- x0, y0);
+ x, y);
/* code generated texture sampling */
sampler = lp_llvm_sampler_soa_create(key->sampler, context_ptr);