1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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
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 **************************************************************************/
29 * This file implements the st_draw_vbo() function which is called from
30 * Mesa's VBO module. All point/line/triangle rendering is done through
31 * this function whether the user called glBegin/End, glDrawArrays,
32 * glDrawElements, glEvalMesh, or glCalList, etc.
34 * We basically convert the VBO's vertex attribute/array information into
35 * Gallium vertex state, bind the vertex buffer objects and call
36 * pipe->draw_elements(), pipe->draw_range_elements() or pipe->draw_arrays().
39 * Keith Whitwell <keith@tungstengraphics.com>
43 #include "main/imports.h"
44 #include "main/image.h"
45 #include "main/macros.h"
46 #include "shader/prog_uniform.h"
50 #include "st_context.h"
52 #include "st_cb_bufferobjects.h"
54 #include "st_program.h"
56 #include "pipe/p_context.h"
57 #include "pipe/p_defines.h"
58 #include "pipe/p_inlines.h"
61 static GLuint double_types
[4] = {
62 PIPE_FORMAT_R64_FLOAT
,
63 PIPE_FORMAT_R64G64_FLOAT
,
64 PIPE_FORMAT_R64G64B64_FLOAT
,
65 PIPE_FORMAT_R64G64B64A64_FLOAT
68 static GLuint float_types
[4] = {
69 PIPE_FORMAT_R32_FLOAT
,
70 PIPE_FORMAT_R32G32_FLOAT
,
71 PIPE_FORMAT_R32G32B32_FLOAT
,
72 PIPE_FORMAT_R32G32B32A32_FLOAT
75 static GLuint uint_types_norm
[4] = {
76 PIPE_FORMAT_R32_UNORM
,
77 PIPE_FORMAT_R32G32_UNORM
,
78 PIPE_FORMAT_R32G32B32_UNORM
,
79 PIPE_FORMAT_R32G32B32A32_UNORM
82 static GLuint uint_types_scale
[4] = {
83 PIPE_FORMAT_R32_USCALED
,
84 PIPE_FORMAT_R32G32_USCALED
,
85 PIPE_FORMAT_R32G32B32_USCALED
,
86 PIPE_FORMAT_R32G32B32A32_USCALED
89 static GLuint int_types_norm
[4] = {
90 PIPE_FORMAT_R32_SNORM
,
91 PIPE_FORMAT_R32G32_SNORM
,
92 PIPE_FORMAT_R32G32B32_SNORM
,
93 PIPE_FORMAT_R32G32B32A32_SNORM
96 static GLuint int_types_scale
[4] = {
97 PIPE_FORMAT_R32_SSCALED
,
98 PIPE_FORMAT_R32G32_SSCALED
,
99 PIPE_FORMAT_R32G32B32_SSCALED
,
100 PIPE_FORMAT_R32G32B32A32_SSCALED
103 static GLuint ushort_types_norm
[4] = {
104 PIPE_FORMAT_R16_UNORM
,
105 PIPE_FORMAT_R16G16_UNORM
,
106 PIPE_FORMAT_R16G16B16_UNORM
,
107 PIPE_FORMAT_R16G16B16A16_UNORM
110 static GLuint ushort_types_scale
[4] = {
111 PIPE_FORMAT_R16_USCALED
,
112 PIPE_FORMAT_R16G16_USCALED
,
113 PIPE_FORMAT_R16G16B16_USCALED
,
114 PIPE_FORMAT_R16G16B16A16_USCALED
117 static GLuint short_types_norm
[4] = {
118 PIPE_FORMAT_R16_SNORM
,
119 PIPE_FORMAT_R16G16_SNORM
,
120 PIPE_FORMAT_R16G16B16_SNORM
,
121 PIPE_FORMAT_R16G16B16A16_SNORM
124 static GLuint short_types_scale
[4] = {
125 PIPE_FORMAT_R16_SSCALED
,
126 PIPE_FORMAT_R16G16_SSCALED
,
127 PIPE_FORMAT_R16G16B16_SSCALED
,
128 PIPE_FORMAT_R16G16B16A16_SSCALED
131 static GLuint ubyte_types_norm
[4] = {
132 PIPE_FORMAT_R8_UNORM
,
133 PIPE_FORMAT_R8G8_UNORM
,
134 PIPE_FORMAT_R8G8B8_UNORM
,
135 PIPE_FORMAT_R8G8B8A8_UNORM
138 static GLuint ubyte_types_scale
[4] = {
139 PIPE_FORMAT_R8_USCALED
,
140 PIPE_FORMAT_R8G8_USCALED
,
141 PIPE_FORMAT_R8G8B8_USCALED
,
142 PIPE_FORMAT_R8G8B8A8_USCALED
145 static GLuint byte_types_norm
[4] = {
146 PIPE_FORMAT_R8_SNORM
,
147 PIPE_FORMAT_R8G8_SNORM
,
148 PIPE_FORMAT_R8G8B8_SNORM
,
149 PIPE_FORMAT_R8G8B8A8_SNORM
152 static GLuint byte_types_scale
[4] = {
153 PIPE_FORMAT_R8_SSCALED
,
154 PIPE_FORMAT_R8G8_SSCALED
,
155 PIPE_FORMAT_R8G8B8_SSCALED
,
156 PIPE_FORMAT_R8G8B8A8_SSCALED
159 static GLuint fixed_types
[4] = {
160 PIPE_FORMAT_R32_FIXED
,
161 PIPE_FORMAT_R32G32_FIXED
,
162 PIPE_FORMAT_R32G32B32_FIXED
,
163 PIPE_FORMAT_R32G32B32A32_FIXED
169 * Return a PIPE_FORMAT_x for the given GL datatype and size.
172 st_pipe_vertex_format(GLenum type
, GLuint size
, GLenum format
,
173 GLboolean normalized
)
175 assert((type
>= GL_BYTE
&& type
<= GL_DOUBLE
) ||
179 assert(format
== GL_RGBA
|| format
== GL_BGRA
);
181 if (format
== GL_BGRA
) {
182 /* this is an odd-ball case */
183 assert(type
== GL_UNSIGNED_BYTE
);
185 return PIPE_FORMAT_B8G8R8A8_UNORM
;
190 case GL_DOUBLE
: return double_types
[size
-1];
191 case GL_FLOAT
: return float_types
[size
-1];
192 case GL_INT
: return int_types_norm
[size
-1];
193 case GL_SHORT
: return short_types_norm
[size
-1];
194 case GL_BYTE
: return byte_types_norm
[size
-1];
195 case GL_UNSIGNED_INT
: return uint_types_norm
[size
-1];
196 case GL_UNSIGNED_SHORT
: return ushort_types_norm
[size
-1];
197 case GL_UNSIGNED_BYTE
: return ubyte_types_norm
[size
-1];
198 case GL_FIXED
: return fixed_types
[size
-1];
199 default: assert(0); return 0;
204 case GL_DOUBLE
: return double_types
[size
-1];
205 case GL_FLOAT
: return float_types
[size
-1];
206 case GL_INT
: return int_types_scale
[size
-1];
207 case GL_SHORT
: return short_types_scale
[size
-1];
208 case GL_BYTE
: return byte_types_scale
[size
-1];
209 case GL_UNSIGNED_INT
: return uint_types_scale
[size
-1];
210 case GL_UNSIGNED_SHORT
: return ushort_types_scale
[size
-1];
211 case GL_UNSIGNED_BYTE
: return ubyte_types_scale
[size
-1];
212 case GL_FIXED
: return fixed_types
[size
-1];
213 default: assert(0); return 0;
216 return 0; /* silence compiler warning */
221 * If edge flags are needed, setup an bitvector of flags and call
222 * pipe->set_edgeflags().
223 * XXX memleak: need to free the returned pointer at some point
226 setup_edgeflags(GLcontext
*ctx
, GLenum primMode
, GLint start
, GLint count
,
227 const struct gl_client_array
*array
)
229 struct pipe_context
*pipe
= ctx
->st
->pipe
;
231 if ((primMode
== GL_TRIANGLES
||
232 primMode
== GL_QUADS
||
233 primMode
== GL_POLYGON
) &&
234 (ctx
->Polygon
.FrontMode
!= GL_FILL
||
235 ctx
->Polygon
.BackMode
!= GL_FILL
)) {
236 /* need edge flags */
239 struct st_buffer_object
*stobj
= st_buffer_object(array
->BufferObj
);
242 if (!stobj
|| stobj
->Base
.Name
== 0) {
243 /* edge flags are not in a VBO */
247 vec
= (unsigned *) _mesa_calloc(sizeof(unsigned) * ((count
+ 31) / 32));
251 map
= pipe_buffer_map(pipe
->screen
, stobj
->buffer
, PIPE_BUFFER_USAGE_CPU_READ
);
252 map
= ADD_POINTERS(map
, array
->Ptr
);
254 for (i
= 0; i
< count
; i
++) {
255 if (*((float *) map
))
256 vec
[i
/32] |= 1 << (i
% 32);
258 map
+= array
->StrideB
;
261 pipe_buffer_unmap(pipe
->screen
, stobj
->buffer
);
263 pipe
->set_edgeflags(pipe
, vec
);
268 /* edge flags not needed */
269 pipe
->set_edgeflags(pipe
, NULL
);
276 * Examine the active arrays to determine if we have interleaved
277 * vertex arrays all living in one VBO, or all living in user space.
278 * \param userSpace returns whether the arrays are in user space.
281 is_interleaved_arrays(const struct st_vertex_program
*vp
,
282 const struct gl_client_array
**arrays
,
283 GLboolean
*userSpace
)
286 const struct gl_buffer_object
*firstBufObj
= NULL
;
287 GLint firstStride
= -1;
288 GLuint num_client_arrays
= 0;
289 const GLubyte
*client_addr
= NULL
;
291 for (attr
= 0; attr
< vp
->num_inputs
; attr
++) {
292 const GLuint mesaAttr
= vp
->index_to_input
[attr
];
293 const struct gl_buffer_object
*bufObj
= arrays
[mesaAttr
]->BufferObj
;
294 const GLsizei stride
= arrays
[mesaAttr
]->StrideB
; /* in bytes */
296 if (firstStride
< 0) {
297 firstStride
= stride
;
299 else if (firstStride
!= stride
) {
303 if (!bufObj
|| !bufObj
->Name
) {
305 /* Try to detect if the client-space arrays are
306 * "close" to each other.
309 client_addr
= arrays
[mesaAttr
]->Ptr
;
311 else if (abs(arrays
[mesaAttr
]->Ptr
- client_addr
) > firstStride
) {
312 /* arrays start too far apart */
316 else if (!firstBufObj
) {
317 firstBufObj
= bufObj
;
319 else if (bufObj
!= firstBufObj
) {
324 *userSpace
= (num_client_arrays
== vp
->num_inputs
);
325 /* printf("user space: %d (%d %d)\n", (int) *userSpace,num_client_arrays,vp->num_inputs); */
332 * Compute the memory range occupied by the arrays.
335 get_arrays_bounds(const struct st_vertex_program
*vp
,
336 const struct gl_client_array
**arrays
,
338 const GLubyte
**low
, const GLubyte
**high
)
340 const GLubyte
*low_addr
= NULL
;
341 const GLubyte
*high_addr
= NULL
;
344 for (attr
= 0; attr
< vp
->num_inputs
; attr
++) {
345 const GLuint mesaAttr
= vp
->index_to_input
[attr
];
346 const GLint stride
= arrays
[mesaAttr
]->StrideB
;
347 const GLubyte
*start
= arrays
[mesaAttr
]->Ptr
;
348 const unsigned sz
= (arrays
[mesaAttr
]->Size
*
349 _mesa_sizeof_type(arrays
[mesaAttr
]->Type
));
350 const GLubyte
*end
= start
+ (max_index
* stride
) + sz
;
357 low_addr
= MIN2(low_addr
, start
);
358 high_addr
= MAX2(high_addr
, end
);
368 * Set up for drawing interleaved arrays that all live in one VBO
369 * or all live in user space.
370 * \param vbuffer returns vertex buffer info
371 * \param velements returns vertex element info
374 setup_interleaved_attribs(GLcontext
*ctx
,
375 const struct st_vertex_program
*vp
,
376 const struct gl_client_array
**arrays
,
379 struct pipe_vertex_buffer
*vbuffer
,
380 struct pipe_vertex_element velements
[])
382 struct pipe_context
*pipe
= ctx
->st
->pipe
;
384 const GLubyte
*offset0
;
386 for (attr
= 0; attr
< vp
->num_inputs
; attr
++) {
387 const GLuint mesaAttr
= vp
->index_to_input
[attr
];
388 struct gl_buffer_object
*bufobj
= arrays
[mesaAttr
]->BufferObj
;
389 struct st_buffer_object
*stobj
= st_buffer_object(bufobj
);
390 GLsizei stride
= arrays
[mesaAttr
]->StrideB
;
392 /*printf("stobj %u = %p\n", attr, (void*)stobj);*/
395 const GLubyte
*low
, *high
;
397 get_arrays_bounds(vp
, arrays
, max_index
, &low
, &high
);
398 /*printf("buffer range: %p %p %d\n", low, high, high-low);*/
403 pipe_user_buffer_create(pipe
->screen
, (void *) low
, high
- low
);
404 vbuffer
->buffer_offset
= 0;
407 vbuffer
->buffer
= NULL
;
408 pipe_buffer_reference(&vbuffer
->buffer
, stobj
->buffer
);
409 vbuffer
->buffer_offset
= pointer_to_offset(low
);
411 vbuffer
->stride
= stride
; /* in bytes */
412 vbuffer
->max_index
= max_index
;
415 velements
[attr
].src_offset
=
416 (unsigned) (arrays
[mesaAttr
]->Ptr
- offset0
);
417 velements
[attr
].vertex_buffer_index
= 0;
418 velements
[attr
].nr_components
= arrays
[mesaAttr
]->Size
;
419 velements
[attr
].src_format
=
420 st_pipe_vertex_format(arrays
[mesaAttr
]->Type
,
421 arrays
[mesaAttr
]->Size
,
422 arrays
[mesaAttr
]->Format
,
423 arrays
[mesaAttr
]->Normalized
);
424 assert(velements
[attr
].src_format
);
430 * Set up a separate pipe_vertex_buffer and pipe_vertex_element for each
432 * \param vbuffer returns vertex buffer info
433 * \param velements returns vertex element info
436 setup_non_interleaved_attribs(GLcontext
*ctx
,
437 const struct st_vertex_program
*vp
,
438 const struct gl_client_array
**arrays
,
440 GLboolean
*userSpace
,
441 struct pipe_vertex_buffer vbuffer
[],
442 struct pipe_vertex_element velements
[])
444 struct pipe_context
*pipe
= ctx
->st
->pipe
;
447 for (attr
= 0; attr
< vp
->num_inputs
; attr
++) {
448 const GLuint mesaAttr
= vp
->index_to_input
[attr
];
449 struct gl_buffer_object
*bufobj
= arrays
[mesaAttr
]->BufferObj
;
450 GLsizei stride
= arrays
[mesaAttr
]->StrideB
;
452 *userSpace
= GL_FALSE
;
454 if (bufobj
&& bufobj
->Name
) {
455 /* Attribute data is in a VBO.
456 * Recall that for VBOs, the gl_client_array->Ptr field is
457 * really an offset from the start of the VBO, not a pointer.
459 struct st_buffer_object
*stobj
= st_buffer_object(bufobj
);
460 assert(stobj
->buffer
);
461 /*printf("stobj %u = %p\n", attr, (void*) stobj);*/
463 vbuffer
[attr
].buffer
= NULL
;
464 pipe_buffer_reference(&vbuffer
[attr
].buffer
, stobj
->buffer
);
465 vbuffer
[attr
].buffer_offset
= pointer_to_offset(arrays
[mesaAttr
]->Ptr
);
466 velements
[attr
].src_offset
= 0;
469 /* attribute data is in user-space memory, not a VBO */
471 /*printf("user-space array %d stride %d\n", attr, stride);*/
473 *userSpace
= GL_TRUE
;
476 if (arrays
[mesaAttr
]->Ptr
) {
477 /* user's vertex array */
478 if (arrays
[mesaAttr
]->StrideB
) {
479 bytes
= arrays
[mesaAttr
]->StrideB
* (max_index
+ 1);
482 bytes
= arrays
[mesaAttr
]->Size
483 * _mesa_sizeof_type(arrays
[mesaAttr
]->Type
);
485 vbuffer
[attr
].buffer
= pipe_user_buffer_create(pipe
->screen
,
486 (void *) arrays
[mesaAttr
]->Ptr
, bytes
);
489 /* no array, use ctx->Current.Attrib[] value */
490 bytes
= sizeof(ctx
->Current
.Attrib
[0]);
491 vbuffer
[attr
].buffer
= pipe_user_buffer_create(pipe
->screen
,
492 (void *) ctx
->Current
.Attrib
[mesaAttr
], bytes
);
496 vbuffer
[attr
].buffer_offset
= 0;
497 velements
[attr
].src_offset
= 0;
500 assert(velements
[attr
].src_offset
<= 2048); /* 11-bit field */
502 /* common-case setup */
503 vbuffer
[attr
].stride
= stride
; /* in bytes */
504 vbuffer
[attr
].max_index
= max_index
;
505 velements
[attr
].vertex_buffer_index
= attr
;
506 velements
[attr
].nr_components
= arrays
[mesaAttr
]->Size
;
507 velements
[attr
].src_format
508 = st_pipe_vertex_format(arrays
[mesaAttr
]->Type
,
509 arrays
[mesaAttr
]->Size
,
510 arrays
[mesaAttr
]->Format
,
511 arrays
[mesaAttr
]->Normalized
);
512 assert(velements
[attr
].src_format
);
519 * Prior to drawing, check that any uniforms referenced by the
520 * current shader have been set. If a uniform has not been set,
524 check_uniforms(GLcontext
*ctx
)
526 const struct gl_shader_program
*shProg
= ctx
->Shader
.CurrentProgram
;
527 if (shProg
&& shProg
->LinkStatus
) {
529 for (i
= 0; i
< shProg
->Uniforms
->NumUniforms
; i
++) {
530 const struct gl_uniform
*u
= &shProg
->Uniforms
->Uniforms
[i
];
531 if (!u
->Initialized
) {
533 "Using shader with uninitialized uniform: %s",
542 * This function gets plugged into the VBO module and is called when
543 * we have something to render.
544 * Basically, translate the information into the format expected by gallium.
547 st_draw_vbo(GLcontext
*ctx
,
548 const struct gl_client_array
**arrays
,
549 const struct _mesa_prim
*prims
,
551 const struct _mesa_index_buffer
*ib
,
552 GLboolean index_bounds_valid
,
556 struct pipe_context
*pipe
= ctx
->st
->pipe
;
557 const struct st_vertex_program
*vp
;
558 const struct pipe_shader_state
*vs
;
559 struct pipe_vertex_buffer vbuffer
[PIPE_MAX_SHADER_INPUTS
];
561 struct pipe_vertex_element velements
[PIPE_MAX_ATTRIBS
];
562 unsigned num_vbuffers
, num_velements
;
565 /* Gallium probably doesn't want this in some cases. */
566 if (!index_bounds_valid
)
567 vbo_get_minmax_index(ctx
, prims
, ib
, &min_index
, &max_index
);
569 /* sanity check for pointer arithmetic below */
570 assert(sizeof(arrays
[0]->Ptr
[0]) == 1);
572 st_validate_state(ctx
->st
);
574 /* must get these after state validation! */
576 vs
= &ctx
->st
->vp_varient
->state
;
579 if (MESA_VERBOSE
& VERBOSE_GLSL
) {
583 (void) check_uniforms
;
587 * Setup the vbuffer[] and velements[] arrays.
589 if (is_interleaved_arrays(vp
, arrays
, &userSpace
)) {
590 /*printf("Draw interleaved\n");*/
591 setup_interleaved_attribs(ctx
, vp
, arrays
, max_index
, userSpace
,
594 num_velements
= vp
->num_inputs
;
595 if (num_velements
== 0)
599 /*printf("Draw non-interleaved\n");*/
600 setup_non_interleaved_attribs(ctx
, vp
, arrays
, max_index
,
601 &userSpace
, vbuffer
, velements
);
602 num_vbuffers
= vp
->num_inputs
;
603 num_velements
= vp
->num_inputs
;
609 for (i
= 0; i
< num_vbuffers
; i
++) {
610 printf("buffers[%d].stride = %u\n", i
, vbuffer
[i
].stride
);
611 printf("buffers[%d].max_index = %u\n", i
, vbuffer
[i
].max_index
);
612 printf("buffers[%d].buffer_offset = %u\n", i
, vbuffer
[i
].buffer_offset
);
613 printf("buffers[%d].buffer = %p\n", i
, (void*) vbuffer
[i
].buffer
);
615 for (i
= 0; i
< num_velements
; i
++) {
616 printf("vlements[%d].vbuffer_index = %u\n", i
, velements
[i
].vertex_buffer_index
);
617 printf("vlements[%d].src_offset = %u\n", i
, velements
[i
].src_offset
);
618 printf("vlements[%d].nr_comps = %u\n", i
, velements
[i
].nr_components
);
619 printf("vlements[%d].format = %s\n", i
, pf_name(velements
[i
].src_format
));
624 pipe
->set_vertex_buffers(pipe
, num_vbuffers
, vbuffer
);
625 pipe
->set_vertex_elements(pipe
, num_velements
, velements
);
627 if (num_vbuffers
== 0 || num_velements
== 0)
630 /* do actual drawing */
632 /* indexed primitive */
633 struct gl_buffer_object
*bufobj
= ib
->obj
;
634 struct pipe_buffer
*indexBuf
= NULL
;
635 unsigned indexSize
, indexOffset
, i
;
638 case GL_UNSIGNED_INT
:
641 case GL_UNSIGNED_SHORT
:
644 case GL_UNSIGNED_BYTE
:
652 /* get/create the index buffer object */
653 if (bufobj
&& bufobj
->Name
) {
654 /* elements/indexes are in a real VBO */
655 struct st_buffer_object
*stobj
= st_buffer_object(bufobj
);
656 pipe_buffer_reference(&indexBuf
, stobj
->buffer
);
657 indexOffset
= pointer_to_offset(ib
->ptr
) / indexSize
;
660 /* element/indicies are in user space memory */
661 indexBuf
= pipe_user_buffer_create(pipe
->screen
, (void *) ib
->ptr
,
662 ib
->count
* indexSize
);
667 if (nr_prims
== 1 && pipe
->draw_range_elements
!= NULL
) {
670 /* XXX: exercise temporary path to pass min/max directly
671 * through to driver & draw module. These interfaces still
672 * need a bit of work...
674 setup_edgeflags(ctx
, prims
[i
].mode
,
675 prims
[i
].start
+ indexOffset
, prims
[i
].count
,
676 arrays
[VERT_ATTRIB_EDGEFLAG
]);
678 pipe
->draw_range_elements(pipe
, indexBuf
, indexSize
,
682 prims
[i
].start
+ indexOffset
, prims
[i
].count
);
685 for (i
= 0; i
< nr_prims
; i
++) {
686 setup_edgeflags(ctx
, prims
[i
].mode
,
687 prims
[i
].start
+ indexOffset
, prims
[i
].count
,
688 arrays
[VERT_ATTRIB_EDGEFLAG
]);
690 pipe
->draw_elements(pipe
, indexBuf
, indexSize
,
692 prims
[i
].start
+ indexOffset
, prims
[i
].count
);
696 pipe_buffer_reference(&indexBuf
, NULL
);
701 for (i
= 0; i
< nr_prims
; i
++) {
702 setup_edgeflags(ctx
, prims
[i
].mode
,
703 prims
[i
].start
, prims
[i
].count
,
704 arrays
[VERT_ATTRIB_EDGEFLAG
]);
706 pipe
->draw_arrays(pipe
, prims
[i
].mode
, prims
[i
].start
, prims
[i
].count
);
710 /* unreference buffers (frees wrapped user-space buffer objects) */
711 for (attr
= 0; attr
< num_vbuffers
; attr
++) {
712 pipe_buffer_reference(&vbuffer
[attr
].buffer
, NULL
);
713 assert(!vbuffer
[attr
].buffer
);
718 pipe
->set_vertex_buffers(pipe
, 0, NULL
);
723 void st_init_draw( struct st_context
*st
)
725 GLcontext
*ctx
= st
->ctx
;
727 vbo_set_draw_func(ctx
, st_draw_vbo
);
731 void st_destroy_draw( struct st_context
*st
)