struct vertex_info vertex_info;
/** Which vertex shader output slot contains color */
- int color_slot;
+ int color_slot[2];
/** Which vertex shader output slot contains bcolor */
- int bcolor_slot;
+ int bcolor_slot[2];
/** Which vertex shader output slot contains point size */
int psize_slot;
unsigned vs_index;
uint i;
+ llvmpipe->color_slot[0] = ~0;
+ llvmpipe->color_slot[1] = ~0;
+ llvmpipe->bcolor_slot[0] = ~0;
+ llvmpipe->bcolor_slot[1] = ~0;
+
/*
* Match FS inputs against VS outputs, emitting the necessary
* attributes. Could cache these structs and look them up with a
vs_index = draw_find_shader_output(llvmpipe->draw,
lpfs->info.base.input_semantic_name[i],
lpfs->info.base.input_semantic_index[i]);
- if (lpfs->info.base.input_semantic_name[i]==TGSI_SEMANTIC_COLOR){
- llvmpipe->color_slot = vinfo->num_attribs;
+
+ if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_COLOR &&
+ lpfs->info.base.input_semantic_index[i] < 2) {
+ int idx = lpfs->info.base.input_semantic_index[i];
+ llvmpipe->color_slot[idx] = vinfo->num_attribs;
}
+
/*
* Emit the requested fs attribute for all but position.
*/
/* Figure out if we need bcolor as well.
*/
- vs_index = draw_find_shader_output(llvmpipe->draw,
- TGSI_SEMANTIC_BCOLOR, 0);
+ for (i = 0; i < 2; i++) {
+ vs_index = draw_find_shader_output(llvmpipe->draw,
+ TGSI_SEMANTIC_BCOLOR, i);
- if (vs_index > 0) {
- llvmpipe->bcolor_slot = vinfo->num_attribs;
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
+ if (vs_index > 0) {
+ llvmpipe->bcolor_slot[i] = vinfo->num_attribs;
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
+ }
}
+
/* Figure out if we need pointsize as well.
*/
vs_index = draw_find_shader_output(llvmpipe->draw,
static void
lp_twoside(LLVMBuilderRef b,
struct lp_setup_args *args,
- const struct lp_setup_variant_key *key)
+ const struct lp_setup_variant_key *key,
+ int bcolor_slot)
{
LLVMValueRef a0_back, a1_back, a2_back;
- LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), key->bcolor_slot, 0);
+ LLVMValueRef idx2 = LLVMConstInt(LLVMInt32Type(), bcolor_slot, 0);
LLVMValueRef facing = args->facing;
LLVMValueRef front_facing = LLVMBuildICmp(b, LLVMIntEQ, facing, LLVMConstInt(LLVMInt32Type(), 0, 0), ""); /** need i1 for if condition */
lp_do_offset_tri(b, args, key);
}
- if (key->twoside && vert_attr == key->color_slot) {
- lp_twoside(b, args, key);
+ if (key->twoside) {
+ if (vert_attr == key->color_slot && key->bcolor_slot != ~0)
+ lp_twoside(b, args, key, key->bcolor_slot);
+ else if (vert_attr == key->spec_slot && key->bspec_slot != ~0)
+ lp_twoside(b, args, key, key->bspec_slot);
}
}
key->pixel_center_half = lp->rasterizer->gl_rasterization_rules;
key->twoside = lp->rasterizer->light_twoside;
key->size = Offset(struct lp_setup_variant_key,
- inputs[key->num_inputs]);
- key->color_slot = lp->color_slot;
- key->bcolor_slot = lp->bcolor_slot;
+ inputs[key->num_inputs]);
+ key->color_slot = lp->color_slot[0];
+ key->bcolor_slot = lp->bcolor_slot[0];
+ key->spec_slot = lp->color_slot[1];
+ key->bspec_slot = lp->bcolor_slot[1];
key->units = (float) (lp->rasterizer->offset_units * lp->mrd);
key->scale = lp->rasterizer->offset_scale;
key->pad = 0;
struct lp_setup_variant_key {
+ unsigned size:16;
unsigned num_inputs:8;
+ unsigned color_slot:8;
+
+ unsigned bcolor_slot:8;
+ unsigned spec_slot:8;
+ unsigned bspec_slot:8;
unsigned flatshade_first:1;
unsigned pixel_center_half:1;
unsigned twoside:1;
- unsigned color_slot:8;
- unsigned bcolor_slot:8;
- unsigned size:16;
- unsigned pad:21;
+ unsigned pad:5;
+
float units;
float scale;
struct lp_shader_input inputs[PIPE_MAX_SHADER_INPUTS];