VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/array/arrayspu.c@ 16036

Last change on this file since 16036 was 16036, checked in by vboxsync, 16 years ago

crOpenGL: fix crash in spec viewperf tcvis-01 benchmark

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 28.6 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include <stdio.h>
8#include "cr_spu.h"
9#include "cr_error.h"
10#include "state/cr_limits.h"
11#include "arrayspu.h"
12
13ArraySPU array_spu;
14
15static void ARRAYSPU_APIENTRY arrayspu_ArrayElement( GLint index )
16{
17 const CRClientState *c = &(array_spu.ctx->client);
18 const CRVertexArrays *array = &(c->array);
19 const GLboolean vpEnabled = array_spu.ctx->program.vpEnabled;
20 unsigned char *p;
21 unsigned int unit, attr;
22
23 if (array->e.enabled)
24 {
25 p = array->e.p + index * array->e.stride;
26
27#ifdef CR_ARB_vertex_buffer_object
28 if (array->e.buffer && array->e.buffer->data)
29 {
30 p = (unsigned char *)(array->e.buffer->data) + (unsigned long)p;
31 }
32#endif
33
34 array_spu.self.EdgeFlagv(p);
35 }
36
37 /*
38 * Vertex attribute arrays (GL_NV_vertex_program) have priority over
39 * the conventional vertex arrays.
40 */
41 if (vpEnabled)
42 {
43 for (attr = 1; attr < VERT_ATTRIB_MAX; attr++)
44 {
45 if (array->a[attr].enabled)
46 {
47 GLint *iPtr;
48 p = array->a[attr].p + index * array->a[attr].stride;
49
50#ifdef CR_ARB_vertex_buffer_object
51 if (array->a[attr].buffer && array->a[attr].buffer->data)
52 {
53 p = (unsigned char *)(array->a[attr].buffer->data) + (unsigned long)p;
54 }
55#endif
56
57 switch (array->a[attr].type)
58 {
59 case GL_SHORT:
60 switch (array->a[attr].size)
61 {
62 case 1: array_spu.self.VertexAttrib1svARB(attr, (GLshort *)p); break;
63 case 2: array_spu.self.VertexAttrib2svARB(attr, (GLshort *)p); break;
64 case 3: array_spu.self.VertexAttrib3svARB(attr, (GLshort *)p); break;
65 case 4: array_spu.self.VertexAttrib4svARB(attr, (GLshort *)p); break;
66 }
67 break;
68 case GL_INT:
69 iPtr = (GLint *) p;
70 switch (array->a[attr].size)
71 {
72 case 1: array_spu.self.VertexAttrib1fARB(attr, p[0]); break;
73 case 2: array_spu.self.VertexAttrib2fARB(attr, p[0], p[1]); break;
74 case 3: array_spu.self.VertexAttrib3fARB(attr, p[0], p[1], p[2]); break;
75 case 4: array_spu.self.VertexAttrib4fARB(attr, p[0], p[1], p[2], p[3]); break;
76 }
77 break;
78 case GL_FLOAT:
79 switch (array->a[attr].size)
80 {
81 case 1: array_spu.self.VertexAttrib1fvARB(attr, (GLfloat *)p); break;
82 case 2: array_spu.self.VertexAttrib2fvARB(attr, (GLfloat *)p); break;
83 case 3: array_spu.self.VertexAttrib3fvARB(attr, (GLfloat *)p); break;
84 case 4: array_spu.self.VertexAttrib4fvARB(attr, (GLfloat *)p); break;
85 }
86 break;
87 case GL_DOUBLE:
88 switch (array->a[attr].size)
89 {
90 case 1: array_spu.self.VertexAttrib1dvARB(attr, (GLdouble *)p); break;
91 case 2: array_spu.self.VertexAttrib2dvARB(attr, (GLdouble *)p); break;
92 case 3: array_spu.self.VertexAttrib3dvARB(attr, (GLdouble *)p); break;
93 case 4: array_spu.self.VertexAttrib4dvARB(attr, (GLdouble *)p); break;
94 }
95 break;
96 default:
97 crWarning("Bad datatype for vertex attribute [%d] array: 0x%x\n",
98 attr, array->a[attr].type);
99 }
100 }
101 }
102 }
103
104 /* Now do conventional arrays, unless overriden by generic arrays above */
105 for (unit = 0 ; unit < array_spu.ctx->limits.maxTextureUnits ; unit++)
106 {
107 if (array->t[unit].enabled && !(vpEnabled && array->a[VERT_ATTRIB_TEX0+unit].enabled))
108 {
109 p = array->t[unit].p + index * array->t[unit].stride;
110
111#ifdef CR_ARB_vertex_buffer_object
112 if (array->t[unit].buffer && array->t[unit].buffer->data)
113 {
114 p = (unsigned char *)(array->t[unit].buffer->data) + (unsigned long)p;
115 }
116#endif
117
118 switch (array->t[unit].type)
119 {
120 case GL_SHORT:
121 switch (array->t[unit].size)
122 {
123 case 1: array_spu.self.MultiTexCoord1svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
124 case 2: array_spu.self.MultiTexCoord2svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
125 case 3: array_spu.self.MultiTexCoord3svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
126 case 4: array_spu.self.MultiTexCoord4svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
127 }
128 break;
129 case GL_INT:
130 switch (array->t[unit].size)
131 {
132 case 1: array_spu.self.MultiTexCoord1ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
133 case 2: array_spu.self.MultiTexCoord2ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
134 case 3: array_spu.self.MultiTexCoord3ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
135 case 4: array_spu.self.MultiTexCoord4ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
136 }
137 break;
138 case GL_FLOAT:
139 switch (array->t[unit].size)
140 {
141 case 1: array_spu.self.MultiTexCoord1fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
142 case 2: array_spu.self.MultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
143 case 3: array_spu.self.MultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
144 case 4: array_spu.self.MultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
145 }
146 break;
147 case GL_DOUBLE:
148 switch (array->t[unit].size)
149 {
150 case 1: array_spu.self.MultiTexCoord1dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
151 case 2: array_spu.self.MultiTexCoord2dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
152 case 3: array_spu.self.MultiTexCoord3dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
153 case 4: array_spu.self.MultiTexCoord4dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
154 }
155 break;
156 }
157 }
158 }
159 if (array->i.enabled)
160 {
161 p = array->i.p + index * array->i.stride;
162
163#ifdef CR_ARB_vertex_buffer_object
164 if (array->i.buffer && array->i.buffer->data)
165 {
166 p = (unsigned char *)(array->i.buffer->data) + (unsigned long)p;
167 }
168#endif
169
170 switch (array->i.type)
171 {
172 case GL_SHORT: array_spu.self.Indexsv((GLshort *)p); break;
173 case GL_INT: array_spu.self.Indexiv((GLint *)p); break;
174 case GL_FLOAT: array_spu.self.Indexfv((GLfloat *)p); break;
175 case GL_DOUBLE: array_spu.self.Indexdv((GLdouble *)p); break;
176 }
177 }
178 if (array->c.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR0].enabled))
179 {
180 p = array->c.p + index * array->c.stride;
181
182#ifdef CR_ARB_vertex_buffer_object
183 if (array->c.buffer && array->c.buffer->data)
184 {
185 p = (unsigned char *)(array->c.buffer->data) + (unsigned long)p;
186 }
187#endif
188
189 switch (array->c.type)
190 {
191 case GL_BYTE:
192 switch (array->c.size)
193 {
194 case 3: array_spu.self.Color3bv((GLbyte *)p); break;
195 case 4: array_spu.self.Color4bv((GLbyte *)p); break;
196 }
197 break;
198 case GL_UNSIGNED_BYTE:
199 switch (array->c.size)
200 {
201 case 3: array_spu.self.Color3ubv((GLubyte *)p); break;
202 case 4: array_spu.self.Color4ubv((GLubyte *)p); break;
203 }
204 break;
205 case GL_SHORT:
206 switch (array->c.size)
207 {
208 case 3: array_spu.self.Color3sv((GLshort *)p); break;
209 case 4: array_spu.self.Color4sv((GLshort *)p); break;
210 }
211 break;
212 case GL_UNSIGNED_SHORT:
213 switch (array->c.size)
214 {
215 case 3: array_spu.self.Color3usv((GLushort *)p); break;
216 case 4: array_spu.self.Color4usv((GLushort *)p); break;
217 }
218 break;
219 case GL_INT:
220 switch (array->c.size)
221 {
222 case 3: array_spu.self.Color3iv((GLint *)p); break;
223 case 4: array_spu.self.Color4iv((GLint *)p); break;
224 }
225 break;
226 case GL_UNSIGNED_INT:
227 switch (array->c.size)
228 {
229 case 3: array_spu.self.Color3uiv((GLuint *)p); break;
230 case 4: array_spu.self.Color4uiv((GLuint *)p); break;
231 }
232 break;
233 case GL_FLOAT:
234 switch (array->c.size)
235 {
236 case 3: array_spu.self.Color3fv((GLfloat *)p); break;
237 case 4: array_spu.self.Color4fv((GLfloat *)p); break;
238 }
239 break;
240 case GL_DOUBLE:
241 switch (array->c.size)
242 {
243 case 3: array_spu.self.Color3dv((GLdouble *)p); break;
244 case 4: array_spu.self.Color4dv((GLdouble *)p); break;
245 }
246 break;
247 }
248 }
249 if (array->n.enabled && !(vpEnabled && array->a[VERT_ATTRIB_NORMAL].enabled))
250 {
251 p = array->n.p + index * array->n.stride;
252
253#ifdef CR_ARB_vertex_buffer_object
254 if (array->n.buffer && array->n.buffer->data)
255 {
256 p = (unsigned char *)(array->n.buffer->data) + (unsigned long)p;
257 }
258#endif
259
260 switch (array->n.type)
261 {
262 case GL_BYTE: array_spu.self.Normal3bv((GLbyte *)p); break;
263 case GL_SHORT: array_spu.self.Normal3sv((GLshort *)p); break;
264 case GL_INT: array_spu.self.Normal3iv((GLint *)p); break;
265 case GL_FLOAT: array_spu.self.Normal3fv((GLfloat *)p); break;
266 case GL_DOUBLE: array_spu.self.Normal3dv((GLdouble *)p); break;
267 }
268 }
269#ifdef CR_EXT_secondary_color
270 if (array->s.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR1].enabled))
271 {
272 p = array->s.p + index * array->s.stride;
273
274#ifdef CR_ARB_vertex_buffer_object
275 if (array->s.buffer && array->s.buffer->data)
276 {
277 p = (unsigned char *)(array->s.buffer->data) + (unsigned long)p;
278 }
279#endif
280
281 switch (array->s.type)
282 {
283 case GL_BYTE:
284 array_spu.self.SecondaryColor3bvEXT((GLbyte *)p); break;
285 case GL_UNSIGNED_BYTE:
286 array_spu.self.SecondaryColor3ubvEXT((GLubyte *)p); break;
287 case GL_SHORT:
288 array_spu.self.SecondaryColor3svEXT((GLshort *)p); break;
289 case GL_UNSIGNED_SHORT:
290 array_spu.self.SecondaryColor3usvEXT((GLushort *)p); break;
291 case GL_INT:
292 array_spu.self.SecondaryColor3ivEXT((GLint *)p); break;
293 case GL_UNSIGNED_INT:
294 array_spu.self.SecondaryColor3uivEXT((GLuint *)p); break;
295 case GL_FLOAT:
296 array_spu.self.SecondaryColor3fvEXT((GLfloat *)p); break;
297 case GL_DOUBLE:
298 array_spu.self.SecondaryColor3dvEXT((GLdouble *)p); break;
299 }
300 }
301#endif // CR_EXT_secondary_color
302#ifdef CR_EXT_fog_coord
303 if (array->f.enabled && !(vpEnabled && array->a[VERT_ATTRIB_FOG].enabled))
304 {
305 p = array->f.p + index * array->f.stride;
306
307#ifdef CR_ARB_vertex_buffer_object
308 if (array->f.buffer && array->f.buffer->data)
309 {
310 p = (unsigned char *)(array->f.buffer->data) + (unsigned long)p;
311 }
312#endif
313
314 array_spu.self.FogCoordfEXT( *((GLfloat *) p) );
315 }
316#endif // CR_EXT_fog_coord
317
318 /* Need to do attrib[0] / vertex position last */
319 if (array->a[VERT_ATTRIB_POS].enabled) {
320 GLint *iPtr;
321 p = array->a[VERT_ATTRIB_POS].p + index * array->a[VERT_ATTRIB_POS].stride;
322
323#ifdef CR_ARB_vertex_buffer_object
324 if (array->a[VERT_ATTRIB_POS].buffer && array->a[VERT_ATTRIB_POS].buffer->data)
325 {
326 p = (unsigned char *)(array->a[VERT_ATTRIB_POS].buffer->data) + (unsigned long)p;
327 }
328#endif
329
330 switch (array->a[VERT_ATTRIB_POS].type)
331 {
332 case GL_SHORT:
333 switch (array->a[VERT_ATTRIB_POS].size)
334 {
335 case 1: array_spu.self.VertexAttrib1svARB(0, (GLshort *)p); break;
336 case 2: array_spu.self.VertexAttrib2svARB(0, (GLshort *)p); break;
337 case 3: array_spu.self.VertexAttrib3svARB(0, (GLshort *)p); break;
338 case 4: array_spu.self.VertexAttrib4svARB(0, (GLshort *)p); break;
339 }
340 break;
341 case GL_INT:
342 iPtr = (GLint *) p;
343 switch (array->a[VERT_ATTRIB_POS].size)
344 {
345 case 1: array_spu.self.VertexAttrib1fARB(0, p[0]); break;
346 case 2: array_spu.self.VertexAttrib2fARB(0, p[0], p[1]); break;
347 case 3: array_spu.self.VertexAttrib3fARB(0, p[0], p[1], p[2]); break;
348 case 4: array_spu.self.VertexAttrib4fARB(0, p[0], p[1], p[2], p[3]); break;
349 }
350 break;
351 case GL_FLOAT:
352 switch (array->a[VERT_ATTRIB_POS].size)
353 {
354 case 1: array_spu.self.VertexAttrib1fvARB(0, (GLfloat *)p); break;
355 case 2: array_spu.self.VertexAttrib2fvARB(0, (GLfloat *)p); break;
356 case 3: array_spu.self.VertexAttrib3fvARB(0, (GLfloat *)p); break;
357 case 4: array_spu.self.VertexAttrib4fvARB(0, (GLfloat *)p); break;
358 }
359 break;
360 case GL_DOUBLE:
361 switch (array->a[VERT_ATTRIB_POS].size)
362 {
363 case 1: array_spu.self.VertexAttrib1dvARB(0, (GLdouble *)p); break;
364 case 2: array_spu.self.VertexAttrib2dvARB(0, (GLdouble *)p); break;
365 case 3: array_spu.self.VertexAttrib3dvARB(0, (GLdouble *)p); break;
366 case 4: array_spu.self.VertexAttrib4dvARB(0, (GLdouble *)p); break;
367 }
368 break;
369 default:
370 crWarning("Bad datatype for vertex attribute [0] array: 0x%x\n", array->a[0].type);
371 }
372 }
373 else if (array->v.enabled)
374 {
375 p = array->v.p + index * array->v.stride;
376
377#ifdef CR_ARB_vertex_buffer_object
378 if (array->v.buffer && array->v.buffer->data)
379 {
380 p = (unsigned char *)(array->v.buffer->data) + (unsigned long)p;
381 }
382#endif
383
384 switch (array->v.type)
385 {
386 case GL_SHORT:
387 switch (array->v.size)
388 {
389 case 2: array_spu.self.Vertex2sv((GLshort *)p); break;
390 case 3: array_spu.self.Vertex3sv((GLshort *)p); break;
391 case 4: array_spu.self.Vertex4sv((GLshort *)p); break;
392 }
393 break;
394 case GL_INT:
395 switch (array->v.size)
396 {
397 case 2: array_spu.self.Vertex2iv((GLint *)p); break;
398 case 3: array_spu.self.Vertex3iv((GLint *)p); break;
399 case 4: array_spu.self.Vertex4iv((GLint *)p); break;
400 }
401 break;
402 case GL_FLOAT:
403 switch (array->v.size)
404 {
405 case 2: array_spu.self.Vertex2fv((GLfloat *)p); break;
406 case 3: array_spu.self.Vertex3fv((GLfloat *)p); break;
407 case 4: array_spu.self.Vertex4fv((GLfloat *)p); break;
408 }
409 break;
410 case GL_DOUBLE:
411 switch (array->v.size)
412 {
413 case 2: array_spu.self.Vertex2dv((GLdouble *)p); break;
414 case 3: array_spu.self.Vertex3dv((GLdouble *)p); break;
415 case 4: array_spu.self.Vertex4dv((GLdouble *)p); break;
416 }
417 break;
418 default:
419 crWarning("Bad datatype for vertex array: 0x%x\n", array->v.type);
420 }
421 }
422}
423
424static void ARRAYSPU_APIENTRY arrayspu_DrawArrays(GLenum mode, GLint first, GLsizei count)
425{
426 int i;
427
428 if (count < 0)
429 {
430 crError("array_spu.self.DrawArrays passed negative count: %d", count);
431 }
432
433 if (mode > GL_POLYGON)
434 {
435 crError("array_spu.self.DrawArrays called with invalid mode: %d", mode);
436 }
437
438 array_spu.self.Begin(mode);
439 for (i=0; i<count; i++)
440 {
441 array_spu.self.ArrayElement(first++);
442 }
443 array_spu.self.End();
444}
445
446static void ARRAYSPU_APIENTRY arrayspu_DrawElements(GLenum mode, GLsizei count,
447 GLenum type, const GLvoid *indices)
448{
449 int i;
450 GLubyte *p = (GLubyte *)indices;
451#ifdef CR_ARB_vertex_buffer_object
452 CRBufferObject *elementsBuffer = array_spu.ctx->bufferobject.elementsBuffer;
453#endif
454
455 if (count < 0)
456 {
457 crError("array_spu.self.DrawElements passed negative count: %d", count);
458 }
459
460 if (mode > GL_POLYGON)
461 {
462 crError("array_spu.self.DrawElements called with invalid mode: %d", mode);
463 }
464
465 if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT)
466 {
467 crError("array_spu.self.DrawElements called with invalid type: %d", type);
468 }
469
470#ifdef CR_ARB_vertex_buffer_object
471 if (elementsBuffer && elementsBuffer->data)
472 {
473 p = (unsigned char *)(elementsBuffer->data) + (unsigned long)p;
474 }
475#endif
476
477 array_spu.self.Begin(mode);
478 switch (type)
479 {
480 case GL_UNSIGNED_BYTE:
481 for (i=0; i<count; i++)
482 {
483 array_spu.self.ArrayElement((GLint) *p++);
484 }
485 break;
486 case GL_UNSIGNED_SHORT:
487 for (i=0; i<count; i++)
488 {
489 array_spu.self.ArrayElement((GLint) * (GLushort *) p);
490 p+=sizeof (GLushort);
491 }
492 break;
493 case GL_UNSIGNED_INT:
494 for (i=0; i<count; i++)
495 {
496 array_spu.self.ArrayElement((GLint) * (GLuint *) p);
497 p+=sizeof (GLuint);
498 }
499 break;
500 default:
501 crError( "this can't happen: array_spu.self.DrawElements" );
502 break;
503 }
504 array_spu.self.End();
505}
506
507static void ARRAYSPU_APIENTRY arrayspu_ColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
508{
509 crStateColorPointer( size, type, stride, pointer );
510}
511
512static void ARRAYSPU_APIENTRY arrayspu_SecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
513{
514 crStateSecondaryColorPointerEXT( size, type, stride, pointer );
515}
516
517static void ARRAYSPU_APIENTRY arrayspu_VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
518{
519 crStateVertexPointer( size, type, stride, pointer );
520}
521
522static void ARRAYSPU_APIENTRY arrayspu_TexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
523{
524 crStateTexCoordPointer( size, type, stride, pointer );
525}
526
527static void ARRAYSPU_APIENTRY arrayspu_NormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
528{
529 crStateNormalPointer( type, stride, pointer );
530}
531
532static void ARRAYSPU_APIENTRY arrayspu_IndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
533{
534 crStateIndexPointer( type, stride, pointer );
535}
536
537static void ARRAYSPU_APIENTRY arrayspu_EdgeFlagPointer( GLsizei stride, const GLvoid *pointer )
538{
539 crStateEdgeFlagPointer( stride, pointer );
540}
541
542static void ARRAYSPU_APIENTRY arrayspu_VertexAttribPointerNV( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer )
543{
544 crStateVertexAttribPointerNV( index, size, type, stride, pointer );
545}
546
547static void ARRAYSPU_APIENTRY arrayspu_FogCoordPointerEXT( GLenum type, GLsizei stride, const GLvoid *pointer )
548{
549 crStateFogCoordPointerEXT( type, stride, pointer );
550}
551
552static void ARRAYSPU_APIENTRY arrayspu_GetPointerv( GLenum pname, GLvoid **params )
553{
554 crStateGetPointerv( pname, params );
555}
556
557static void ARRAYSPU_APIENTRY arrayspu_EnableClientState( GLenum array )
558{
559 crStateEnableClientState( array );
560}
561
562static void ARRAYSPU_APIENTRY arrayspu_DisableClientState( GLenum array )
563{
564 crStateDisableClientState( array );
565}
566
567static void ARRAYSPU_APIENTRY arrayspu_ClientActiveTextureARB( GLenum texture )
568{
569 crStateClientActiveTextureARB( texture );
570}
571
572static void ARRAYSPU_APIENTRY arrayspu_MultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
573{
574 int i;
575
576 if (primcount < 0)
577 {
578 crError("array_spu.self.MultiDrawArraysEXT passed negative count: %d", primcount);
579 }
580
581 if (mode > GL_POLYGON)
582 {
583 crError("array_spu.self.MultiDrawArraysEXT called with invalid mode: %d", mode);
584 }
585
586 for (i = 0; i < primcount; i++)
587 {
588 array_spu.self.DrawArrays(mode, first[i], count[i]);
589 }
590}
591
592static void ARRAYSPU_APIENTRY arrayspu_MultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)
593{
594 int i;
595
596 if (primcount < 0)
597 {
598 crError("array_spu.self.MultiDrawElementsEXT passed negative count: %d", primcount);
599 }
600
601 if (mode > GL_POLYGON)
602 {
603 crError("array_spu.self.MultiDrawElementsEXT called with invalid mode: %d", mode);
604 }
605
606 if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT)
607 {
608 crError("array_spu.self.MultiDrawElementsEXT called with invalid type: %d", type);
609 }
610
611 for (i = 0; i < primcount; i++)
612 {
613 array_spu.self.DrawElements(mode, count[i], type, indices[i]);
614 }
615}
616
617/*
618 * We need to know when vertex program mode is enabled/disabled
619 * in order to handle vertex attribute arrays correctly.
620 */
621static void ARRAYSPU_APIENTRY arrayspu_Enable(GLenum cap)
622{
623 if (cap == GL_VERTEX_PROGRAM_NV) {
624 array_spu.ctx->program.vpEnabled = GL_TRUE;
625 }
626 array_spu.child.Enable(cap);
627}
628
629
630static void ARRAYSPU_APIENTRY arrayspu_Disable(GLenum cap)
631{
632 if (cap == GL_VERTEX_PROGRAM_NV) {
633 array_spu.ctx->program.vpEnabled = GL_FALSE;
634 }
635 array_spu.child.Disable(cap);
636}
637
638
639
640static void ARRAYSPU_APIENTRY
641arrayspu_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
642 GLboolean normalized, GLsizei stride,
643 const GLvoid *pointer)
644{
645 crStateVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
646}
647
648
649static void ARRAYSPU_APIENTRY
650arrayspu_EnableVertexAttribArrayARB(GLuint index)
651{
652 crStateEnableVertexAttribArrayARB(index);
653}
654
655
656static void ARRAYSPU_APIENTRY
657arrayspu_DisableVertexAttribArrayARB(GLuint index)
658{
659 crStateDisableVertexAttribArrayARB(index);
660}
661
662
663/* We need to implement Push/PopClientAttrib here so that _our_ state
664 * tracker gets used. Also, pass the call onto the next SPU (in case
665 * it's the GL_CLIENT_PIXEL_STORE_BIT, etc).
666 */
667static void ARRAYSPU_APIENTRY
668arrayspu_PushClientAttrib( GLbitfield mask )
669{
670 crStatePushClientAttrib(mask);
671 array_spu.child.PushClientAttrib(mask);
672}
673
674
675static void ARRAYSPU_APIENTRY
676arrayspu_PopClientAttrib( void )
677{
678 crStatePopClientAttrib();
679 array_spu.child.PopClientAttrib();
680}
681
682
683static void ARRAYSPU_APIENTRY
684arrayspu_GenBuffersARB( GLsizei n, GLuint * buffers )
685{
686 crStateGenBuffersARB(n, buffers);
687}
688
689static void ARRAYSPU_APIENTRY
690arrayspu_DeleteBuffersARB( GLsizei n, const GLuint *buffers )
691{
692 crStateDeleteBuffersARB(n, buffers);
693}
694
695static void ARRAYSPU_APIENTRY
696arrayspu_BindBufferARB( GLenum target, GLuint buffer )
697{
698 crStateBindBufferARB(target, buffer);
699}
700
701static GLboolean ARRAYSPU_APIENTRY
702arrayspu_IsBufferARB (GLuint buffer)
703{
704 return crStateIsBufferARB(buffer);
705}
706
707static void ARRAYSPU_APIENTRY
708arrayspu_BufferDataARB( GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage )
709{
710 crStateBufferDataARB(target, size, data, usage);
711}
712
713static void ARRAYSPU_APIENTRY
714arrayspu_BufferSubDataARB( GLenum target, GLintptrARB offset,
715 GLsizeiptrARB size, const GLvoid * data )
716{
717 crStateBufferSubDataARB(target, offset, size, data);
718}
719
720static void ARRAYSPU_APIENTRY
721arrayspu_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data)
722{
723 crStateGetBufferSubDataARB(target, offset, size, data);
724}
725
726static void * ARRAYSPU_APIENTRY
727arrayspu_MapBufferARB(GLenum target, GLenum access)
728{
729 return crStateMapBufferARB(target, access);
730}
731
732static GLboolean ARRAYSPU_APIENTRY
733arrayspu_UnmapBufferARB(GLenum target)
734{
735 return crStateUnmapBufferARB(target);
736}
737
738static void ARRAYSPU_APIENTRY
739arrayspu_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
740{
741 crStateGetBufferParameterivARB(target, pname, params);
742}
743
744static void ARRAYSPU_APIENTRY
745arrayspu_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
746{
747 crStateGetBufferPointervARB(target, pname, params);
748}
749
750static void ARRAYSPU_APIENTRY
751arrayspu_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *p)
752{
753 crStateInterleavedArrays(format, stride, p);
754}
755
756
757SPUNamedFunctionTable _cr_array_table[] = {
758 { "ArrayElement", (SPUGenericFunction) arrayspu_ArrayElement },
759 { "DrawArrays", (SPUGenericFunction) arrayspu_DrawArrays},
760 { "DrawElements", (SPUGenericFunction) arrayspu_DrawElements},
761 { "ColorPointer", (SPUGenericFunction) arrayspu_ColorPointer},
762 { "SecondaryColorPointerEXT", (SPUGenericFunction) arrayspu_SecondaryColorPointerEXT},
763 { "VertexPointer", (SPUGenericFunction) arrayspu_VertexPointer},
764 { "TexCoordPointer", (SPUGenericFunction) arrayspu_TexCoordPointer},
765 { "NormalPointer", (SPUGenericFunction) arrayspu_NormalPointer},
766 { "IndexPointer", (SPUGenericFunction) arrayspu_IndexPointer},
767 { "EdgeFlagPointer", (SPUGenericFunction) arrayspu_EdgeFlagPointer},
768 { "VertexAttribPointerNV", (SPUGenericFunction) arrayspu_VertexAttribPointerNV},
769 { "FogCoordPointerEXT", (SPUGenericFunction) arrayspu_FogCoordPointerEXT},
770 { "GetPointerv", (SPUGenericFunction) arrayspu_GetPointerv},
771 { "EnableClientState", (SPUGenericFunction) arrayspu_EnableClientState},
772 { "DisableClientState", (SPUGenericFunction) arrayspu_DisableClientState},
773 { "ClientActiveTextureARB", (SPUGenericFunction) arrayspu_ClientActiveTextureARB },
774 { "MultiDrawArraysEXT", (SPUGenericFunction) arrayspu_MultiDrawArraysEXT },
775 { "MultiDrawElementsEXT", (SPUGenericFunction) arrayspu_MultiDrawElementsEXT },
776 { "Enable", (SPUGenericFunction) arrayspu_Enable },
777 { "Disable", (SPUGenericFunction) arrayspu_Disable },
778 { "PushClientAttrib", (SPUGenericFunction) arrayspu_PushClientAttrib },
779 { "PopClientAttrib", (SPUGenericFunction) arrayspu_PopClientAttrib },
780 { "VertexAttribPointerARB", (SPUGenericFunction) arrayspu_VertexAttribPointerARB },
781 { "EnableVertexAttribArrayARB", (SPUGenericFunction) arrayspu_EnableVertexAttribArrayARB },
782 { "DisableVertexAttribArrayARB", (SPUGenericFunction) arrayspu_DisableVertexAttribArrayARB },
783 { "GenBuffersARB", (SPUGenericFunction) arrayspu_GenBuffersARB },
784 { "DeleteBuffersARB", (SPUGenericFunction) arrayspu_DeleteBuffersARB },
785 { "BindBufferARB", (SPUGenericFunction) arrayspu_BindBufferARB },
786 { "IsBufferARB", (SPUGenericFunction) arrayspu_IsBufferARB },
787 { "BufferDataARB", (SPUGenericFunction) arrayspu_BufferDataARB },
788 { "BufferSubDataARB", (SPUGenericFunction) arrayspu_BufferSubDataARB },
789 { "GetBufferSubDataARB", (SPUGenericFunction) arrayspu_GetBufferSubDataARB },
790 { "MapBufferARB", (SPUGenericFunction) arrayspu_MapBufferARB },
791 { "UnmapBufferARB", (SPUGenericFunction) arrayspu_UnmapBufferARB },
792 { "GetBufferParameterivARB", (SPUGenericFunction) arrayspu_GetBufferParameterivARB},
793 { "GetBufferPointervARB", (SPUGenericFunction) arrayspu_GetBufferPointervARB},
794 { "InterleavedArrays", (SPUGenericFunction) arrayspu_InterleavedArrays},
795 { NULL, NULL }
796};
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette