~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/crOpenGL/pack/packspu_client.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
    crStateVertexAttribPointerNV( index, size, type, stride, pointer );
137
137
}
138
138
 
 
139
void PACKSPU_APIENTRY packspu_IndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
 
140
{
 
141
#if CR_ARB_vertex_buffer_object
 
142
    GET_CONTEXT(ctx);
 
143
    if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
 
144
        if (pack_spu.swap)
 
145
            crPackIndexPointerSWAP( type, stride, pointer );
 
146
        else
 
147
            crPackIndexPointer( type, stride, pointer );
 
148
    }
 
149
#endif
 
150
    crStateIndexPointer(type, stride, pointer);
 
151
}
 
152
 
139
153
void PACKSPU_APIENTRY packspu_GetPointerv( GLenum pname, GLvoid **params )
140
154
{
141
155
    crStateGetPointerv( pname, params );
152
166
            crPackInterleavedArrays( format, stride, pointer );
153
167
    }
154
168
#endif
 
169
 
 
170
    /*crDebug("packspu_InterleavedArrays");*/
 
171
 
155
172
    crStateInterleavedArrays( format, stride, pointer );
156
173
}
157
174
 
159
176
void PACKSPU_APIENTRY
160
177
packspu_ArrayElement( GLint index )
161
178
{
 
179
/*@todo cash guest/host pointers calculation and use appropriate path here without crStateUseServerArrays call*/
 
180
#if 1
162
181
    GLboolean serverArrays = GL_FALSE;
163
182
 
164
183
#if CR_ARB_vertex_buffer_object
165
184
    GET_CONTEXT(ctx);
 
185
    /*crDebug("packspu_ArrayElement index:%i", index);*/
166
186
    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
167
187
        serverArrays = crStateUseServerArrays();
168
188
#endif
169
189
 
170
190
    if (serverArrays) {
 
191
        GET_CONTEXT(ctx);
 
192
        CRClientState *clientState = &(ctx->clientState->client);
 
193
 
 
194
        /*Note the comment in packspu_LockArraysEXT*/
 
195
        if (clientState->array.locked && !clientState->array.synced)
 
196
        {
 
197
            crPackLockArraysEXT(clientState->array.lockFirst, clientState->array.lockCount);
 
198
            clientState->array.synced = GL_TRUE;
 
199
        }
 
200
 
171
201
        /* Send the DrawArrays command over the wire */
172
202
        if (pack_spu.swap)
173
203
            crPackArrayElementSWAP( index );
183
213
        else
184
214
            crPackExpandArrayElement( index, clientState );
185
215
    }
 
216
#else
 
217
    GET_CONTEXT(ctx);
 
218
    CRClientState *clientState = &(ctx->clientState->client);
 
219
    crPackExpandArrayElement(index, clientState);
 
220
#endif
186
221
}
187
222
 
188
223
 
193
228
 
194
229
#if CR_ARB_vertex_buffer_object
195
230
    GET_CONTEXT(ctx);
 
231
    /*crDebug("DrawElements count=%d, indices=%p", count, indices);*/
196
232
    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
197
233
        serverArrays = crStateUseServerArrays();
198
234
#endif
199
235
 
200
236
    if (serverArrays) {
 
237
        GET_CONTEXT(ctx);
 
238
        CRClientState *clientState = &(ctx->clientState->client);
 
239
 
 
240
        /*Note the comment in packspu_LockArraysEXT*/
 
241
        if (clientState->array.locked && !clientState->array.synced)
 
242
        {
 
243
            crPackLockArraysEXT(clientState->array.lockFirst, clientState->array.lockCount);
 
244
            clientState->array.synced = GL_TRUE;
 
245
        }
 
246
        
201
247
        /* Send the DrawArrays command over the wire */
202
248
        if (pack_spu.swap)
203
249
            crPackDrawElementsSWAP( mode, count, type, indices );
211
257
        if (pack_spu.swap)
212
258
            crPackExpandDrawElementsSWAP( mode, count, type, indices, clientState );
213
259
        else
 
260
        {
 
261
            //packspu_Begin(mode);
214
262
            crPackExpandDrawElements( mode, count, type, indices, clientState );
 
263
            //packspu_End();
 
264
        }
215
265
    }
216
266
}
217
267
 
223
273
 
224
274
#if CR_ARB_vertex_buffer_object
225
275
    GET_CONTEXT(ctx);
 
276
    /*crDebug("DrawRangeElements count=%d", count);*/
226
277
    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
227
278
         serverArrays = crStateUseServerArrays();
228
279
#endif
229
280
 
230
281
    if (serverArrays) {
 
282
        GET_CONTEXT(ctx);
 
283
        CRClientState *clientState = &(ctx->clientState->client);
 
284
 
 
285
        /*Note the comment in packspu_LockArraysEXT*/
 
286
        if (clientState->array.locked && !clientState->array.synced)
 
287
        {
 
288
            crPackLockArraysEXT(clientState->array.lockFirst, clientState->array.lockCount);
 
289
            clientState->array.synced = GL_TRUE;
 
290
        }
 
291
 
231
292
        /* Send the DrawRangeElements command over the wire */
232
293
        if (pack_spu.swap)
233
294
            crPackDrawRangeElementsSWAP( mode, start, end, count, type, indices );
241
302
        if (pack_spu.swap)
242
303
            crPackExpandDrawRangeElementsSWAP( mode, start, end, count, type, indices, clientState );
243
304
        else
 
305
        {
244
306
            crPackExpandDrawRangeElements( mode, start, end, count, type, indices, clientState );
 
307
        }
245
308
    }
246
309
}
247
310
 
253
316
 
254
317
#if CR_ARB_vertex_buffer_object
255
318
    GET_CONTEXT(ctx);
 
319
    /*crDebug("DrawArrays count=%d", count);*/
256
320
    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
257
321
         serverArrays = crStateUseServerArrays();
258
322
#endif
259
323
 
260
324
    if (serverArrays) {
 
325
        GET_CONTEXT(ctx);
 
326
        CRClientState *clientState = &(ctx->clientState->client);
 
327
 
 
328
        /*Note the comment in packspu_LockArraysEXT*/
 
329
        if (clientState->array.locked && !clientState->array.synced)
 
330
        {
 
331
            crPackLockArraysEXT(clientState->array.lockFirst, clientState->array.lockCount);
 
332
            clientState->array.synced = GL_TRUE;
 
333
        }
 
334
 
261
335
        /* Send the DrawArrays command over the wire */
262
336
        if (pack_spu.swap)
263
337
            crPackDrawArraysSWAP( mode, first, count );
301
375
 
302
376
void PACKSPU_APIENTRY packspu_EnableClientState( GLenum array )
303
377
{
304
 
    crStateEnableClientState( array );
 
378
    crStateEnableClientState(array);
 
379
    crPackEnableClientState(array);
305
380
}
306
381
 
307
382
void PACKSPU_APIENTRY packspu_DisableClientState( GLenum array )
308
383
{
309
 
    crStateDisableClientState( array );
 
384
    crStateDisableClientState(array);
 
385
    crPackDisableClientState(array);
310
386
}
311
387
 
312
388
void PACKSPU_APIENTRY packspu_ClientActiveTextureARB( GLenum texUnit )
313
389
{
314
 
    crStateClientActiveTextureARB( texUnit );
315
 
    /* XXX also send to server for texcoord arrays? */
316
 
}
317
 
 
 
390
    crStateClientActiveTextureARB(texUnit);
 
391
    crPackClientActiveTextureARB(texUnit);
 
392
}
 
393
 
 
394
void PACKSPU_APIENTRY packspu_EnableVertexAttribArrayARB(GLuint index)
 
395
{
 
396
    crStateEnableVertexAttribArrayARB(index);
 
397
    crPackEnableVertexAttribArrayARB(index);
 
398
}
 
399
 
 
400
 
 
401
void PACKSPU_APIENTRY packspu_DisableVertexAttribArrayARB(GLuint index)
 
402
{
 
403
    crStateDisableVertexAttribArrayARB(index);
 
404
    crPackDisableVertexAttribArrayARB(index);
 
405
}
318
406
 
319
407
void PACKSPU_APIENTRY packspu_Enable( GLenum cap )
320
408
{
321
 
    switch (cap) {
322
 
    case GL_VERTEX_ARRAY:
323
 
    case GL_NORMAL_ARRAY:
324
 
    case GL_COLOR_ARRAY:
325
 
    case GL_INDEX_ARRAY:
326
 
    case GL_TEXTURE_COORD_ARRAY:
327
 
    case GL_EDGE_FLAG_ARRAY:
328
 
    case GL_FOG_COORDINATE_ARRAY_EXT:
329
 
    case GL_SECONDARY_COLOR_ARRAY_EXT:
330
 
#if CR_NV_vertex_program
331
 
    case GL_VERTEX_ATTRIB_ARRAY0_NV:
332
 
    case GL_VERTEX_ATTRIB_ARRAY1_NV:
333
 
    case GL_VERTEX_ATTRIB_ARRAY2_NV:
334
 
    case GL_VERTEX_ATTRIB_ARRAY3_NV:
335
 
    case GL_VERTEX_ATTRIB_ARRAY4_NV:
336
 
    case GL_VERTEX_ATTRIB_ARRAY5_NV:
337
 
    case GL_VERTEX_ATTRIB_ARRAY6_NV:
338
 
    case GL_VERTEX_ATTRIB_ARRAY7_NV:
339
 
    case GL_VERTEX_ATTRIB_ARRAY8_NV:
340
 
    case GL_VERTEX_ATTRIB_ARRAY9_NV:
341
 
    case GL_VERTEX_ATTRIB_ARRAY10_NV:
342
 
    case GL_VERTEX_ATTRIB_ARRAY11_NV:
343
 
    case GL_VERTEX_ATTRIB_ARRAY12_NV:
344
 
    case GL_VERTEX_ATTRIB_ARRAY13_NV:
345
 
    case GL_VERTEX_ATTRIB_ARRAY14_NV:
346
 
    case GL_VERTEX_ATTRIB_ARRAY15_NV:
347
 
#endif /* CR_NV_vertex_program */
348
 
        crStateEnableClientState(cap);
349
 
        break;
350
 
    default:
351
 
        ;
352
 
    }
 
409
    crStateEnable(cap);
353
410
 
354
411
    if (pack_spu.swap)
355
412
        crPackEnableSWAP(cap);
360
417
 
361
418
void PACKSPU_APIENTRY packspu_Disable( GLenum cap )
362
419
{
363
 
    switch (cap) {
364
 
    case GL_VERTEX_ARRAY:
365
 
    case GL_NORMAL_ARRAY:
366
 
    case GL_COLOR_ARRAY:
367
 
    case GL_INDEX_ARRAY:
368
 
    case GL_TEXTURE_COORD_ARRAY:
369
 
    case GL_EDGE_FLAG_ARRAY:
370
 
    case GL_FOG_COORDINATE_ARRAY_EXT:
371
 
    case GL_SECONDARY_COLOR_ARRAY_EXT:
372
 
#if CR_NV_vertex_program
373
 
    case GL_VERTEX_ATTRIB_ARRAY0_NV:
374
 
    case GL_VERTEX_ATTRIB_ARRAY1_NV:
375
 
    case GL_VERTEX_ATTRIB_ARRAY2_NV:
376
 
    case GL_VERTEX_ATTRIB_ARRAY3_NV:
377
 
    case GL_VERTEX_ATTRIB_ARRAY4_NV:
378
 
    case GL_VERTEX_ATTRIB_ARRAY5_NV:
379
 
    case GL_VERTEX_ATTRIB_ARRAY6_NV:
380
 
    case GL_VERTEX_ATTRIB_ARRAY7_NV:
381
 
    case GL_VERTEX_ATTRIB_ARRAY8_NV:
382
 
    case GL_VERTEX_ATTRIB_ARRAY9_NV:
383
 
    case GL_VERTEX_ATTRIB_ARRAY10_NV:
384
 
    case GL_VERTEX_ATTRIB_ARRAY11_NV:
385
 
    case GL_VERTEX_ATTRIB_ARRAY12_NV:
386
 
    case GL_VERTEX_ATTRIB_ARRAY13_NV:
387
 
    case GL_VERTEX_ATTRIB_ARRAY14_NV:
388
 
    case GL_VERTEX_ATTRIB_ARRAY15_NV:
389
 
#endif /* CR_NV_vertex_program */
390
 
        crStateDisableClientState(cap);
391
 
        break;
392
 
    default:
393
 
        ;
394
 
    }
 
420
    crStateDisable(cap);
395
421
 
396
422
    if (pack_spu.swap)
397
423
        crPackDisableSWAP(cap);
399
425
        crPackDisable(cap);
400
426
}
401
427
 
 
428
GLboolean PACKSPU_APIENTRY packspu_IsEnabled(GLenum cap)
 
429
{
 
430
    GLboolean res = crStateIsEnabled(cap);
 
431
#ifdef DEBUG
 
432
    {    
 
433
        GET_THREAD(thread);
 
434
            int writeback = 1;
 
435
            GLboolean return_val = (GLboolean) 0;
 
436
        crPackIsEnabled(cap, &return_val, &writeback);
 
437
            packspuFlush( (void *) thread );
 
438
            while (writeback)
 
439
                  crNetRecv();
 
440
        CRASSERT(return_val==res);
 
441
    }
 
442
#endif
 
443
 
 
444
    return res;
 
445
}
402
446
 
403
447
void PACKSPU_APIENTRY packspu_PushClientAttrib( GLbitfield mask )
404
448
{
405
449
    crStatePushClientAttrib(mask);
 
450
    crPackPushClientAttrib(mask);
406
451
}
407
452
 
408
453
void PACKSPU_APIENTRY packspu_PopClientAttrib( void )
409
454
{
410
455
    crStatePopClientAttrib();
 
456
    crPackPopClientAttrib();
 
457
}
 
458
 
 
459
void PACKSPU_APIENTRY packspu_LockArraysEXT(GLint first, GLint count)
 
460
{
 
461
    if (first>=0 && count>0)
 
462
    {
 
463
        crStateLockArraysEXT(first, count);
 
464
        /*Note: this is a workaround for quake3 based apps.
 
465
          It's modifying vertex data between glLockArraysEXT and glDrawElements calls,
 
466
          so we'd pass data to host right before the glDrawSomething call.
 
467
        */
 
468
        /*crPackLockArraysEXT(first, count);*/
 
469
    } 
 
470
    else crDebug("Ignoring packspu_LockArraysEXT: first:%i, count:%i", first, count);
 
471
}
 
472
 
 
473
void PACKSPU_APIENTRY packspu_UnlockArraysEXT()
 
474
{
 
475
    crStateUnlockArraysEXT();
 
476
    crPackUnlockArraysEXT();
411
477
}