uint n;
slot = draw_find_shader_output(draw, semantic_name, semantic_index);
- if (slot > 0) {
+ if (slot >= 0) {
return slot;
}
* attributes (such as texcoords for AA lines). The driver can call this
* function to find those attributes.
*
- * Zero is returned if the attribute is not found since this is
- * a don't care / undefined situtation. Returning -1 would be a bit more
- * work for the drivers.
+ * -1 is returned if the attribute is not found since this is
+ * an undefined situtation. Note, that zero is valid and can
+ * be used by any of the attributes, because position is not
+ * required to be attribute 0 or even at all present.
*/
int
draw_find_shader_output(const struct draw_context *draw,
}
}
- return 0;
+ return -1;
}
draw_emit_vertex_attr(struct vertex_info *vinfo,
enum attrib_emit emit,
enum interp_mode interp, /* only used by softpipe??? */
- uint src_index)
+ int src_index)
{
const uint n = vinfo->num_attribs;
assert(n < Elements(vinfo->attrib));
{
const struct lp_fragment_shader *lpfs = llvmpipe->fs;
struct vertex_info *vinfo = &llvmpipe->vertex_info;
- unsigned vs_index;
+ int vs_index;
uint i;
llvmpipe->color_slot[0] = -1;
vs_index = draw_find_shader_output(llvmpipe->draw,
TGSI_SEMANTIC_BCOLOR, i);
- if (vs_index > 0) {
+ if (vs_index >= 0) {
llvmpipe->bcolor_slot[i] = (int)vinfo->num_attribs;
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
}
vs_index = draw_find_shader_output(llvmpipe->draw,
TGSI_SEMANTIC_PSIZE, 0);
- if (vs_index > 0) {
+ if (vs_index >= 0) {
llvmpipe->psize_slot = vinfo->num_attribs;
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
}
vs_index = draw_find_shader_output(llvmpipe->draw,
TGSI_SEMANTIC_VIEWPORT_INDEX,
0);
- if (vs_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 {
softpipe->psize_slot = draw_find_shader_output(softpipe->draw,
TGSI_SEMANTIC_PSIZE, 0);
- if (softpipe->psize_slot > 0) {
+ if (softpipe->psize_slot >= 0) {
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT,
softpipe->psize_slot);
}