Changeset 21308 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Jul 7, 2009 10:49:52 AM (16 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/glapi_parser/APIspec.txt
r20467 r21308 3366 3366 category 1.1 3367 3367 props setclient 3368 chromium 3368 chromium extpack 3369 3369 3370 3370 name PushClientAttrib … … 3373 3373 category 1.1 3374 3374 props setclient 3375 chromium 3375 chromium extpack 3376 3376 3377 3377 -
trunk/src/VBox/GuestHost/OpenGL/packer/pack_client.c
r21306 r21308 8 8 #include "cr_opcodes.h" 9 9 #include "cr_version.h" 10 #include "state/cr_limits.h" 11 #include "cr_glstate.h" 12 13 /*Convert from GLint to GLfloat in [-1.f,1.f]*/ 14 #define CRP_I2F_NORM(i) ((2.f*((GLint)(i))+1.f) * (1.f/4294967294.f)) 15 /*Convert from GLshort to GLfloat in [-1.f,1.f]*/ 16 #define CRP_S2F_NORM(s) ((2.f*((GLshort)(s))+1.f) * (1.f/65535.f)) 17 18 19 static void crPackVertexAttrib(const CRVertexArrays *array, unsigned int attr, GLint index) 20 { 21 GLint *iPtr; 22 GLshort *sPtr; 23 unsigned char *p = array->a[attr].p + index * array->a[attr].stride; 24 25 #ifdef CR_ARB_vertex_buffer_object 26 if (array->a[attr].buffer && array->a[attr].buffer->data) 27 { 28 p = (unsigned char *)(array->a[attr].buffer->data) + (unsigned long)p; 29 } 30 #endif 31 switch (array->a[attr].type) 32 { 33 case GL_SHORT: 34 sPtr = (GLshort*) p; 35 switch (array->a[attr].size) 36 { 37 case 1: 38 if (array->a[attr].normalized) 39 crPackVertexAttrib1fARB(attr, CRP_S2F_NORM(sPtr[0])); 40 else 41 crPackVertexAttrib1svARB(attr, sPtr); 42 break; 43 case 2: 44 if (array->a[attr].normalized) 45 crPackVertexAttrib2fARB(attr, CRP_S2F_NORM(sPtr[0]), CRP_S2F_NORM(sPtr[1])); 46 else 47 crPackVertexAttrib2svARB(attr, sPtr); 48 break; 49 case 3: 50 if (array->a[attr].normalized) 51 crPackVertexAttrib3fARB(attr, CRP_S2F_NORM(sPtr[0]), CRP_S2F_NORM(sPtr[1]), CRP_S2F_NORM(sPtr[2])); 52 else 53 crPackVertexAttrib3svARB(attr, sPtr); 54 break; 55 case 4: 56 if (array->a[attr].normalized) 57 crPackVertexAttrib4NsvARB(attr, sPtr); 58 else 59 crPackVertexAttrib4svARB(attr, sPtr); 60 break; 61 } 62 break; 63 case GL_INT: 64 iPtr = (GLint*) p; 65 switch (array->a[attr].size) 66 { 67 case 1: 68 if (array->a[attr].normalized) 69 crPackVertexAttrib1fARB(attr, CRP_I2F_NORM(iPtr[0])); 70 else 71 crPackVertexAttrib1fARB(attr, iPtr[0]); 72 break; 73 case 2: 74 if (array->a[attr].normalized) 75 crPackVertexAttrib2fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1])); 76 else 77 crPackVertexAttrib2fARB(attr, iPtr[0], iPtr[1]); 78 break; 79 case 3: 80 if (array->a[attr].normalized) 81 crPackVertexAttrib3fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1]), CRP_I2F_NORM(iPtr[2])); 82 else 83 crPackVertexAttrib3fARB(attr, iPtr[0], iPtr[1], iPtr[2]); 84 break; 85 case 4: 86 if (array->a[attr].normalized) 87 crPackVertexAttrib4NivARB(attr, iPtr); 88 else 89 crPackVertexAttrib4fARB(attr, iPtr[0], iPtr[1], iPtr[2], iPtr[3]); 90 break; 91 } 92 break; 93 case GL_FLOAT: 94 switch (array->a[attr].size) 95 { 96 case 1: crPackVertexAttrib1fvARB(attr, (GLfloat *)p); break; 97 case 2: crPackVertexAttrib2fvARB(attr, (GLfloat *)p); break; 98 case 3: crPackVertexAttrib3fvARB(attr, (GLfloat *)p); break; 99 case 4: crPackVertexAttrib4fvARB(attr, (GLfloat *)p); break; 100 } 101 break; 102 case GL_DOUBLE: 103 switch (array->a[attr].size) 104 { 105 case 1: crPackVertexAttrib1dvARB(attr, (GLdouble *)p); break; 106 case 2: crPackVertexAttrib2dvARB(attr, (GLdouble *)p); break; 107 case 3: crPackVertexAttrib3dvARB(attr, (GLdouble *)p); break; 108 case 4: crPackVertexAttrib4dvARB(attr, (GLdouble *)p); break; 109 } 110 break; 111 default: 112 crWarning("Bad datatype for vertex attribute [%d] array: 0x%x\n", 113 attr, array->a[attr].type); 114 } 115 } 10 116 11 117 /* … … 16 122 { 17 123 unsigned char *p; 18 int unit; 19 20 if (c->array.e.enabled) 21 { 22 crPackEdgeFlagv(c->array.e.p + index * c->array.e.stride); 23 } 24 for (unit = 0; unit < CR_MAX_TEXTURE_UNITS; unit++) 25 { 26 if (c->array.t[unit].enabled) 27 { 28 p = c->array.t[unit].p + index * c->array.t[unit].stride; 29 switch (c->array.t[unit].type) 30 { 31 case GL_SHORT: 32 switch (c->array.t[c->curClientTextureUnit].size) 33 { 34 case 1: crPackMultiTexCoord1svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 35 case 2: crPackMultiTexCoord2svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 36 case 3: crPackMultiTexCoord3svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 37 case 4: crPackMultiTexCoord4svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 38 } 39 break; 40 case GL_INT: 41 switch (c->array.t[c->curClientTextureUnit].size) 42 { 43 case 1: crPackMultiTexCoord1ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 44 case 2: crPackMultiTexCoord2ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 45 case 3: crPackMultiTexCoord3ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 46 case 4: crPackMultiTexCoord4ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 47 } 48 break; 49 case GL_FLOAT: 50 switch (c->array.t[c->curClientTextureUnit].size) 51 { 52 case 1: crPackMultiTexCoord1fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 53 case 2: crPackMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 54 case 3: crPackMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 55 case 4: crPackMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 56 } 57 break; 58 case GL_DOUBLE: 59 switch (c->array.t[c->curClientTextureUnit].size) 60 { 61 case 1: crPackMultiTexCoord1dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 62 case 2: crPackMultiTexCoord2dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 63 case 3: crPackMultiTexCoord3dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 64 case 4: crPackMultiTexCoord4dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 65 } 66 break; 67 } 68 } 69 } /* loop over texture units */ 70 71 if (c->array.i.enabled) 72 { 73 p = c->array.i.p + index * c->array.i.stride; 74 switch (c->array.i.type) 75 { 76 case GL_SHORT: crPackIndexsv((GLshort *)p); break; 77 case GL_INT: crPackIndexiv((GLint *)p); break; 78 case GL_FLOAT: crPackIndexfv((GLfloat *)p); break; 79 case GL_DOUBLE: crPackIndexdv((GLdouble *)p); break; 80 } 81 } 82 if (c->array.c.enabled) 83 { 84 p = c->array.c.p + index * c->array.c.stride; 85 switch (c->array.c.type) 86 { 87 case GL_BYTE: 88 switch (c->array.c.size) 89 { 90 case 3: crPackColor3bv((GLbyte *)p); break; 91 case 4: crPackColor4bv((GLbyte *)p); break; 92 } 93 break; 94 case GL_UNSIGNED_BYTE: 95 switch (c->array.c.size) 96 { 97 case 3: crPackColor3ubv((GLubyte *)p); break; 98 case 4: crPackColor4ubv((GLubyte *)p); break; 99 } 100 break; 101 case GL_SHORT: 102 switch (c->array.c.size) 103 { 104 case 3: crPackColor3sv((GLshort *)p); break; 105 case 4: crPackColor4sv((GLshort *)p); break; 106 } 107 break; 108 case GL_UNSIGNED_SHORT: 109 switch (c->array.c.size) 110 { 111 case 3: crPackColor3usv((GLushort *)p); break; 112 case 4: crPackColor4usv((GLushort *)p); break; 113 } 114 break; 115 case GL_INT: 116 switch (c->array.c.size) 117 { 118 case 3: crPackColor3iv((GLint *)p); break; 119 case 4: crPackColor4iv((GLint *)p); break; 120 } 121 break; 122 case GL_UNSIGNED_INT: 123 switch (c->array.c.size) 124 { 125 case 3: crPackColor3uiv((GLuint *)p); break; 126 case 4: crPackColor4uiv((GLuint *)p); break; 127 } 128 break; 129 case GL_FLOAT: 130 switch (c->array.c.size) 131 { 132 case 3: crPackColor3fv((GLfloat *)p); break; 133 case 4: crPackColor4fv((GLfloat *)p); break; 134 } 135 break; 136 case GL_DOUBLE: 137 switch (c->array.c.size) 138 { 139 case 3: crPackColor3dv((GLdouble *)p); break; 140 case 4: crPackColor4dv((GLdouble *)p); break; 141 } 142 break; 143 } 144 } 145 if (c->array.n.enabled) 146 { 147 p = c->array.n.p + index * c->array.n.stride; 148 switch (c->array.n.type) 124 unsigned int unit, attr; 125 const CRVertexArrays *array = &(c->array); 126 const GLboolean vpEnabled = crStateGetCurrent()->program.vpEnabled; 127 128 if (array->n.enabled && !(vpEnabled && array->a[VERT_ATTRIB_NORMAL].enabled)) 129 { 130 p = array->n.p + index * array->n.stride; 131 132 #ifdef CR_ARB_vertex_buffer_object 133 if (array->n.buffer && array->n.buffer->data) 134 { 135 p = (unsigned char *)(array->n.buffer->data) + (unsigned long)p; 136 } 137 #endif 138 139 switch (array->n.type) 149 140 { 150 141 case GL_BYTE: crPackNormal3bv((GLbyte *)p); break; … … 155 146 } 156 147 } 148 149 if (array->c.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR0].enabled)) 150 { 151 p = array->c.p + index * array->c.stride; 152 153 #ifdef CR_ARB_vertex_buffer_object 154 if (array->c.buffer && array->c.buffer->data) 155 { 156 p = (unsigned char *)(array->c.buffer->data) + (unsigned long)p; 157 } 158 #endif 159 160 switch (array->c.type) 161 { 162 case GL_BYTE: 163 switch (c->array.c.size) 164 { 165 case 3: crPackColor3bv((GLbyte *)p); break; 166 case 4: crPackColor4bv((GLbyte *)p); break; 167 } 168 break; 169 case GL_UNSIGNED_BYTE: 170 switch (c->array.c.size) 171 { 172 case 3: crPackColor3ubv((GLubyte *)p); break; 173 case 4: crPackColor4ubv((GLubyte *)p); break; 174 } 175 break; 176 case GL_SHORT: 177 switch (c->array.c.size) 178 { 179 case 3: crPackColor3sv((GLshort *)p); break; 180 case 4: crPackColor4sv((GLshort *)p); break; 181 } 182 break; 183 case GL_UNSIGNED_SHORT: 184 switch (c->array.c.size) 185 { 186 case 3: crPackColor3usv((GLushort *)p); break; 187 case 4: crPackColor4usv((GLushort *)p); break; 188 } 189 break; 190 case GL_INT: 191 switch (c->array.c.size) 192 { 193 case 3: crPackColor3iv((GLint *)p); break; 194 case 4: crPackColor4iv((GLint *)p); break; 195 } 196 break; 197 case GL_UNSIGNED_INT: 198 switch (c->array.c.size) 199 { 200 case 3: crPackColor3uiv((GLuint *)p); break; 201 case 4: crPackColor4uiv((GLuint *)p); break; 202 } 203 break; 204 case GL_FLOAT: 205 switch (c->array.c.size) 206 { 207 case 3: crPackColor3fv((GLfloat *)p); break; 208 case 4: crPackColor4fv((GLfloat *)p); break; 209 } 210 break; 211 case GL_DOUBLE: 212 switch (c->array.c.size) 213 { 214 case 3: crPackColor3dv((GLdouble *)p); break; 215 case 4: crPackColor4dv((GLdouble *)p); break; 216 } 217 break; 218 } 219 } 220 157 221 #ifdef CR_EXT_secondary_color 158 if (c->array.s.enabled) 159 { 160 p = c->array.s.p + index * c->array.s.stride; 161 switch (c->array.s.type) 222 if (array->s.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR1].enabled)) 223 { 224 p = array->s.p + index * array->s.stride; 225 226 #ifdef CR_ARB_vertex_buffer_object 227 if (array->s.buffer && array->s.buffer->data) 228 { 229 p = (unsigned char *)(array->s.buffer->data) + (unsigned long)p; 230 } 231 #endif 232 233 switch (array->s.type) 162 234 { 163 235 case GL_BYTE: … … 179 251 } 180 252 } 181 #endif 182 if (c->array.v.enabled) 183 { 184 p = c->array.v.p + (index * c->array.v.stride); 185 switch (c->array.v.type) 253 #endif // CR_EXT_secondary_color 254 255 256 #ifdef CR_EXT_fog_coord 257 if (array->f.enabled && !(vpEnabled && array->a[VERT_ATTRIB_FOG].enabled)) 258 { 259 p = array->f.p + index * array->f.stride; 260 261 #ifdef CR_ARB_vertex_buffer_object 262 if (array->f.buffer && array->f.buffer->data) 263 { 264 p = (unsigned char *)(array->f.buffer->data) + (unsigned long)p; 265 } 266 #endif 267 crPackFogCoordfEXT( *((GLfloat *) p) ); 268 } 269 #endif // CR_EXT_fog_coord 270 271 for (unit = 0 ; unit < CR_MAX_TEXTURE_UNITS ; unit++) 272 { 273 if (array->t[unit].enabled && !(vpEnabled && array->a[VERT_ATTRIB_TEX0+unit].enabled)) 274 { 275 p = array->t[unit].p + index * array->t[unit].stride; 276 277 #ifdef CR_ARB_vertex_buffer_object 278 if (array->t[unit].buffer && array->t[unit].buffer->data) 279 { 280 p = (unsigned char *)(array->t[unit].buffer->data) + (unsigned long)p; 281 } 282 #endif 283 284 switch (array->t[unit].type) 285 { 286 case GL_SHORT: 287 switch (array->t[unit].size) 288 { 289 case 1: crPackMultiTexCoord1svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 290 case 2: crPackMultiTexCoord2svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 291 case 3: crPackMultiTexCoord3svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 292 case 4: crPackMultiTexCoord4svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; 293 } 294 break; 295 case GL_INT: 296 switch (array->t[unit].size) 297 { 298 case 1: crPackMultiTexCoord1ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 299 case 2: crPackMultiTexCoord2ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 300 case 3: crPackMultiTexCoord3ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 301 case 4: crPackMultiTexCoord4ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; 302 } 303 break; 304 case GL_FLOAT: 305 switch (array->t[unit].size) 306 { 307 case 1: crPackMultiTexCoord1fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 308 case 2: crPackMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 309 case 3: crPackMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 310 case 4: crPackMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; 311 } 312 break; 313 case GL_DOUBLE: 314 switch (array->t[unit].size) 315 { 316 case 1: crPackMultiTexCoord1dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 317 case 2: crPackMultiTexCoord2dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 318 case 3: crPackMultiTexCoord3dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 319 case 4: crPackMultiTexCoord4dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; 320 } 321 break; 322 } 323 } 324 } 325 326 if (array->i.enabled) 327 { 328 p = array->i.p + index * array->i.stride; 329 330 #ifdef CR_ARB_vertex_buffer_object 331 if (array->i.buffer && array->i.buffer->data) 332 { 333 p = (unsigned char *)(array->i.buffer->data) + (unsigned long)p; 334 } 335 #endif 336 337 switch (array->i.type) 338 { 339 case GL_SHORT: crPackIndexsv((GLshort *)p); break; 340 case GL_INT: crPackIndexiv((GLint *)p); break; 341 case GL_FLOAT: crPackIndexfv((GLfloat *)p); break; 342 case GL_DOUBLE: crPackIndexdv((GLdouble *)p); break; 343 } 344 } 345 346 if (array->e.enabled) 347 { 348 p = array->e.p + index * array->e.stride; 349 350 #ifdef CR_ARB_vertex_buffer_object 351 if (array->e.buffer && array->e.buffer->data) 352 { 353 p = (unsigned char *)(array->e.buffer->data) + (unsigned long)p; 354 } 355 #endif 356 357 crPackEdgeFlagv(p); 358 } 359 360 for (attr = 1; attr < VERT_ATTRIB_MAX; attr++) 361 { 362 if (array->a[attr].enabled) 363 { 364 crPackVertexAttrib(array, attr, index); 365 } 366 } 367 368 if (array->a[VERT_ATTRIB_POS].enabled) 369 { 370 crPackVertexAttrib(array, 0, index); 371 } 372 else if (array->v.enabled) 373 { 374 p = array->v.p + index * array->v.stride; 375 376 #ifdef CR_ARB_vertex_buffer_object 377 if (array->v.buffer && array->v.buffer->data) 378 { 379 p = (unsigned char *)(array->v.buffer->data) + (unsigned long)p; 380 } 381 #endif 382 switch (array->v.type) 186 383 { 187 384 case GL_SHORT: 188 385 switch (c->array.v.size) 189 386 { 190 case 2: crPackVertex2sv BBOX_COUNT((GLshort *)p); break;191 case 3: crPackVertex3sv BBOX_COUNT((GLshort *)p); break;192 case 4: crPackVertex4sv BBOX_COUNT((GLshort *)p); break;387 case 2: crPackVertex2sv((GLshort *)p); break; 388 case 3: crPackVertex3sv((GLshort *)p); break; 389 case 4: crPackVertex4sv((GLshort *)p); break; 193 390 } 194 391 break; … … 196 393 switch (c->array.v.size) 197 394 { 198 case 2: crPackVertex2iv BBOX_COUNT((GLint *)p); break;199 case 3: crPackVertex3iv BBOX_COUNT((GLint *)p); break;200 case 4: crPackVertex4iv BBOX_COUNT((GLint *)p); break;395 case 2: crPackVertex2iv((GLint *)p); break; 396 case 3: crPackVertex3iv((GLint *)p); break; 397 case 4: crPackVertex4iv((GLint *)p); break; 201 398 } 202 399 break; … … 204 401 switch (c->array.v.size) 205 402 { 206 case 2: crPackVertex2fv BBOX_COUNT((GLfloat *)p); break;207 case 3: crPackVertex3fv BBOX_COUNT((GLfloat *)p); break;208 case 4: crPackVertex4fv BBOX_COUNT((GLfloat *)p); break;403 case 2: crPackVertex2fv((GLfloat *)p); break; 404 case 3: crPackVertex3fv((GLfloat *)p); break; 405 case 4: crPackVertex4fv((GLfloat *)p); break; 209 406 } 210 407 break; … … 212 409 switch (c->array.v.size) 213 410 { 214 case 2: crPackVertex2dv BBOX_COUNT((GLdouble *)p); break;215 case 3: crPackVertex3dv BBOX_COUNT((GLdouble *)p); break;216 case 4: crPackVertex4dv BBOX_COUNT((GLdouble *)p); break;411 case 2: crPackVertex2dv((GLdouble *)p); break; 412 case 3: crPackVertex3dv((GLdouble *)p); break; 413 case 4: crPackVertex4dv((GLdouble *)p); break; 217 414 } 218 415 break; … … 247 444 } 248 445 249 250 /* 251 * Really pack glDrawElements (for server-side vertex arrays) 252 * Note: we pack the pointer (which is actually an index into the server-side 253 * vertex buffer) and not the actual indices. 254 */ 446 static GLsizei crPackElementsIndexSize(GLenum type) 447 { 448 switch (type) 449 { 450 case GL_UNSIGNED_BYTE: 451 return sizeof(GLubyte); 452 case GL_UNSIGNED_SHORT: 453 return sizeof(GLushort); 454 case GL_UNSIGNED_INT: 455 return sizeof(GLuint); 456 default: 457 crError("Unknown type 0x%x in crPackElementsIndexSize", type); 458 return 0; 459 } 460 } 461 255 462 void PACK_APIENTRY 256 463 crPackDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) 257 464 { 258 unsigned char *data_ptr ;465 unsigned char *data_ptr, *start_ptr; 259 466 int packet_length = sizeof(int) + sizeof(mode) + sizeof(count) + sizeof(type) + sizeof(GLintptrARB); 260 data_ptr = (unsigned char *) crPackAlloc(packet_length); 261 WRITE_DATA( 0, GLenum, CR_DRAWELEMENTS_EXTEND_OPCODE ); 262 WRITE_DATA( 4, GLenum, mode ); 263 WRITE_DATA( 8, GLsizei, count); 264 WRITE_DATA( 12, GLenum, type); 265 WRITE_DATA( 16, GLsizeiptrARB, (GLsizeiptrARB) indices ); 266 crHugePacket( CR_EXTEND_OPCODE, data_ptr ); 267 crPackFree( data_ptr ); 467 GLsizei indexsize; 468 #ifdef CR_ARB_vertex_buffer_object 469 CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer; 470 packet_length += sizeof(GLboolean); 471 if (elementsBuffer && elementsBuffer->name) 472 { 473 /*@todo not sure it's possible, and not sure what to do*/ 474 if (!elementsBuffer->data) 475 { 476 crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring."); 477 return; 478 } 479 indexsize = 0; 480 } 481 else 482 #endif 483 { 484 indexsize = crPackElementsIndexSize(type); 485 } 486 487 packet_length += count * indexsize; 488 489 start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length); 490 WRITE_DATA_AI(GLenum, CR_DRAWELEMENTS_EXTEND_OPCODE ); 491 WRITE_DATA_AI(GLenum, mode ); 492 WRITE_DATA_AI(GLsizei, count); 493 WRITE_DATA_AI(GLenum, type); 494 WRITE_DATA_AI(GLsizeiptrARB, (GLsizeiptrARB) indices ); 495 #ifdef CR_ARB_vertex_buffer_object 496 WRITE_DATA_AI(GLboolean, (GLboolean) indexsize>0); 497 #endif 498 if (indexsize>0) 499 { 500 crMemcpy(data_ptr, indices, count * indexsize); 501 } 502 crHugePacket(CR_EXTEND_OPCODE, start_ptr); 503 crPackFree(start_ptr); 504 } 505 506 void PACK_APIENTRY 507 crPackDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, 508 GLenum type, const GLvoid *indices) 509 { 510 unsigned char *data_ptr, *start_ptr; 511 int packet_length = sizeof(int) + sizeof(mode) + sizeof(start) 512 + sizeof(end) + sizeof(count) + sizeof(type) + sizeof(GLintptrARB); 513 GLsizei indexsize; 514 515 #ifdef CR_ARB_vertex_buffer_object 516 CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer; 517 packet_length += sizeof(GLboolean); 518 if (elementsBuffer && elementsBuffer->name) 519 { 520 /*@todo not sure it's possible, and not sure what to do*/ 521 if (!elementsBuffer->data) 522 { 523 crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring."); 524 return; 525 } 526 indexsize = 0; 527 } 528 else 529 #endif 530 { 531 indexsize = crPackElementsIndexSize(type); 532 } 533 534 packet_length += count * indexsize; 535 536 start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length); 537 WRITE_DATA_AI(GLenum, CR_DRAWRANGEELEMENTS_EXTEND_OPCODE); 538 WRITE_DATA_AI(GLenum, mode); 539 WRITE_DATA_AI(GLuint, start); 540 WRITE_DATA_AI(GLuint, end); 541 WRITE_DATA_AI(GLsizei, count); 542 WRITE_DATA_AI(GLenum, type); 543 WRITE_DATA_AI(GLsizeiptrARB, (GLsizeiptr) indices); 544 #ifdef CR_ARB_vertex_buffer_object 545 WRITE_DATA_AI(GLboolean, (GLboolean) indexsize>0); 546 #endif 547 if (indexsize>0) 548 { 549 crMemcpy(data_ptr, indices, count * indexsize); 550 } 551 crHugePacket(CR_EXTEND_OPCODE, start_ptr); 552 crPackFree(start_ptr); 268 553 } 269 554 … … 278 563 { 279 564 int i; 565 GLubyte *p = (GLubyte *)indices; 566 #ifdef CR_ARB_vertex_buffer_object 567 CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer; 568 #endif 280 569 281 570 if (count < 0) … … 302 591 } 303 592 593 #ifdef CR_ARB_vertex_buffer_object 594 if (elementsBuffer && elementsBuffer->data) 595 { 596 p = (unsigned char *)(elementsBuffer->data) + (unsigned long)p; 597 } 598 #endif 599 304 600 if (mode != 999) 305 601 crPackBegin(mode); 306 602 307 switch (type) { 308 case GL_UNSIGNED_BYTE: 309 { 310 const GLubyte *p = (const GLubyte *) indices; 311 for (i = 0; i < count; i++) 312 crPackExpandArrayElement(p[i], c); 313 } 314 break; 315 case GL_UNSIGNED_SHORT: 316 { 317 const GLushort *p = (const GLushort *) indices; 603 //crDebug("crPackExpandDrawElements mode:0x%x, count:%d, type:0x%x", mode, count, type); 604 605 switch (type) 606 { 607 case GL_UNSIGNED_BYTE: 318 608 for (i=0; i<count; i++) 319 crPackExpandArrayElement(p[i], c); 320 } 321 break; 322 case GL_UNSIGNED_INT: 323 { 324 const GLuint *p = (const GLuint *) indices; 325 for (i = 0; i < count; i++) 326 crPackExpandArrayElement(p[i], c); 327 } 328 break; 329 default: 330 __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, 331 "crPackDrawElements(bad type)"); 332 break; 609 { 610 crPackExpandArrayElement((GLint) *p++, c); 611 } 612 break; 613 case GL_UNSIGNED_SHORT: 614 for (i=0; i<count; i++) 615 { 616 crPackExpandArrayElement((GLint) * (GLushort *) p, c); 617 p+=sizeof (GLushort); 618 } 619 break; 620 case GL_UNSIGNED_INT: 621 for (i=0; i<count; i++) 622 { 623 crPackExpandArrayElement((GLint) * (GLuint *) p, c); 624 p+=sizeof (GLuint); 625 } 626 break; 627 default: 628 crError( "this can't happen: array_spu.self.DrawElements" ); 629 break; 333 630 } 334 631 … … 379 676 380 677 /* 381 * Really pack glDrawRangeElements (for server-side vertex arrays)382 * Note: we pack the pointer (which is actually an index into the server-side383 * vertex buffer) and not the actual indices.384 */385 void PACK_APIENTRY386 crPackDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,387 GLenum type, const GLvoid *indices)388 {389 unsigned char *data_ptr;390 int packet_length = sizeof(int) + sizeof(mode) + sizeof(start)391 + sizeof(end) + sizeof(count) + sizeof(type) + sizeof(GLintptrARB);392 393 data_ptr = (unsigned char *) crPackAlloc(packet_length);394 WRITE_DATA( 0, GLenum, CR_DRAWRANGEELEMENTS_EXTEND_OPCODE );395 WRITE_DATA( 4, GLenum, mode );396 WRITE_DATA( 8, GLuint, start );397 WRITE_DATA( 12, GLuint, end );398 WRITE_DATA( 16, GLsizei, count );399 WRITE_DATA( 20, GLenum, type );400 WRITE_DATA( 24, GLsizeiptrARB, (GLsizeiptr) indices );401 crHugePacket( CR_EXTEND_OPCODE, data_ptr );402 crPackFree( data_ptr );403 }404 405 406 /*407 678 * glDrawRangeElements, expanded into crPackBegin/Vertex/End/etc. 408 679 */ … … 410 681 crPackExpandDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c) 411 682 { 412 int i; 413 GLubyte *p = (GLubyte *)indices; 414 415 (void) end; 416 417 if (count < 0) 418 { 419 __PackError(__LINE__, __FILE__, GL_INVALID_VALUE, "crPackDrawRangeElements(negative count)"); 683 if (start>end) 684 { 685 crWarning("crPackExpandDrawRangeElements start>end (%d>%d)", start, end); 420 686 return; 421 687 } 422 688 423 if (mode > GL_POLYGON) 424 { 425 __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, "crPackDrawRangeElements(bad mode)"); 426 return; 427 } 428 429 if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT) 430 { 431 __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, "crPackDrawRangeElements(bad type)"); 432 return; 433 } 434 435 crPackBegin(mode); 436 switch (type) 437 { 438 case GL_UNSIGNED_BYTE: 439 for (i=0; i<count; i++) 440 { 441 crPackExpandArrayElement((GLint) *p++, c); 442 } 443 break; 444 case GL_UNSIGNED_SHORT: 445 for (i=0; i<count; i++) 446 { 447 crPackExpandArrayElement((GLint) * (GLushort *) p, c); 448 p += sizeof(GLushort); 449 } 450 break; 451 case GL_UNSIGNED_INT: 452 for (i=0; i<count; i++) 453 { 454 crPackExpandArrayElement((GLint) * (GLuint *) p, c); 455 p += sizeof(GLuint); 456 } 457 break; 458 default: 459 crError( "this can't happen: crPackDrawRangeElements" ); 460 break; 461 } 462 crPackEnd(); 689 crPackExpandDrawElements(mode, count, type, indices, c); 463 690 } 464 691 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c
r20975 r21308 172 172 DIRTY(bb->elementsBinding, g->neg_bitid); 173 173 } 174 /* XXXcheck bindings with the vertex arrays */174 /* @todo check bindings with the vertex arrays */ 175 175 176 176 crHashtableDelete(b->buffers, buffers[i], crStateFreeBufferObject); -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_client.c
r15532 r21308 1312 1312 } 1313 1313 1314 /*Returns if the given clientpointer could be used on server side directly*/ 1315 #define CRSTATE_IS_SERVER_CP(cp) (!(cp).enabled || !(cp).p || ((cp).buffer && (cp).buffer->name)) 1316 1317 static crStateDumpClientPointer(CRClientPointer *cp, const char *name, int i) 1318 { 1319 if (i<0 && cp->enabled) 1320 { 1321 crDebug("CP(%s): enabled:%d ptr:%p buffer:%p buffer.name:%i %s", 1322 name, cp->enabled, cp->p, cp->buffer, cp->buffer? cp->buffer->name:-1, 1323 CRSTATE_IS_SERVER_CP(*cp) ? "":"!FAIL!"); 1324 } 1325 else if (0==i || cp->enabled) 1326 { 1327 crDebug("CP(%s%i): enabled:%d ptr:%p buffer:%p buffer.name:%i %s", 1328 name, i, cp->enabled, cp->p, cp->buffer, cp->buffer? cp->buffer->name:-1, 1329 CRSTATE_IS_SERVER_CP(*cp) ? "":"!FAIL!"); 1330 } 1331 } 1314 1332 1315 1333 /* … … 1323 1341 CRClientState *c = &(g->client); 1324 1342 int i; 1325 1326 if (!c->array.v.enabled) 1327 return GL_FALSE; 1328 1329 if (c->array.v.enabled && (!c->array.v.buffer || !c->array.v.buffer->name)) 1330 return GL_FALSE; 1331 1332 if (c->array.n.enabled && (!c->array.n.buffer || !c->array.n.buffer->name)) 1333 return GL_FALSE; 1334 1335 if (c->array.c.enabled && (!c->array.c.buffer || !c->array.c.buffer->name)) 1336 return GL_FALSE; 1337 1338 if (c->array.i.enabled && (!c->array.i.buffer || !c->array.i.buffer->name)) 1339 return GL_FALSE; 1343 GLboolean res; 1344 1345 res = CRSTATE_IS_SERVER_CP(c->array.v) 1346 && CRSTATE_IS_SERVER_CP(c->array.n) 1347 && CRSTATE_IS_SERVER_CP(c->array.c) 1348 && CRSTATE_IS_SERVER_CP(c->array.i) 1349 && CRSTATE_IS_SERVER_CP(c->array.e) 1350 && CRSTATE_IS_SERVER_CP(c->array.s) 1351 && CRSTATE_IS_SERVER_CP(c->array.f); 1340 1352 1341 1353 for (i = 0; (unsigned int)i < g->limits.maxTextureUnits; i++) 1342 if (c->array.t[i].enabled && (!c->array.t[i].buffer || !c->array.t[i].buffer->name)) 1343 return GL_FALSE; 1344 1345 if (c->array.e.enabled && (!c->array.e.buffer || !c->array.e.buffer->name)) 1346 return GL_FALSE; 1347 1348 if (c->array.s.enabled && (!c->array.s.buffer || !c->array.s.buffer->name)) 1349 return GL_FALSE; 1350 1351 if (c->array.f.enabled && (!c->array.f.buffer || !c->array.f.buffer->name)) 1352 return GL_FALSE; 1354 if (!CRSTATE_IS_SERVER_CP(c->array.t[i])) 1355 { 1356 res = GL_FALSE; 1357 break; 1358 } 1353 1359 1354 1360 for (i = 0; (unsigned int)i < g->limits.maxVertexProgramAttribs; i++) 1355 if (c->array.a[i].enabled && (!c->array.a[i].buffer || !c->array.a[i].buffer->name)) 1356 return GL_FALSE; 1357 1358 return GL_TRUE; 1361 if (!CRSTATE_IS_SERVER_CP(c->array.a[i])) 1362 { 1363 res = GL_FALSE; 1364 break; 1365 } 1366 1367 if (!res) 1368 { 1369 crStateDumpClientPointer(&c->array.v, "v", -1); 1370 crStateDumpClientPointer(&c->array.n, "n", -1); 1371 crStateDumpClientPointer(&c->array.c, "c", -1); 1372 crStateDumpClientPointer(&c->array.i, "i", -1); 1373 crStateDumpClientPointer(&c->array.e, "e", -1); 1374 crStateDumpClientPointer(&c->array.s, "s", -1); 1375 crStateDumpClientPointer(&c->array.f, "f", -1); 1376 for (i = 0; (unsigned int)i < g->limits.maxTextureUnits; i++) 1377 crStateDumpClientPointer(&c->array.t[i], "tex", i); 1378 for (i = 0; (unsigned int)i < g->limits.maxVertexProgramAttribs; i++) 1379 crStateDumpClientPointer(&c->array.a[i], "attrib", i); 1380 crDebug("crStateUseServerArrays->%d", res); 1381 } 1382 1383 return res; 1359 1384 #else 1360 1385 return GL_FALSE;
Note:
See TracChangeset
for help on using the changeset viewer.