draw_prepare_shader_outputs(llvmpipe->draw);
- llvmpipe->color_slot[0] = -1;
- llvmpipe->color_slot[1] = -1;
- llvmpipe->bcolor_slot[0] = -1;
- llvmpipe->bcolor_slot[1] = -1;
+ llvmpipe->color_slot[0] = 0;
+ llvmpipe->color_slot[1] = 0;
+ llvmpipe->bcolor_slot[0] = 0;
+ llvmpipe->bcolor_slot[1] = 0;
+ llvmpipe->viewport_index_slot = 0;
+ llvmpipe->layer_slot = 0;
+ llvmpipe->face_slot = 0;
+ llvmpipe->psize_slot = 0;
/*
* Match FS inputs against VS outputs, emitting the necessary
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] = (int)vinfo->num_attribs;
+ llvmpipe->color_slot[idx] = vinfo->num_attribs;
}
if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_FACE) {
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
} else if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_PRIMID) {
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
+ /*
+ * For vp index and layer, if the fs requires them but the vs doesn't
+ * provide them, store the slot - we'll later replace the data directly
+ * with zero (as required by ARB_fragment_layer_viewport). This is
+ * because draw itself just redirects them to whatever was at output 0.
+ * We'll also store the real vpindex/layer slot for setup use.
+ */
+ } else if (lpfs->info.base.input_semantic_name[i] ==
+ TGSI_SEMANTIC_VIEWPORT_INDEX) {
+ if (vs_index >= 0) {
+ llvmpipe->viewport_index_slot = vinfo->num_attribs;
+ }
+ else {
+ llvmpipe->fake_vpindex_slot = vinfo->num_attribs;
+ }
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
+ } else if (lpfs->info.base.input_semantic_name[i] == TGSI_SEMANTIC_LAYER) {
+ if (vs_index >= 0) {
+ llvmpipe->layer_slot = vinfo->num_attribs;
+ }
+ else {
+ llvmpipe->fake_layer_slot = vinfo->num_attribs;
+ }
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
} else {
/*
* Emit the requested fs attribute for all but position.
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
}
}
+
/* Figure out if we need bcolor as well.
*/
for (i = 0; i < 2; i++) {
TGSI_SEMANTIC_BCOLOR, i);
if (vs_index >= 0) {
- llvmpipe->bcolor_slot[i] = (int)vinfo->num_attribs;
+ 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,
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
}
- /* Figure out if we need viewport index */
- vs_index = draw_find_shader_output(llvmpipe->draw,
- TGSI_SEMANTIC_VIEWPORT_INDEX,
- 0);
- if (vs_index >= 0) {
- llvmpipe->viewport_index_slot = vinfo->num_attribs;
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
- } else {
- llvmpipe->viewport_index_slot = 0;
+ /* Figure out if we need viewport index (if it wasn't already in fs input) */
+ if (llvmpipe->viewport_index_slot == 0) {
+ vs_index = draw_find_shader_output(llvmpipe->draw,
+ TGSI_SEMANTIC_VIEWPORT_INDEX,
+ 0);
+ if (vs_index >= 0) {
+ llvmpipe->viewport_index_slot = vinfo->num_attribs;
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
+ }
}
- /* Figure out if we need layer */
- vs_index = draw_find_shader_output(llvmpipe->draw,
- TGSI_SEMANTIC_LAYER,
- 0);
- if (vs_index >= 0) {
- llvmpipe->layer_slot = vinfo->num_attribs;
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
- } else {
- llvmpipe->layer_slot = 0;
+ /* Figure out if we need layer (if it wasn't already in fs input) */
+ if (llvmpipe->layer_slot == 0) {
+ vs_index = draw_find_shader_output(llvmpipe->draw,
+ TGSI_SEMANTIC_LAYER,
+ 0);
+ if (vs_index >= 0) {
+ llvmpipe->layer_slot = vinfo->num_attribs;
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
+ }
}
draw_compute_vertex_size(vinfo);
/* Potentially modify it according to twoside, etc:
*/
if (key->twoside) {
- if (vert_attr == key->color_slot && key->bcolor_slot >= 0)
+ if (vert_attr == key->color_slot && key->bcolor_slot > 0)
lp_twoside(gallivm, args, key, key->bcolor_slot, attribv);
- else if (vert_attr == key->spec_slot && key->bspec_slot >= 0)
+ else if (vert_attr == key->spec_slot && key->bspec_slot > 0)
lp_twoside(gallivm, args, key, key->bspec_slot, attribv);
}
}
*/
break;
+ case LP_INTERP_ZERO:
+ /*
+ * The information we get from the output is bogus, replace it
+ * with zero.
+ */
+ emit_constant_coef4(gallivm, args, slot+1, args->bld.zero);
+ break;
case LP_INTERP_FACING:
emit_facing_coef(gallivm, args, slot+1);
break;
key->size = Offset(struct lp_setup_variant_key,
inputs[key->num_inputs]);
- key->color_slot = lp->color_slot [0];
+ 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];
- assert(key->color_slot == lp->color_slot [0]);
- assert(key->bcolor_slot == lp->bcolor_slot[0]);
- assert(key->spec_slot == lp->color_slot [1]);
- assert(key->bspec_slot == lp->bcolor_slot[1]);
+ key->spec_slot = lp->color_slot[1];
+ key->bspec_slot = lp->bcolor_slot[1];
/*
* If depth is floating point, depth bias is calculated with respect
key->pad = 0;
memcpy(key->inputs, fs->inputs, key->num_inputs * sizeof key->inputs[0]);
for (i = 0; i < key->num_inputs; i++) {
- if (key->inputs[i].interp == LP_INTERP_COLOR) {
+ if (key->inputs[i].interp == LP_INTERP_CONSTANT) {
+ if (key->inputs[i].src_index == lp->fake_vpindex_slot ||
+ key->inputs[i].src_index == lp->fake_layer_slot) {
+ key->inputs[i].interp = LP_INTERP_ZERO;
+ }
+ }
+ else if (key->inputs[i].interp == LP_INTERP_COLOR) {
if (lp->rasterizer->flatshade)
key->inputs[i].interp = LP_INTERP_CONSTANT;
else