unsigned max_indices;
unsigned nr_indices;
- /* Cache point size somewhere it's address won't change:
+ /* Cache point size somewhere its address won't change:
*/
float point_size;
+ float zero4[4];
struct translate_cache *cache;
};
struct translate_key hw_key;
unsigned dst_offset;
unsigned i;
+ const struct vertex_info *vinfo;
vbuf->render->set_primitive(vbuf->render, prim);
* state change.
*/
vbuf->vinfo = vbuf->render->get_vertex_info(vbuf->render);
- vbuf->vertex_size = vbuf->vinfo->size * sizeof(float);
+ vinfo = vbuf->vinfo;
+ vbuf->vertex_size = vinfo->size * sizeof(float);
/* Translate from pipeline vertices to hw vertices.
*/
dst_offset = 0;
- for (i = 0; i < vbuf->vinfo->num_attribs; i++) {
+ for (i = 0; i < vinfo->num_attribs; i++) {
unsigned emit_sz = 0;
unsigned src_buffer = 0;
enum pipe_format output_format;
- unsigned src_offset = (vbuf->vinfo->attrib[i].src_index * 4 * sizeof(float) );
+ unsigned src_offset = (vinfo->attrib[i].src_index * 4 * sizeof(float) );
- output_format = draw_translate_vinfo_format(vbuf->vinfo->attrib[i].emit);
- emit_sz = draw_translate_vinfo_size(vbuf->vinfo->attrib[i].emit);
+ output_format = draw_translate_vinfo_format(vinfo->attrib[i].emit);
+ emit_sz = draw_translate_vinfo_size(vinfo->attrib[i].emit);
/* doesn't handle EMIT_OMIT */
assert(emit_sz != 0);
- if (vbuf->vinfo->attrib[i].emit == EMIT_1F_PSIZE) {
- src_buffer = 1;
- src_offset = 0;
+ if (vinfo->attrib[i].emit == EMIT_1F_PSIZE) {
+ src_buffer = 1;
+ src_offset = 0;
+ }
+ else if (vinfo->attrib[i].src_index == DRAW_ATTR_NONEXIST) {
+ /* elements which don't exist will get assigned zeros */
+ src_buffer = 2;
+ src_offset = 0;
}
hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
dst_offset += emit_sz;
}
- hw_key.nr_elements = vbuf->vinfo->num_attribs;
+ hw_key.nr_elements = vinfo->num_attribs;
hw_key.output_stride = vbuf->vertex_size;
/* Don't bother with caching at this stage:
vbuf->translate = translate_cache_find(vbuf->cache, &hw_key);
vbuf->translate->set_buffer(vbuf->translate, 1, &vbuf->point_size, 0, ~0);
+ vbuf->translate->set_buffer(vbuf->translate, 2, &vbuf->zero4[0], 0, ~0);
}
vbuf->point_size = vbuf->stage.draw->rasterizer->point_size;
struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage);
if (!vbuf)
goto fail;
-
+
vbuf->stage.draw = draw;
vbuf->stage.name = "vbuf";
vbuf->stage.point = vbuf_first_point;
vbuf->stage.flush = vbuf_flush;
vbuf->stage.reset_stipple_counter = vbuf_reset_stipple_counter;
vbuf->stage.destroy = vbuf_destroy;
-
+
vbuf->render = render;
vbuf->max_indices = MIN2(render->max_indices, UNDEFINED_VERTEX_ID-1);
- vbuf->indices = (ushort *) align_malloc( vbuf->max_indices *
- sizeof(vbuf->indices[0]),
- 16 );
+ vbuf->indices = (ushort *) align_malloc(vbuf->max_indices *
+ sizeof(vbuf->indices[0]),
+ 16);
if (!vbuf->indices)
goto fail;
vbuf->cache = translate_cache_create();
- if (!vbuf->cache)
+ if (!vbuf->cache)
goto fail;
-
-
+
vbuf->vertices = NULL;
vbuf->vertex_ptr = vbuf->vertices;
-
+
+ vbuf->zero4[0] = vbuf->zero4[1] = vbuf->zero4[2] = vbuf->zero4[3] = 0.0f;
+
return &vbuf->stage;
- fail:
+fail:
if (vbuf)
vbuf_destroy(&vbuf->stage);
-
+
return NULL;
}
unsigned prim;
const struct vertex_info *vinfo;
+
+ float zero4[4];
+
};
src_buffer = 1;
src_offset = 0;
}
+ else if (vinfo->attrib[i].src_index == DRAW_ATTR_NONEXIST) {
+ /* elements which don't exist will get assigned zeros */
+ src_buffer = 2;
+ src_offset = 0;
+ }
hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
hw_key.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
translate_key_compare(&emit->translate->key, &hw_key) != 0) {
translate_key_sanitize(&hw_key);
emit->translate = translate_cache_find(emit->cache, &hw_key);
+
+ emit->translate->set_buffer(emit->translate, 2, &emit->zero4[0], 0, ~0);
}
if (!vinfo->size)
return NULL;
}
+ emit->zero4[0] = emit->zero4[1] = emit->zero4[2] = emit->zero4[3] = 0.0f;
+
return emit;
}