revert 213 commits (to 56092) from the last month. 10 still need work to resolve...
[AROS.git] / workbench / libs / mesa / src / gallium / drivers / i915 / i915_prim_vbuf.c
blob2576c417b18bf7094e3a3479a8d691c2e6581ad4
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 /**
29 * \file
30 * Build post-transformation, post-clipping vertex buffers and element
31 * lists by hooking into the end of the primitive pipeline and
32 * manipulating the vertex_id field in the vertex headers.
34 * XXX: work in progress
36 * \author José Fonseca <jrfonseca@tungstengraphics.com>
37 * \author Keith Whitwell <keith@tungstengraphics.com>
41 #include "draw/draw_context.h"
42 #include "draw/draw_vbuf.h"
43 #include "util/u_debug.h"
44 #include "util/u_inlines.h"
45 #include "util/u_math.h"
46 #include "util/u_memory.h"
47 #include "util/u_fifo.h"
49 #include "i915_context.h"
50 #include "i915_reg.h"
51 #include "i915_batch.h"
52 #include "i915_state.h"
55 #define VBUF_MAP_BUFFER
57 /**
58 * Primitive renderer for i915.
60 struct i915_vbuf_render {
61 struct vbuf_render base;
63 struct i915_context *i915;
65 /** Vertex size in bytes */
66 size_t vertex_size;
68 /** Software primitive */
69 unsigned prim;
71 /** Hardware primitive */
72 unsigned hwprim;
74 /** Genereate a vertex list */
75 unsigned fallback;
77 /* Stuff for the vbo */
78 struct i915_winsys_buffer *vbo;
79 size_t vbo_size; /**< current size of allocated buffer */
80 size_t vbo_alloc_size; /**< minimum buffer size to allocate */
81 size_t vbo_hw_offset; /**< offset that we program the hardware with */
82 size_t vbo_sw_offset; /**< offset that we work with */
83 size_t vbo_index; /**< index offset to be added to all indices */
84 void *vbo_ptr;
85 size_t vbo_max_used;
86 size_t vbo_max_index; /**< index offset to be added to all indices */
88 #ifndef VBUF_MAP_BUFFER
89 size_t map_used_start;
90 size_t map_used_end;
91 size_t map_size;
92 #endif
96 /**
97 * Basically a cast wrapper.
99 static INLINE struct i915_vbuf_render *
100 i915_vbuf_render(struct vbuf_render *render)
102 assert(render);
103 return (struct i915_vbuf_render *)render;
107 * If vbo state differs between renderer and context
108 * push state to the context. This function pushes
109 * hw_offset to i915->vbo_offset and vbo to i915->vbo.
111 * Side effects:
112 * May updates context vbo_offset and vbo fields.
114 static void
115 i915_vbuf_update_vbo_state(struct vbuf_render *render)
117 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
118 struct i915_context *i915 = i915_render->i915;
120 if (i915->vbo != i915_render->vbo ||
121 i915->vbo_offset != i915_render->vbo_hw_offset) {
122 i915->vbo = i915_render->vbo;
123 i915->vbo_offset = i915_render->vbo_hw_offset;
124 i915->dirty |= I915_NEW_VBO;
129 * Callback exported to the draw module.
130 * Returns the current vertex_info.
132 * Side effects:
133 * If state is dirty update derived state.
135 static const struct vertex_info *
136 i915_vbuf_render_get_vertex_info(struct vbuf_render *render)
138 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
139 struct i915_context *i915 = i915_render->i915;
141 if (i915->dirty) {
142 /* make sure we have up to date vertex layout */
143 i915_update_derived(i915);
146 return &i915->current.vertex_info;
150 * Reserve space in the vbo for vertices.
152 * Side effects:
153 * None.
155 static boolean
156 i915_vbuf_render_reserve(struct i915_vbuf_render *i915_render, size_t size)
158 struct i915_context *i915 = i915_render->i915;
160 if (i915_render->vbo_size < size + i915_render->vbo_sw_offset)
161 return FALSE;
163 if (i915->vbo_flushed)
164 return FALSE;
166 return TRUE;
170 * Allocate a new vbo buffer should there not be enough space for
171 * the requested number of vertices by the draw module.
173 * Side effects:
174 * Updates hw_offset, sw_offset, index and allocates a new buffer.
175 * Will set i915->vbo to null on buffer allocation.
177 static void
178 i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size)
180 struct i915_context *i915 = i915_render->i915;
181 struct i915_winsys *iws = i915->iws;
183 if (i915_render->vbo) {
184 iws->buffer_unmap(iws, i915_render->vbo);
185 iws->buffer_destroy(iws, i915_render->vbo);
187 * XXX If buffers where referenced then this should be done in
188 * update_vbo_state but since they arn't and malloc likes to reuse
189 * memory we need to set it to null
191 i915->vbo = NULL;
192 i915_render->vbo = NULL;
195 i915->vbo_flushed = 0;
197 i915_render->vbo_size = MAX2(size, i915_render->vbo_alloc_size);
198 i915_render->vbo_hw_offset = 0;
199 i915_render->vbo_sw_offset = 0;
200 i915_render->vbo_index = 0;
202 #ifndef VBUF_MAP_BUFFER
203 if (i915_render->vbo_size > i915_render->map_size) {
204 i915_render->map_size = i915_render->vbo_size;
205 FREE(i915_render->vbo_ptr);
206 i915_render->vbo_ptr = MALLOC(i915_render->map_size);
208 #endif
210 i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size,
211 I915_NEW_VERTEX);
212 i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, TRUE);
216 * Callback exported to the draw module.
218 * Side effects:
219 * Updates hw_offset, sw_offset, index and may allocate
220 * a new buffer. Also updates may update the vbo state
221 * on the i915 context.
223 static boolean
224 i915_vbuf_render_allocate_vertices(struct vbuf_render *render,
225 ushort vertex_size,
226 ushort nr_vertices)
228 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
229 size_t size = (size_t)vertex_size * (size_t)nr_vertices;
230 size_t offset;
233 * Align sw_offset with first multiple of vertex size from hw_offset.
234 * Set index to be the multiples from from hw_offset to sw_offset.
235 * i915_vbuf_render_new_buf will reset index, sw_offset, hw_offset
236 * when it allocates a new buffer this is correct.
239 offset = i915_render->vbo_sw_offset - i915_render->vbo_hw_offset;
240 offset = util_align_npot(offset, vertex_size);
241 i915_render->vbo_sw_offset = i915_render->vbo_hw_offset + offset;
242 i915_render->vbo_index = offset / vertex_size;
245 if (!i915_vbuf_render_reserve(i915_render, size))
246 i915_vbuf_render_new_buf(i915_render, size);
249 * If a new buffer has been alocated sw_offset,
250 * hw_offset & index will be reset by new_buf
253 i915_render->vertex_size = vertex_size;
255 i915_vbuf_update_vbo_state(render);
257 if (!i915_render->vbo)
258 return FALSE;
259 return TRUE;
262 static void *
263 i915_vbuf_render_map_vertices(struct vbuf_render *render)
265 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
266 struct i915_context *i915 = i915_render->i915;
268 if (i915->vbo_flushed)
269 debug_printf("%s bad vbo flush occured stalling on hw\n", __FUNCTION__);
271 #ifdef VBUF_MAP_BUFFER
272 return (unsigned char *)i915_render->vbo_ptr + i915_render->vbo_sw_offset;
273 #else
274 return (unsigned char *)i915_render->vbo_ptr;
275 #endif
278 static void
279 i915_vbuf_render_unmap_vertices(struct vbuf_render *render,
280 ushort min_index,
281 ushort max_index)
283 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
284 struct i915_context *i915 = i915_render->i915;
285 struct i915_winsys *iws = i915->iws;
287 i915_render->vbo_max_index = max_index;
288 i915_render->vbo_max_used = MAX2(i915_render->vbo_max_used, i915_render->vertex_size * (max_index + 1));
289 #ifdef VBUF_MAP_BUFFER
290 (void)iws;
291 #else
292 i915_render->map_used_start = i915_render->vertex_size * min_index;
293 i915_render->map_used_end = i915_render->vertex_size * (max_index + 1);
294 iws->buffer_write(iws, i915_render->vbo,
295 i915_render->map_used_start + i915_render->vbo_sw_offset,
296 i915_render->map_used_end - i915_render->map_used_start,
297 (unsigned char *)i915_render->vbo_ptr + i915_render->map_used_start);
299 #endif
303 * Ensure that the given max_index given is not larger ushort max.
304 * If it is larger then ushort max it advanced the hw_offset to the
305 * same position in the vbo as sw_offset and set index to zero.
307 * Side effects:
308 * On failure update hw_offset and index.
310 static void
311 i915_vbuf_ensure_index_bounds(struct vbuf_render *render,
312 unsigned max_index)
314 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
316 if (max_index + i915_render->vbo_index < ((1 << 17) - 1))
317 return;
319 i915_render->vbo_hw_offset = i915_render->vbo_sw_offset;
320 i915_render->vbo_index = 0;
322 i915_vbuf_update_vbo_state(render);
325 static boolean
326 i915_vbuf_render_set_primitive(struct vbuf_render *render,
327 unsigned prim)
329 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
330 i915_render->prim = prim;
332 switch(prim) {
333 case PIPE_PRIM_POINTS:
334 i915_render->hwprim = PRIM3D_POINTLIST;
335 i915_render->fallback = 0;
336 return TRUE;
337 case PIPE_PRIM_LINES:
338 i915_render->hwprim = PRIM3D_LINELIST;
339 i915_render->fallback = 0;
340 return TRUE;
341 case PIPE_PRIM_LINE_LOOP:
342 i915_render->hwprim = PRIM3D_LINELIST;
343 i915_render->fallback = PIPE_PRIM_LINE_LOOP;
344 return TRUE;
345 case PIPE_PRIM_LINE_STRIP:
346 i915_render->hwprim = PRIM3D_LINESTRIP;
347 i915_render->fallback = 0;
348 return TRUE;
349 case PIPE_PRIM_TRIANGLES:
350 i915_render->hwprim = PRIM3D_TRILIST;
351 i915_render->fallback = 0;
352 return TRUE;
353 case PIPE_PRIM_TRIANGLE_STRIP:
354 i915_render->hwprim = PRIM3D_TRISTRIP;
355 i915_render->fallback = 0;
356 return TRUE;
357 case PIPE_PRIM_TRIANGLE_FAN:
358 i915_render->hwprim = PRIM3D_TRIFAN;
359 i915_render->fallback = 0;
360 return TRUE;
361 case PIPE_PRIM_QUADS:
362 i915_render->hwprim = PRIM3D_TRILIST;
363 i915_render->fallback = PIPE_PRIM_QUADS;
364 return TRUE;
365 case PIPE_PRIM_QUAD_STRIP:
366 i915_render->hwprim = PRIM3D_TRILIST;
367 i915_render->fallback = PIPE_PRIM_QUAD_STRIP;
368 return TRUE;
369 case PIPE_PRIM_POLYGON:
370 i915_render->hwprim = PRIM3D_POLY;
371 i915_render->fallback = 0;
372 return TRUE;
373 default:
374 /* FIXME: Actually, can handle a lot more just fine... */
375 return FALSE;
380 * Used for fallbacks in draw_arrays
382 static void
383 draw_arrays_generate_indices(struct vbuf_render *render,
384 unsigned start, uint nr,
385 unsigned type)
387 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
388 struct i915_context *i915 = i915_render->i915;
389 unsigned i;
390 unsigned end = start + nr + i915_render->vbo_index;
391 start += i915_render->vbo_index;
393 switch(type) {
394 case 0:
395 for (i = start; i+1 < end; i += 2)
396 OUT_BATCH((i+0) | (i+1) << 16);
397 if (i < end)
398 OUT_BATCH(i);
399 break;
400 case PIPE_PRIM_LINE_LOOP:
401 if (nr >= 2) {
402 for (i = start + 1; i < end; i++)
403 OUT_BATCH((i-1) | (i+0) << 16);
404 OUT_BATCH((i-1) | ( start) << 16);
406 break;
407 case PIPE_PRIM_QUADS:
408 for (i = start; i + 3 < end; i += 4) {
409 OUT_BATCH((i+0) | (i+1) << 16);
410 OUT_BATCH((i+3) | (i+1) << 16);
411 OUT_BATCH((i+2) | (i+3) << 16);
413 break;
414 case PIPE_PRIM_QUAD_STRIP:
415 for (i = start; i + 3 < end; i += 2) {
416 OUT_BATCH((i+0) | (i+1) << 16);
417 OUT_BATCH((i+3) | (i+2) << 16);
418 OUT_BATCH((i+0) | (i+3) << 16);
420 break;
421 default:
422 assert(0);
426 static unsigned
427 draw_arrays_calc_nr_indices(uint nr, unsigned type)
429 switch (type) {
430 case 0:
431 return nr;
432 case PIPE_PRIM_LINE_LOOP:
433 if (nr >= 2)
434 return nr * 2;
435 else
436 return 0;
437 case PIPE_PRIM_QUADS:
438 return (nr / 4) * 6;
439 case PIPE_PRIM_QUAD_STRIP:
440 return ((nr - 2) / 2) * 6;
441 default:
442 assert(0);
443 return 0;
447 static void
448 draw_arrays_fallback(struct vbuf_render *render,
449 unsigned start,
450 uint nr)
452 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
453 struct i915_context *i915 = i915_render->i915;
454 unsigned nr_indices;
456 nr_indices = draw_arrays_calc_nr_indices(nr, i915_render->fallback);
457 if (!nr_indices)
458 return;
460 i915_vbuf_ensure_index_bounds(render, start + nr_indices);
462 if (i915->dirty)
463 i915_update_derived(i915);
465 if (i915->hardware_dirty)
466 i915_emit_hardware_state(i915);
468 if (!BEGIN_BATCH(1 + (nr_indices + 1)/2)) {
469 FLUSH_BATCH(NULL);
471 /* Make sure state is re-emitted after a flush:
473 i915_emit_hardware_state(i915);
474 i915->vbo_flushed = 1;
476 if (!BEGIN_BATCH(1 + (nr_indices + 1)/2)) {
477 assert(0);
478 goto out;
482 OUT_BATCH(_3DPRIMITIVE |
483 PRIM_INDIRECT |
484 i915_render->hwprim |
485 PRIM_INDIRECT_ELTS |
486 nr_indices);
488 draw_arrays_generate_indices(render, start, nr, i915_render->fallback);
490 i915_flush_heuristically(i915, nr_indices);
491 out:
492 return;
495 static void
496 i915_vbuf_render_draw_arrays(struct vbuf_render *render,
497 unsigned start,
498 uint nr)
500 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
501 struct i915_context *i915 = i915_render->i915;
503 if (i915_render->fallback) {
504 draw_arrays_fallback(render, start, nr);
505 return;
508 i915_vbuf_ensure_index_bounds(render, start + nr);
509 start += i915_render->vbo_index;
511 if (i915->dirty)
512 i915_update_derived(i915);
514 if (i915->hardware_dirty)
515 i915_emit_hardware_state(i915);
517 if (!BEGIN_BATCH(2)) {
518 FLUSH_BATCH(NULL);
520 /* Make sure state is re-emitted after a flush:
522 i915_emit_hardware_state(i915);
523 i915->vbo_flushed = 1;
525 if (!BEGIN_BATCH(2)) {
526 assert(0);
527 goto out;
531 OUT_BATCH(_3DPRIMITIVE |
532 PRIM_INDIRECT |
533 PRIM_INDIRECT_SEQUENTIAL |
534 i915_render->hwprim |
535 nr);
536 OUT_BATCH(start); /* Beginning vertex index */
538 i915_flush_heuristically(i915, nr);
539 out:
540 return;
544 * Used for normal and fallback emitting of indices
545 * If type is zero normal operation assumed.
547 static void
548 draw_generate_indices(struct vbuf_render *render,
549 const ushort *indices,
550 uint nr_indices,
551 unsigned type)
553 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
554 struct i915_context *i915 = i915_render->i915;
555 unsigned i;
556 unsigned o = i915_render->vbo_index;
558 switch(type) {
559 case 0:
560 for (i = 0; i + 1 < nr_indices; i += 2) {
561 OUT_BATCH((o+indices[i]) | (o+indices[i+1]) << 16);
563 if (i < nr_indices) {
564 OUT_BATCH((o+indices[i]));
566 break;
567 case PIPE_PRIM_LINE_LOOP:
568 if (nr_indices >= 2) {
569 for (i = 1; i < nr_indices; i++)
570 OUT_BATCH((o+indices[i-1]) | (o+indices[i]) << 16);
571 OUT_BATCH((o+indices[i-1]) | (o+indices[0]) << 16);
573 break;
574 case PIPE_PRIM_QUADS:
575 for (i = 0; i + 3 < nr_indices; i += 4) {
576 OUT_BATCH((o+indices[i+0]) | (o+indices[i+1]) << 16);
577 OUT_BATCH((o+indices[i+3]) | (o+indices[i+1]) << 16);
578 OUT_BATCH((o+indices[i+2]) | (o+indices[i+3]) << 16);
580 break;
581 case PIPE_PRIM_QUAD_STRIP:
582 for (i = 0; i + 3 < nr_indices; i += 2) {
583 OUT_BATCH((o+indices[i+0]) | (o+indices[i+1]) << 16);
584 OUT_BATCH((o+indices[i+3]) | (o+indices[i+2]) << 16);
585 OUT_BATCH((o+indices[i+0]) | (o+indices[i+3]) << 16);
587 break;
588 default:
589 assert(0);
590 break;
594 static unsigned
595 draw_calc_nr_indices(uint nr_indices, unsigned type)
597 switch (type) {
598 case 0:
599 return nr_indices;
600 case PIPE_PRIM_LINE_LOOP:
601 if (nr_indices >= 2)
602 return nr_indices * 2;
603 else
604 return 0;
605 case PIPE_PRIM_QUADS:
606 return (nr_indices / 4) * 6;
607 case PIPE_PRIM_QUAD_STRIP:
608 return ((nr_indices - 2) / 2) * 6;
609 default:
610 assert(0);
611 return 0;
615 static void
616 i915_vbuf_render_draw_elements(struct vbuf_render *render,
617 const ushort *indices,
618 uint nr_indices)
620 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
621 struct i915_context *i915 = i915_render->i915;
622 unsigned save_nr_indices;
624 save_nr_indices = nr_indices;
626 nr_indices = draw_calc_nr_indices(nr_indices, i915_render->fallback);
627 if (!nr_indices)
628 return;
630 i915_vbuf_ensure_index_bounds(render, i915_render->vbo_max_index);
632 if (i915->dirty)
633 i915_update_derived(i915);
635 if (i915->hardware_dirty)
636 i915_emit_hardware_state(i915);
638 if (!BEGIN_BATCH(1 + (nr_indices + 1)/2)) {
639 FLUSH_BATCH(NULL);
641 /* Make sure state is re-emitted after a flush:
643 i915_emit_hardware_state(i915);
644 i915->vbo_flushed = 1;
646 if (!BEGIN_BATCH(1 + (nr_indices + 1)/2)) {
647 assert(0);
648 goto out;
652 OUT_BATCH(_3DPRIMITIVE |
653 PRIM_INDIRECT |
654 i915_render->hwprim |
655 PRIM_INDIRECT_ELTS |
656 nr_indices);
657 draw_generate_indices(render,
658 indices,
659 save_nr_indices,
660 i915_render->fallback);
662 i915_flush_heuristically(i915, nr_indices);
663 out:
664 return;
667 static void
668 i915_vbuf_render_release_vertices(struct vbuf_render *render)
670 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
672 i915_render->vbo_sw_offset += i915_render->vbo_max_used;
673 i915_render->vbo_max_used = 0;
676 * Micro optimization, by calling update here we the offset change
677 * will be picked up on the next pipe_context::draw_*.
679 i915_vbuf_update_vbo_state(render);
682 static void
683 i915_vbuf_render_destroy(struct vbuf_render *render)
685 struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
686 struct i915_context *i915 = i915_render->i915;
687 struct i915_winsys *iws = i915->iws;
689 if (i915_render->vbo) {
690 i915->vbo = NULL;
691 iws->buffer_unmap(iws, i915_render->vbo);
692 iws->buffer_destroy(iws, i915_render->vbo);
695 FREE(i915_render);
699 * Create a new primitive render.
701 static struct vbuf_render *
702 i915_vbuf_render_create(struct i915_context *i915)
704 struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
705 struct i915_winsys *iws = i915->iws;
706 int i;
708 i915_render->i915 = i915;
710 i915_render->base.max_vertex_buffer_bytes = 16*4096;
712 /* NOTE: it must be such that state and vertices indices fit in a single
713 * batch buffer.
715 i915_render->base.max_indices = 16*1024;
717 i915_render->base.get_vertex_info = i915_vbuf_render_get_vertex_info;
718 i915_render->base.allocate_vertices = i915_vbuf_render_allocate_vertices;
719 i915_render->base.map_vertices = i915_vbuf_render_map_vertices;
720 i915_render->base.unmap_vertices = i915_vbuf_render_unmap_vertices;
721 i915_render->base.set_primitive = i915_vbuf_render_set_primitive;
722 i915_render->base.draw_elements = i915_vbuf_render_draw_elements;
723 i915_render->base.draw_arrays = i915_vbuf_render_draw_arrays;
724 i915_render->base.release_vertices = i915_vbuf_render_release_vertices;
725 i915_render->base.destroy = i915_vbuf_render_destroy;
727 #ifndef VBUF_MAP_BUFFER
728 i915_render->map_size = 0;
729 i915_render->map_used_start = 0;
730 i915_render->map_used_end = 0;
731 #endif
733 i915_render->vbo = NULL;
734 i915_render->vbo_ptr = NULL;
735 i915_render->vbo_size = 0;
736 i915_render->vbo_hw_offset = 0;
737 i915_render->vbo_sw_offset = 0;
738 i915_render->vbo_alloc_size = i915_render->base.max_vertex_buffer_bytes * 4;
740 #ifdef VBUF_USE_POOL
741 i915_render->pool_used = FALSE;
742 i915_render->pool_buffer_size = i915_render->vbo_alloc_size;
743 i915_render->pool_fifo = u_fifo_create(6);
744 for (i = 0; i < 6; i++)
745 u_fifo_add(i915_render->pool_fifo,
746 iws->buffer_create(iws, i915_render->pool_buffer_size,
747 I915_NEW_VERTEX));
748 #else
749 (void)i;
750 (void)iws;
751 #endif
753 return &i915_render->base;
757 * Create a new primitive vbuf/render stage.
759 struct draw_stage *i915_draw_vbuf_stage(struct i915_context *i915)
761 struct vbuf_render *render;
762 struct draw_stage *stage;
764 render = i915_vbuf_render_create(i915);
765 if(!render)
766 return NULL;
768 stage = draw_vbuf_stage(i915->draw, render);
769 if(!stage) {
770 render->destroy(render);
771 return NULL;
773 /** TODO JB: this shouldn't be here */
774 draw_set_render(i915->draw, render);
776 return stage;