st/mesa: remove vpv->num_inputs dereferences in st_update_array
[mesa.git] / src / mesa / state_tracker / st_atom_array.c
1
2 /**************************************************************************
3 *
4 * Copyright 2007 VMware, Inc.
5 * Copyright 2012 Marek Olšák <maraeo@gmail.com>
6 * All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
18 * of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
23 * IN NO EVENT SHALL AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
24 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 *
28 **************************************************************************/
29
30 /*
31 * This converts the VBO's vertex attribute/array information into
32 * Gallium vertex state and binds it.
33 *
34 * Authors:
35 * Keith Whitwell <keithw@vmware.com>
36 * Marek Olšák <maraeo@gmail.com>
37 */
38
39 #include "st_context.h"
40 #include "st_atom.h"
41 #include "st_cb_bufferobjects.h"
42 #include "st_draw.h"
43 #include "st_program.h"
44
45 #include "cso_cache/cso_context.h"
46 #include "util/u_math.h"
47 #include "main/bufferobj.h"
48 #include "main/glformats.h"
49
50 /* vertex_formats[gltype - GL_BYTE][integer*2 + normalized][size - 1] */
51 static const uint16_t vertex_formats[][4][4] = {
52 { /* GL_BYTE */
53 {
54 PIPE_FORMAT_R8_SSCALED,
55 PIPE_FORMAT_R8G8_SSCALED,
56 PIPE_FORMAT_R8G8B8_SSCALED,
57 PIPE_FORMAT_R8G8B8A8_SSCALED
58 },
59 {
60 PIPE_FORMAT_R8_SNORM,
61 PIPE_FORMAT_R8G8_SNORM,
62 PIPE_FORMAT_R8G8B8_SNORM,
63 PIPE_FORMAT_R8G8B8A8_SNORM
64 },
65 {
66 PIPE_FORMAT_R8_SINT,
67 PIPE_FORMAT_R8G8_SINT,
68 PIPE_FORMAT_R8G8B8_SINT,
69 PIPE_FORMAT_R8G8B8A8_SINT
70 },
71 },
72 { /* GL_UNSIGNED_BYTE */
73 {
74 PIPE_FORMAT_R8_USCALED,
75 PIPE_FORMAT_R8G8_USCALED,
76 PIPE_FORMAT_R8G8B8_USCALED,
77 PIPE_FORMAT_R8G8B8A8_USCALED
78 },
79 {
80 PIPE_FORMAT_R8_UNORM,
81 PIPE_FORMAT_R8G8_UNORM,
82 PIPE_FORMAT_R8G8B8_UNORM,
83 PIPE_FORMAT_R8G8B8A8_UNORM
84 },
85 {
86 PIPE_FORMAT_R8_UINT,
87 PIPE_FORMAT_R8G8_UINT,
88 PIPE_FORMAT_R8G8B8_UINT,
89 PIPE_FORMAT_R8G8B8A8_UINT
90 },
91 },
92 { /* GL_SHORT */
93 {
94 PIPE_FORMAT_R16_SSCALED,
95 PIPE_FORMAT_R16G16_SSCALED,
96 PIPE_FORMAT_R16G16B16_SSCALED,
97 PIPE_FORMAT_R16G16B16A16_SSCALED
98 },
99 {
100 PIPE_FORMAT_R16_SNORM,
101 PIPE_FORMAT_R16G16_SNORM,
102 PIPE_FORMAT_R16G16B16_SNORM,
103 PIPE_FORMAT_R16G16B16A16_SNORM
104 },
105 {
106 PIPE_FORMAT_R16_SINT,
107 PIPE_FORMAT_R16G16_SINT,
108 PIPE_FORMAT_R16G16B16_SINT,
109 PIPE_FORMAT_R16G16B16A16_SINT
110 },
111 },
112 { /* GL_UNSIGNED_SHORT */
113 {
114 PIPE_FORMAT_R16_USCALED,
115 PIPE_FORMAT_R16G16_USCALED,
116 PIPE_FORMAT_R16G16B16_USCALED,
117 PIPE_FORMAT_R16G16B16A16_USCALED
118 },
119 {
120 PIPE_FORMAT_R16_UNORM,
121 PIPE_FORMAT_R16G16_UNORM,
122 PIPE_FORMAT_R16G16B16_UNORM,
123 PIPE_FORMAT_R16G16B16A16_UNORM
124 },
125 {
126 PIPE_FORMAT_R16_UINT,
127 PIPE_FORMAT_R16G16_UINT,
128 PIPE_FORMAT_R16G16B16_UINT,
129 PIPE_FORMAT_R16G16B16A16_UINT
130 },
131 },
132 { /* GL_INT */
133 {
134 PIPE_FORMAT_R32_SSCALED,
135 PIPE_FORMAT_R32G32_SSCALED,
136 PIPE_FORMAT_R32G32B32_SSCALED,
137 PIPE_FORMAT_R32G32B32A32_SSCALED
138 },
139 {
140 PIPE_FORMAT_R32_SNORM,
141 PIPE_FORMAT_R32G32_SNORM,
142 PIPE_FORMAT_R32G32B32_SNORM,
143 PIPE_FORMAT_R32G32B32A32_SNORM
144 },
145 {
146 PIPE_FORMAT_R32_SINT,
147 PIPE_FORMAT_R32G32_SINT,
148 PIPE_FORMAT_R32G32B32_SINT,
149 PIPE_FORMAT_R32G32B32A32_SINT
150 },
151 },
152 { /* GL_UNSIGNED_INT */
153 {
154 PIPE_FORMAT_R32_USCALED,
155 PIPE_FORMAT_R32G32_USCALED,
156 PIPE_FORMAT_R32G32B32_USCALED,
157 PIPE_FORMAT_R32G32B32A32_USCALED
158 },
159 {
160 PIPE_FORMAT_R32_UNORM,
161 PIPE_FORMAT_R32G32_UNORM,
162 PIPE_FORMAT_R32G32B32_UNORM,
163 PIPE_FORMAT_R32G32B32A32_UNORM
164 },
165 {
166 PIPE_FORMAT_R32_UINT,
167 PIPE_FORMAT_R32G32_UINT,
168 PIPE_FORMAT_R32G32B32_UINT,
169 PIPE_FORMAT_R32G32B32A32_UINT
170 },
171 },
172 { /* GL_FLOAT */
173 {
174 PIPE_FORMAT_R32_FLOAT,
175 PIPE_FORMAT_R32G32_FLOAT,
176 PIPE_FORMAT_R32G32B32_FLOAT,
177 PIPE_FORMAT_R32G32B32A32_FLOAT
178 },
179 {
180 PIPE_FORMAT_R32_FLOAT,
181 PIPE_FORMAT_R32G32_FLOAT,
182 PIPE_FORMAT_R32G32B32_FLOAT,
183 PIPE_FORMAT_R32G32B32A32_FLOAT
184 },
185 },
186 {{0}}, /* GL_2_BYTES */
187 {{0}}, /* GL_3_BYTES */
188 {{0}}, /* GL_4_BYTES */
189 { /* GL_DOUBLE */
190 {
191 PIPE_FORMAT_R64_FLOAT,
192 PIPE_FORMAT_R64G64_FLOAT,
193 PIPE_FORMAT_R64G64B64_FLOAT,
194 PIPE_FORMAT_R64G64B64A64_FLOAT
195 },
196 {
197 PIPE_FORMAT_R64_FLOAT,
198 PIPE_FORMAT_R64G64_FLOAT,
199 PIPE_FORMAT_R64G64B64_FLOAT,
200 PIPE_FORMAT_R64G64B64A64_FLOAT
201 },
202 },
203 { /* GL_HALF_FLOAT */
204 {
205 PIPE_FORMAT_R16_FLOAT,
206 PIPE_FORMAT_R16G16_FLOAT,
207 PIPE_FORMAT_R16G16B16_FLOAT,
208 PIPE_FORMAT_R16G16B16A16_FLOAT
209 },
210 {
211 PIPE_FORMAT_R16_FLOAT,
212 PIPE_FORMAT_R16G16_FLOAT,
213 PIPE_FORMAT_R16G16B16_FLOAT,
214 PIPE_FORMAT_R16G16B16A16_FLOAT
215 },
216 },
217 { /* GL_FIXED */
218 {
219 PIPE_FORMAT_R32_FIXED,
220 PIPE_FORMAT_R32G32_FIXED,
221 PIPE_FORMAT_R32G32B32_FIXED,
222 PIPE_FORMAT_R32G32B32A32_FIXED
223 },
224 {
225 PIPE_FORMAT_R32_FIXED,
226 PIPE_FORMAT_R32G32_FIXED,
227 PIPE_FORMAT_R32G32B32_FIXED,
228 PIPE_FORMAT_R32G32B32A32_FIXED
229 },
230 },
231 };
232
233
234 /**
235 * Return a PIPE_FORMAT_x for the given GL datatype and size.
236 */
237 enum pipe_format
238 st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
239 GLboolean normalized, GLboolean integer)
240 {
241 unsigned index;
242
243 assert(size >= 1 && size <= 4);
244 assert(format == GL_RGBA || format == GL_BGRA);
245
246 switch (type) {
247 case GL_HALF_FLOAT_OES:
248 type = GL_HALF_FLOAT;
249 break;
250
251 case GL_INT_2_10_10_10_REV:
252 assert(size == 4 && !integer);
253
254 if (format == GL_BGRA) {
255 if (normalized)
256 return PIPE_FORMAT_B10G10R10A2_SNORM;
257 else
258 return PIPE_FORMAT_B10G10R10A2_SSCALED;
259 } else {
260 if (normalized)
261 return PIPE_FORMAT_R10G10B10A2_SNORM;
262 else
263 return PIPE_FORMAT_R10G10B10A2_SSCALED;
264 }
265 break;
266
267 case GL_UNSIGNED_INT_2_10_10_10_REV:
268 assert(size == 4 && !integer);
269
270 if (format == GL_BGRA) {
271 if (normalized)
272 return PIPE_FORMAT_B10G10R10A2_UNORM;
273 else
274 return PIPE_FORMAT_B10G10R10A2_USCALED;
275 } else {
276 if (normalized)
277 return PIPE_FORMAT_R10G10B10A2_UNORM;
278 else
279 return PIPE_FORMAT_R10G10B10A2_USCALED;
280 }
281 break;
282
283 case GL_UNSIGNED_INT_10F_11F_11F_REV:
284 assert(size == 3 && !integer && format == GL_RGBA);
285 return PIPE_FORMAT_R11G11B10_FLOAT;
286
287 case GL_UNSIGNED_BYTE:
288 if (format == GL_BGRA) {
289 /* this is an odd-ball case */
290 assert(normalized);
291 return PIPE_FORMAT_B8G8R8A8_UNORM;
292 }
293 break;
294 }
295
296 index = integer*2 + normalized;
297 assert(index <= 2);
298 assert(type >= GL_BYTE && type <= GL_FIXED);
299 return vertex_formats[type - GL_BYTE][index][size-1];
300 }
301
302 static const struct gl_vertex_array *
303 get_client_array(const struct st_vertex_program *vp,
304 const struct gl_vertex_array **arrays,
305 int attr)
306 {
307 const GLuint mesaAttr = vp->index_to_input[attr];
308 /* st_program uses 0xffffffff to denote a double placeholder attribute */
309 if (mesaAttr == ST_DOUBLE_ATTRIB_PLACEHOLDER)
310 return NULL;
311 return arrays[mesaAttr];
312 }
313
314 /**
315 * Examine the active arrays to determine if we have interleaved
316 * vertex arrays all living in one VBO, or all living in user space.
317 */
318 static GLboolean
319 is_interleaved_arrays(const struct st_vertex_program *vp,
320 const struct gl_vertex_array **arrays,
321 unsigned num_inputs)
322 {
323 GLuint attr;
324 const struct gl_buffer_object *firstBufObj = NULL;
325 GLint firstStride = -1;
326 const GLubyte *firstPtr = NULL;
327 GLboolean userSpaceBuffer = GL_FALSE;
328
329 for (attr = 0; attr < num_inputs; attr++) {
330 const struct gl_vertex_array *array;
331 const struct gl_buffer_object *bufObj;
332 GLsizei stride;
333
334 array = get_client_array(vp, arrays, attr);
335 if (!array)
336 continue;
337
338 stride = array->StrideB; /* in bytes */
339 bufObj = array->BufferObj;
340 if (attr == 0) {
341 /* save info about the first array */
342 firstStride = stride;
343 firstPtr = array->Ptr;
344 firstBufObj = bufObj;
345 userSpaceBuffer = !bufObj || !bufObj->Name;
346 }
347 else {
348 /* check if other arrays interleave with the first, in same buffer */
349 if (stride != firstStride)
350 return GL_FALSE; /* strides don't match */
351
352 if (bufObj != firstBufObj)
353 return GL_FALSE; /* arrays in different VBOs */
354
355 if (llabs(array->Ptr - firstPtr) > firstStride)
356 return GL_FALSE; /* arrays start too far apart */
357
358 if ((!_mesa_is_bufferobj(bufObj)) != userSpaceBuffer)
359 return GL_FALSE; /* mix of VBO and user-space arrays */
360 }
361 }
362
363 return GL_TRUE;
364 }
365
366 static void init_velement(struct pipe_vertex_element *velement,
367 int src_offset, int format,
368 int instance_divisor, int vbo_index)
369 {
370 velement->src_offset = src_offset;
371 velement->src_format = format;
372 velement->instance_divisor = instance_divisor;
373 velement->vertex_buffer_index = vbo_index;
374 assert(velement->src_format);
375 }
376
377 static void init_velement_lowered(const struct st_vertex_program *vp,
378 struct pipe_vertex_element *velements,
379 int src_offset, int format,
380 int instance_divisor, int vbo_index,
381 int nr_components, GLboolean doubles,
382 GLuint *attr_idx)
383 {
384 int idx = *attr_idx;
385 if (doubles) {
386 int lower_format;
387
388 if (nr_components < 2)
389 lower_format = PIPE_FORMAT_R32G32_UINT;
390 else
391 lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
392
393 init_velement(&velements[idx], src_offset,
394 lower_format, instance_divisor, vbo_index);
395 idx++;
396
397 if (idx < vp->num_inputs &&
398 vp->index_to_input[idx] == ST_DOUBLE_ATTRIB_PLACEHOLDER) {
399 if (nr_components >= 3) {
400 if (nr_components == 3)
401 lower_format = PIPE_FORMAT_R32G32_UINT;
402 else
403 lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
404
405 init_velement(&velements[idx], src_offset + 4 * sizeof(float),
406 lower_format, instance_divisor, vbo_index);
407 } else {
408 /* The values here are undefined. Fill in some conservative
409 * dummy values.
410 */
411 init_velement(&velements[idx], src_offset, PIPE_FORMAT_R32G32_UINT,
412 instance_divisor, vbo_index);
413 }
414
415 idx++;
416 }
417 } else {
418 init_velement(&velements[idx], src_offset,
419 format, instance_divisor, vbo_index);
420 idx++;
421 }
422 *attr_idx = idx;
423 }
424
425 static void
426 set_vertex_attribs(struct st_context *st,
427 struct pipe_vertex_buffer *vbuffers,
428 unsigned num_vbuffers,
429 struct pipe_vertex_element *velements,
430 unsigned num_velements)
431 {
432 struct cso_context *cso = st->cso_context;
433
434 cso_set_vertex_buffers(cso, 0, num_vbuffers, vbuffers);
435 if (st->last_num_vbuffers > num_vbuffers) {
436 /* Unbind remaining buffers, if any. */
437 cso_set_vertex_buffers(cso, num_vbuffers,
438 st->last_num_vbuffers - num_vbuffers, NULL);
439 }
440 st->last_num_vbuffers = num_vbuffers;
441 cso_set_vertex_elements(cso, num_velements, velements);
442 }
443
444 /**
445 * Set up for drawing interleaved arrays that all live in one VBO
446 * or all live in user space.
447 * \param vbuffer returns vertex buffer info
448 * \param velements returns vertex element info
449 */
450 static void
451 setup_interleaved_attribs(struct st_context *st,
452 const struct st_vertex_program *vp,
453 const struct gl_vertex_array **arrays,
454 unsigned num_inputs)
455 {
456 struct pipe_vertex_buffer vbuffer;
457 struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS] = {{0}};
458 GLuint attr;
459 const GLubyte *low_addr = NULL;
460 GLboolean usingVBO; /* all arrays in a VBO? */
461 struct gl_buffer_object *bufobj;
462 GLsizei stride;
463
464 /* Find the lowest address of the arrays we're drawing,
465 * Init bufobj and stride.
466 */
467 if (num_inputs) {
468 const struct gl_vertex_array *array;
469
470 array = get_client_array(vp, arrays, 0);
471 assert(array);
472
473 /* Since we're doing interleaved arrays, we know there'll be at most
474 * one buffer object and the stride will be the same for all arrays.
475 * Grab them now.
476 */
477 bufobj = array->BufferObj;
478 stride = array->StrideB;
479
480 low_addr = arrays[vp->index_to_input[0]]->Ptr;
481
482 for (attr = 1; attr < num_inputs; attr++) {
483 const GLubyte *start;
484 array = get_client_array(vp, arrays, attr);
485 if (!array)
486 continue;
487 start = array->Ptr;
488 low_addr = MIN2(low_addr, start);
489 }
490 }
491 else {
492 /* not sure we'll ever have zero inputs, but play it safe */
493 bufobj = NULL;
494 stride = 0;
495 low_addr = 0;
496 }
497
498 /* are the arrays in user space? */
499 usingVBO = _mesa_is_bufferobj(bufobj);
500
501 for (attr = 0; attr < num_inputs;) {
502 const struct gl_vertex_array *array;
503 unsigned src_offset;
504 unsigned src_format;
505
506 array = get_client_array(vp, arrays, attr);
507 assert(array);
508
509 src_offset = (unsigned) (array->Ptr - low_addr);
510 assert(array->_ElementSize ==
511 _mesa_bytes_per_vertex_attrib(array->Size, array->Type));
512
513 src_format = st_pipe_vertex_format(array->Type,
514 array->Size,
515 array->Format,
516 array->Normalized,
517 array->Integer);
518
519 init_velement_lowered(vp, velements, src_offset, src_format,
520 array->InstanceDivisor, 0,
521 array->Size, array->Doubles, &attr);
522 }
523
524 /*
525 * Return the vbuffer info and setup user-space attrib info, if needed.
526 */
527 if (num_inputs == 0) {
528 /* just defensive coding here */
529 vbuffer.buffer.resource = NULL;
530 vbuffer.is_user_buffer = false;
531 vbuffer.buffer_offset = 0;
532 vbuffer.stride = 0;
533 }
534 else if (usingVBO) {
535 /* all interleaved arrays in a VBO */
536 struct st_buffer_object *stobj = st_buffer_object(bufobj);
537
538 if (!stobj || !stobj->buffer) {
539 st->vertex_array_out_of_memory = true;
540 return; /* out-of-memory error probably */
541 }
542
543 vbuffer.buffer.resource = stobj->buffer;
544 vbuffer.is_user_buffer = false;
545 vbuffer.buffer_offset = pointer_to_offset(low_addr);
546 vbuffer.stride = stride;
547 }
548 else {
549 /* all interleaved arrays in user memory */
550 vbuffer.buffer.user = low_addr;
551 vbuffer.is_user_buffer = !!low_addr; /* if NULL, then unbind */
552 vbuffer.buffer_offset = 0;
553 vbuffer.stride = stride;
554 }
555
556 set_vertex_attribs(st, &vbuffer, num_inputs ? 1 : 0,
557 velements, num_inputs);
558 }
559
560 /**
561 * Set up a separate pipe_vertex_buffer and pipe_vertex_element for each
562 * vertex attribute.
563 * \param vbuffer returns vertex buffer info
564 * \param velements returns vertex element info
565 */
566 static void
567 setup_non_interleaved_attribs(struct st_context *st,
568 const struct st_vertex_program *vp,
569 const struct gl_vertex_array **arrays,
570 unsigned num_inputs)
571 {
572 struct gl_context *ctx = st->ctx;
573 struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
574 struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS] = {{0}};
575 unsigned num_vbuffers = 0;
576 GLuint attr;
577
578 for (attr = 0; attr < num_inputs;) {
579 const GLuint mesaAttr = vp->index_to_input[attr];
580 const struct gl_vertex_array *array;
581 struct gl_buffer_object *bufobj;
582 GLsizei stride;
583 unsigned src_format;
584 unsigned bufidx;
585
586 array = get_client_array(vp, arrays, attr);
587 assert(array);
588
589 bufidx = num_vbuffers++;
590
591 stride = array->StrideB;
592 bufobj = array->BufferObj;
593 assert(array->_ElementSize ==
594 _mesa_bytes_per_vertex_attrib(array->Size, array->Type));
595
596 if (_mesa_is_bufferobj(bufobj)) {
597 /* Attribute data is in a VBO.
598 * Recall that for VBOs, the gl_vertex_array->Ptr field is
599 * really an offset from the start of the VBO, not a pointer.
600 */
601 struct st_buffer_object *stobj = st_buffer_object(bufobj);
602
603 if (!stobj || !stobj->buffer) {
604 st->vertex_array_out_of_memory = true;
605 return; /* out-of-memory error probably */
606 }
607
608 vbuffer[bufidx].buffer.resource = stobj->buffer;
609 vbuffer[bufidx].is_user_buffer = false;
610 vbuffer[bufidx].buffer_offset = pointer_to_offset(array->Ptr);
611 }
612 else {
613 /* wrap user data */
614 void *ptr;
615
616 if (array->Ptr) {
617 ptr = (void *) array->Ptr;
618 }
619 else {
620 /* no array, use ctx->Current.Attrib[] value */
621 ptr = (void *) ctx->Current.Attrib[mesaAttr];
622 stride = 0;
623 }
624
625 assert(ptr);
626
627 vbuffer[bufidx].buffer.user = ptr;
628 vbuffer[bufidx].is_user_buffer = !!ptr; /* if NULL, then unbind */
629 vbuffer[bufidx].buffer_offset = 0;
630 }
631
632 /* common-case setup */
633 vbuffer[bufidx].stride = stride; /* in bytes */
634
635 src_format = st_pipe_vertex_format(array->Type,
636 array->Size,
637 array->Format,
638 array->Normalized,
639 array->Integer);
640
641 init_velement_lowered(vp, velements, 0, src_format,
642 array->InstanceDivisor, bufidx,
643 array->Size, array->Doubles, &attr);
644 }
645
646 set_vertex_attribs(st, vbuffer, num_vbuffers, velements, num_inputs);
647 }
648
649 void st_update_array(struct st_context *st)
650 {
651 struct gl_context *ctx = st->ctx;
652 const struct gl_vertex_array **arrays = ctx->Array._DrawArrays;
653 const struct st_vertex_program *vp;
654 unsigned num_inputs;
655
656 st->vertex_array_out_of_memory = FALSE;
657
658 /* No drawing has been done yet, so do nothing. */
659 if (!arrays)
660 return;
661
662 /* vertex program validation must be done before this */
663 vp = st->vp;
664 num_inputs = st->vp_variant->num_inputs;
665
666 if (is_interleaved_arrays(vp, arrays, num_inputs))
667 setup_interleaved_attribs(st, vp, arrays, num_inputs);
668 else
669 setup_non_interleaved_attribs(st, vp, arrays, num_inputs);
670 }