Home | History | Annotate | Download | only in draw

Lines Matching defs:vbuf

96 static void vbuf_flush_vertices( struct vbuf_stage *vbuf );
97 static void vbuf_alloc_vertices( struct vbuf_stage *vbuf );
109 check_space( struct vbuf_stage *vbuf, unsigned nr )
111 if (vbuf->nr_vertices + nr > vbuf->max_vertices ||
112 vbuf->nr_indices + nr > vbuf->max_indices)
114 vbuf_flush_vertices( vbuf );
115 vbuf_alloc_vertices( vbuf );
130 emit_vertex( struct vbuf_stage *vbuf,
133 if (vertex->vertex_id == UNDEFINED_VERTEX_ID && vbuf->vertex_ptr) {
140 vbuf->translate->set_buffer(vbuf->translate, 0, vertex->data[0], 0, ~0);
141 vbuf->translate->run(vbuf->translate, 0, 1, 0, vbuf->vertex_ptr);
143 if (0) draw_dump_emitted_vertex(vbuf->vinfo, (uint8_t *)vbuf->vertex_ptr);
145 vbuf->vertex_ptr += vbuf->vertex_size/4;
146 vertex->vertex_id = vbuf->nr_vertices++;
157 struct vbuf_stage *vbuf = vbuf_stage( stage );
160 check_space( vbuf, 3 );
163 vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[i] );
172 struct vbuf_stage *vbuf = vbuf_stage( stage );
175 check_space( vbuf, 2 );
178 vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[i] );
187 struct vbuf_stage *vbuf = vbuf_stage( stage );
189 check_space( vbuf, 1 );
191 vbuf->indices[vbuf->nr_indices++] = emit_vertex( vbuf, prim->v[0] );
203 vbuf_start_prim( struct vbuf_stage *vbuf, uint prim )
209 vbuf->render->set_primitive(vbuf->render, prim);
217 vbuf->vinfo = vbuf->render->get_vertex_info(vbuf->render);
218 vbuf->vertex_size = vbuf->vinfo->size * sizeof(float);
224 for (i = 0; i < vbuf->vinfo->num_attribs; i++) {
228 unsigned src_offset = (vbuf->vinfo->attrib[i].src_index * 4 * sizeof(float) );
230 output_format = draw_translate_vinfo_format(vbuf->vinfo->attrib[i].emit);
231 emit_sz = draw_translate_vinfo_size(vbuf->vinfo->attrib[i].emit);
236 if (vbuf->vinfo->attrib[i].emit == EMIT_1F_PSIZE) {
252 hw_key.nr_elements = vbuf->vinfo->num_attribs;
253 hw_key.output_stride = vbuf->vinfo->size * 4;
257 if (!vbuf->translate ||
258 translate_key_compare(&vbuf->translate->key, &hw_key) != 0)
261 vbuf->translate = translate_cache_find(vbuf->cache, &hw_key);
263 vbuf->translate->set_buffer(vbuf->translate, 1, &vbuf->point_size, 0, ~0);
266 vbuf->point_size = vbuf->stage.draw->rasterizer->point_size;
270 assert(vbuf->vertices == NULL);
271 vbuf_alloc_vertices(vbuf);
279 struct vbuf_stage *vbuf = vbuf_stage( stage );
281 vbuf_flush_vertices( vbuf );
282 vbuf_start_prim(vbuf, PIPE_PRIM_TRIANGLES);
292 struct vbuf_stage *vbuf = vbuf_stage( stage );
294 vbuf_flush_vertices( vbuf );
295 vbuf_start_prim(vbuf, PIPE_PRIM_LINES);
305 struct vbuf_stage *vbuf = vbuf_stage( stage );
307 vbuf_flush_vertices(vbuf);
308 vbuf_start_prim(vbuf, PIPE_PRIM_POINTS);
319 vbuf_flush_vertices( struct vbuf_stage *vbuf )
321 if(vbuf->vertices) {
323 vbuf->render->unmap_vertices( vbuf->render, 0, vbuf->nr_vertices - 1 );
325 if (vbuf->nr_indices)
327 vbuf->render->draw_elements(vbuf->render,
328 vbuf->indices,
329 vbuf->nr_indices );
331 vbuf->nr_indices = 0;
335 if(vbuf->nr_vertices)
336 draw_reset_vertex_ids( vbuf->stage.draw );
339 vbuf->render->release_vertices( vbuf->render );
341 vbuf->max_vertices = vbuf->nr_vertices = 0;
342 vbuf->vertex_ptr = vbuf->vertices = NULL;
351 vbuf->stage.point = vbuf_first_point;
352 vbuf->stage.line = vbuf_first_line;
353 vbuf->stage.tri = vbuf_first_tri;
358 vbuf_alloc_vertices( struct vbuf_stage *vbuf )
360 if (vbuf->vertex_ptr) {
361 assert(!vbuf->nr_indices);
362 assert(!vbuf->vertices);
366 vbuf->max_vertices = vbuf->render->max_vertex_buffer_bytes / vbuf->vertex_size;
368 if(vbuf->max_vertices >= UNDEFINED_VERTEX_ID)
369 vbuf->max_vertices = UNDEFINED_VERTEX_ID - 1;
376 vbuf->render->allocate_vertices(vbuf->render,
377 (ushort) vbuf->vertex_size,
378 (ushort) vbuf->max_vertices);
380 vbuf->vertices = (uint *) vbuf->render->map_vertices( vbuf->render );
382 vbuf->vertex_ptr = vbuf->vertices;
390 struct vbuf_stage *vbuf = vbuf_stage( stage );
392 vbuf_flush_vertices( vbuf );
407 struct vbuf_stage *vbuf = vbuf_stage( stage );
409 if(vbuf->indices)
410 align_free( vbuf->indices );
412 if (vbuf->render)
413 vbuf->render->destroy( vbuf->render );
415 if (vbuf->cache)
416 translate_cache_destroy(vbuf->cache);
423 * Create a new primitive vbuf/render stage.
428 struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage);
429 if (vbuf == NULL)
432 vbuf->stage.draw = draw;
433 vbuf->stage.name = "vbuf";
434 vbuf->stage.point = vbuf_first_point;
435 vbuf->stage.line = vbuf_first_line;
436 vbuf->stage.tri = vbuf_first_tri;
437 vbuf->stage.flush = vbuf_flush;
438 vbuf->stage.reset_stipple_counter = vbuf_reset_stipple_counter;
439 vbuf->stage.destroy = vbuf_destroy;
441 vbuf->render = render;
442 vbuf->max_indices = MIN2(render->max_indices, UNDEFINED_VERTEX_ID-1);
444 vbuf->indices = (ushort *) align_malloc( vbuf->max_indices *
445 sizeof(vbuf->indices[0]),
447 if (!vbuf->indices)
450 vbuf->cache = translate_cache_create();
451 if (!vbuf->cache)
455 vbuf->vertices = NULL;
456 vbuf->vertex_ptr = vbuf->vertices;
458 return &vbuf->stage;
461 if (vbuf)
462 vbuf_destroy(&vbuf->stage);