VirtualBox

Ignore:
Timestamp:
Jul 7, 2009 10:49:52 AM (16 years ago)
Author:
vboxsync
Message:

crOpenGL: use host side VBO when possible

Location:
trunk/src/VBox/Additions/common/crOpenGL
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu.c

    r20970 r21308  
    478478    }
    479479#endif
     480    //crDebug("arrayspu_DrawElements mode:0x%x, count:%d, type:0x%x", mode, count, type);
     481   
    480482
    481483    array_spu.self.Begin(mode);
     
    521523static void ARRAYSPU_APIENTRY arrayspu_ColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
    522524{
    523     crStateColorPointer( size, type, stride, pointer );
     525    crStateColorPointer(size, type, stride, pointer);
     526    array_spu.child.ColorPointer(size, type, stride, pointer);
    524527}
    525528
    526529static void ARRAYSPU_APIENTRY arrayspu_SecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
    527530{
    528     crStateSecondaryColorPointerEXT( size, type, stride, pointer );
     531    crStateSecondaryColorPointerEXT(size, type, stride, pointer);
     532    array_spu.child.SecondaryColorPointerEXT(size, type, stride, pointer);
    529533}
    530534
    531535static void ARRAYSPU_APIENTRY arrayspu_VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
    532536{
    533     crStateVertexPointer( size, type, stride, pointer );
     537    crStateVertexPointer(size, type, stride, pointer);
     538    array_spu.child.VertexPointer(size, type, stride, pointer);
    534539}
    535540
    536541static void ARRAYSPU_APIENTRY arrayspu_TexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
    537542{
    538     crStateTexCoordPointer( size, type, stride, pointer );
     543    crStateTexCoordPointer(size, type, stride, pointer);
     544    array_spu.child.TexCoordPointer(size, type, stride, pointer);
    539545}
    540546
    541547static void ARRAYSPU_APIENTRY arrayspu_NormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
    542548{
    543     crStateNormalPointer( type, stride, pointer );
     549    crStateNormalPointer(type, stride, pointer);
     550    array_spu.child.NormalPointer(type, stride, pointer);
    544551}
    545552
    546553static void ARRAYSPU_APIENTRY arrayspu_IndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
    547554{
    548     crStateIndexPointer( type, stride, pointer );
     555    crStateIndexPointer(type, stride, pointer);
     556    array_spu.child.IndexPointer(type, stride, pointer);
    549557}
    550558
    551559static void ARRAYSPU_APIENTRY arrayspu_EdgeFlagPointer( GLsizei stride, const GLvoid *pointer )
    552560{
    553     crStateEdgeFlagPointer( stride, pointer );
     561    crStateEdgeFlagPointer(stride, pointer);
     562    array_spu.child.EdgeFlagPointer(stride, pointer);
    554563}
    555564
    556565static void ARRAYSPU_APIENTRY arrayspu_VertexAttribPointerNV( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer )
    557566{
    558     crStateVertexAttribPointerNV( index, size, type, stride, pointer );
     567    crStateVertexAttribPointerNV(index, size, type, stride, pointer);
     568    array_spu.child.VertexAttribPointerNV(index, size, type, stride, pointer);
    559569}
    560570
    561571static void ARRAYSPU_APIENTRY arrayspu_FogCoordPointerEXT( GLenum type, GLsizei stride, const GLvoid *pointer )
    562572{
    563     crStateFogCoordPointerEXT( type, stride, pointer );
     573    crStateFogCoordPointerEXT(type, stride, pointer);
     574    array_spu.child.FogCoordPointerEXT(type, stride, pointer);
    564575}
    565576
    566577static void ARRAYSPU_APIENTRY arrayspu_GetPointerv( GLenum pname, GLvoid **params )
    567578{
    568     crStateGetPointerv( pname, params );
     579    crStateGetPointerv(pname, params);
    569580}
    570581
    571582static void ARRAYSPU_APIENTRY arrayspu_EnableClientState( GLenum array )
    572583{
    573     crStateEnableClientState( array );
     584    crStateEnableClientState(array);
     585    array_spu.child.EnableClientState(array);
    574586}
    575587
    576588static void ARRAYSPU_APIENTRY arrayspu_DisableClientState( GLenum array )
    577589{
    578     crStateDisableClientState( array );
     590    crStateDisableClientState(array);
     591    array_spu.child.DisableClientState(array);
    579592}
    580593
    581594static void ARRAYSPU_APIENTRY arrayspu_ClientActiveTextureARB( GLenum texture )
    582595{
    583     crStateClientActiveTextureARB( texture );
     596    crStateClientActiveTextureARB(texture);
     597    array_spu.child.ClientActiveTextureARB(texture);
    584598}
    585599
     
    662676                                const GLvoid *pointer)
    663677{
    664     crStateVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
     678    crStateVertexAttribPointerARB(index, size, type, normalized, stride, pointer);
     679    array_spu.child.VertexAttribPointerARB(index, size, type, normalized, stride, pointer);
    665680}
    666681
     
    703718arrayspu_GenBuffersARB( GLsizei n, GLuint * buffers )
    704719{
    705     crStateGenBuffersARB(n, buffers);
     720    array_spu.child.GenBuffersARB(n, buffers);
    706721}
    707722
     
    710725{
    711726    crStateDeleteBuffersARB(n, buffers);
     727    array_spu.child.DeleteBuffersARB(n, buffers);
    712728}
    713729
     
    716732{
    717733    crStateBindBufferARB(target, buffer);
     734    array_spu.child.BindBufferARB(target, buffer);
    718735}
    719736
     
    721738arrayspu_IsBufferARB (GLuint buffer)
    722739{
    723     return crStateIsBufferARB(buffer);
     740    return array_spu.child.IsBufferARB(buffer);
    724741}
    725742
     
    728745{
    729746    crStateBufferDataARB(target, size, data, usage);
     747    array_spu.child.BufferDataARB(target, size, data, usage);
    730748}
    731749
     
    735753{
    736754    crStateBufferSubDataARB(target, offset, size, data);
     755    array_spu.child.BufferSubDataARB(target, offset, size, data);
    737756}
    738757
     
    752771arrayspu_UnmapBufferARB(GLenum target)
    753772{
    754     return crStateUnmapBufferARB(target);
     773    crStateUnmapBufferARB(target);
     774    return array_spu.child.UnmapBufferARB(target);
    755775}
    756776
  • trunk/src/VBox/Additions/common/crOpenGL/load.c

    r20616 r21308  
    589589#endif
    590590
    591     strcpy(response, "3 0 array 1 feedback 2 pack");
     591    strcpy(response, "2 0 feedback 1 pack");
    592592    spuchain = crStrSplit( response, " " );
    593593    num_spus = crStrToInt( spuchain[0] );
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c

    r20083 r21308  
    1515packspu_MapBufferARB( GLenum target, GLenum access )
    1616{
    17     GLint size = -1;
    1817    GET_CONTEXT(ctx);
    1918    void *buffer;
     19#if 0
    2020    CRBufferObject *bufObj;
     21    GLint size = -1;
    2122
    2223    (void) crStateMapBufferARB( target, access );
     
    5253     */
    5354    packspu_GetBufferSubDataARB(target, 0, bufObj->size, buffer);
     55#else
     56    CRASSERT(GL_TRUE == ctx->clientState->bufferobject.retainBufferData);
     57    buffer = crStateMapBufferARB(target, access);
     58#endif
    5459
    5560    return buffer;
     61}
     62
     63void PACKSPU_APIENTRY packspu_GetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data )
     64{
     65    crStateGetBufferSubDataARB(target, offset, size, data);
    5666}
    5767
     
    6070packspu_UnmapBufferARB( GLenum target )
    6171{
     72    GET_CONTEXT(ctx);
     73
     74#if 0
    6275    CRBufferObject *bufObj;
    63     GET_CONTEXT(ctx);
    6476
    6577    if (target == GL_ARRAY_BUFFER_ARB) {
     
    7688    /* free the buffer / unmap it */
    7789    crFree(bufObj->pointer);
     90#endif
    7891
    7992    crStateUnmapBufferARB( target );
     
    8497
    8598void PACKSPU_APIENTRY
    86 packspu_BufferDataARB( GLenum target, GLsizeiptrARB size,
    87                                              const GLvoid * data, GLenum usage )
     99packspu_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)
    88100{
     101    /*crDebug("packspu_BufferDataARB size:%d", size);*/
    89102    crStateBufferDataARB(target, size, data, usage);
    90103    crPackBufferDataARB(target, size, data, usage);
     104}
     105
     106void PACKSPU_APIENTRY
     107packspu_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
     108{
     109    /*crDebug("packspu_BufferSubDataARB size:%d", size);*/
     110    crStateBufferSubDataARB(target, offset, size, data);
     111    crPackBufferSubDataARB(target, offset, size, data);
    91112}
    92113
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c

    r20083 r21308  
    153153    }
    154154#endif
     155
     156    /*crDebug("packspu_InterleavedArrays");*/
     157
    155158    crStateInterleavedArrays( format, stride, pointer );
    156159}
     
    160163packspu_ArrayElement( GLint index )
    161164{
     165#if 0
    162166    GLboolean serverArrays = GL_FALSE;
    163167
    164168#if CR_ARB_vertex_buffer_object
    165169    GET_CONTEXT(ctx);
     170    /*crDebug("packspu_ArrayElement index:%i", index);*/
    166171    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
    167172        serverArrays = crStateUseServerArrays();
     
    184189            crPackExpandArrayElement( index, clientState );
    185190    }
     191#else
     192    GET_CONTEXT(ctx);
     193    CRClientState *clientState = &(ctx->clientState->client);
     194    crPackExpandArrayElement(index, clientState);
     195#endif
    186196}
    187197
     
    194204#if CR_ARB_vertex_buffer_object
    195205    GET_CONTEXT(ctx);
     206    /*crDebug("DrawElements count=%d, indices=%p", count, indices);*/
    196207    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
    197208        serverArrays = crStateUseServerArrays();
     
    212223            crPackExpandDrawElementsSWAP( mode, count, type, indices, clientState );
    213224        else
     225        {
     226            //packspu_Begin(mode);
    214227            crPackExpandDrawElements( mode, count, type, indices, clientState );
     228            //packspu_End();
     229        }
    215230    }
    216231}
     
    224239#if CR_ARB_vertex_buffer_object
    225240    GET_CONTEXT(ctx);
     241    /*crDebug("DrawRangeElements count=%d", count);*/
    226242    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
    227243         serverArrays = crStateUseServerArrays();
     
    242258            crPackExpandDrawRangeElementsSWAP( mode, start, end, count, type, indices, clientState );
    243259        else
     260        {
    244261            crPackExpandDrawRangeElements( mode, start, end, count, type, indices, clientState );
     262        }
    245263    }
    246264}
     
    254272#if CR_ARB_vertex_buffer_object
    255273    GET_CONTEXT(ctx);
     274    /*crDebug("DrawArrays count=%d", count);*/
    256275    if (ctx->clientState->extensions.ARB_vertex_buffer_object)
    257276         serverArrays = crStateUseServerArrays();
     
    302321void PACKSPU_APIENTRY packspu_EnableClientState( GLenum array )
    303322{
    304     crStateEnableClientState( array );
     323    crStateEnableClientState(array);
     324    crPackEnableClientState(array);
    305325}
    306326
    307327void PACKSPU_APIENTRY packspu_DisableClientState( GLenum array )
    308328{
    309     crStateDisableClientState( array );
     329    crStateDisableClientState(array);
     330    crPackDisableClientState(array);
    310331}
    311332
    312333void PACKSPU_APIENTRY packspu_ClientActiveTextureARB( GLenum texUnit )
    313334{
    314     crStateClientActiveTextureARB( texUnit );
    315     /* XXX also send to server for texcoord arrays? */
    316 }
    317 
     335    crStateClientActiveTextureARB(texUnit);
     336    crPackClientActiveTextureARB(texUnit);
     337}
     338
     339void PACKSPU_APIENTRY packspu_EnableVertexAttribArrayARB(GLuint index)
     340{
     341    crStateEnableVertexAttribArrayARB(index);
     342    crPackEnableVertexAttribArrayARB(index);
     343}
     344
     345
     346void PACKSPU_APIENTRY packspu_DisableVertexAttribArrayARB(GLuint index)
     347{
     348    crStateDisableVertexAttribArrayARB(index);
     349    crPackDisableVertexAttribArrayARB(index);
     350}
    318351
    319352void PACKSPU_APIENTRY packspu_Enable( GLenum cap )
    320353{
    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     }
     354    crStateEnable(cap);
    353355
    354356    if (pack_spu.swap)
     
    361363void PACKSPU_APIENTRY packspu_Disable( GLenum cap )
    362364{
    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     }
     365    crStateDisable(cap);
    395366
    396367    if (pack_spu.swap)
     
    400371}
    401372
     373GLboolean PACKSPU_APIENTRY packspu_IsEnabled(GLenum cap)
     374{
     375    GLboolean res = crStateIsEnabled(cap);
     376#ifdef DEBUG
     377    {   
     378        GET_THREAD(thread);
     379            int writeback = 1;
     380            GLboolean return_val = (GLboolean) 0;
     381        crPackIsEnabled(cap, &return_val, &writeback);
     382            packspuFlush( (void *) thread );
     383            while (writeback)
     384                  crNetRecv();
     385        CRASSERT(return_val==res);
     386    }
     387#endif
     388
     389    return res;
     390}
    402391
    403392void PACKSPU_APIENTRY packspu_PushClientAttrib( GLbitfield mask )
    404393{
    405394    crStatePushClientAttrib(mask);
     395    crPackPushClientAttrib(mask);
    406396}
    407397
     
    409399{
    410400    crStatePopClientAttrib();
    411 }
     401    crPackPopClientAttrib();
     402}
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c

    r21127 r21308  
    163163    /* XXX fix-up sharedCtx param here */
    164164    pack_spu.context[slot].clientState = crStateCreateContext(NULL, visual, NULL);
     165    pack_spu.context[slot].clientState->bufferobject.retainBufferData = GL_TRUE;
    165166    pack_spu.context[slot].serverCtx = serverCtx;
    166167
     
    227228        crPackSetContext( thread->packer );
    228229        crStateMakeCurrent( newCtx->clientState );
     230        //crStateSetCurrentPointers(newCtx->clientState, &thread->packer->current);
    229231        serverCtx = pack_spu.context[slot].serverCtx;
    230232    }
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py

    r20084 r21308  
    6969        print '\t}'
    7070        if func_name in simple_funcs:
    71             print '\tif (pname == GL_UNPACK_ALIGNMENT ||'
    72             print '\t\tpname == GL_UNPACK_ROW_LENGTH ||'
    73             print '\t\tpname == GL_UNPACK_SKIP_PIXELS ||'
    74             print '\t\tpname == GL_UNPACK_LSB_FIRST ||'
    75             print '\t\tpname == GL_UNPACK_SWAP_BYTES ||'
    76             print '#ifdef CR_OPENGL_VERSION_1_2'
    77             print '\t\tpname == GL_UNPACK_IMAGE_HEIGHT ||'
    78             print '#endif'
    79             print '\t\tpname == GL_UNPACK_SKIP_ROWS ||'
    80             print '\t\tpname == GL_PACK_ALIGNMENT ||'
    81             print '\t\tpname == GL_PACK_ROW_LENGTH ||'
    82             print '\t\tpname == GL_PACK_SKIP_PIXELS ||'
    83             print '\t\tpname == GL_PACK_LSB_FIRST ||'
    84             print '\t\tpname == GL_PACK_SWAP_BYTES ||'
    85             print '#ifdef CR_OPENGL_VERSION_1_2'
    86             print '\t\tpname == GL_PACK_IMAGE_HEIGHT ||'
    87             print '#endif'
    88             print '\t\tpname == GL_PACK_SKIP_ROWS'
    89             print '\t\t|| pname == GL_DRAW_BUFFER'
    90             print '#ifdef CR_OPENGL_VERSION_1_3'
    91             print '\t\t|| pname == GL_ACTIVE_TEXTURE'
    92             print '#endif'
    93             print '#ifdef CR_ARB_multitexture'
    94             print '\t\t|| pname == GL_ACTIVE_TEXTURE_ARB'
    95             print '#endif'
    96             print ') {'
    97             print '\t\t\tcrState%s( pname, params );' % func_name
    98             print '\t\t\treturn;'
    99             print '\t}'
     71            print """
     72    if (pname == GL_UNPACK_ALIGNMENT
     73        || pname == GL_UNPACK_ROW_LENGTH
     74        || pname == GL_UNPACK_SKIP_PIXELS
     75        || pname == GL_UNPACK_LSB_FIRST
     76        || pname == GL_UNPACK_SWAP_BYTES
     77#ifdef CR_OPENGL_VERSION_1_2
     78        || pname == GL_UNPACK_IMAGE_HEIGHT
     79#endif
     80        || pname == GL_UNPACK_SKIP_ROWS
     81        || pname == GL_PACK_ALIGNMENT
     82        || pname == GL_PACK_ROW_LENGTH
     83        || pname == GL_PACK_SKIP_PIXELS
     84        || pname == GL_PACK_LSB_FIRST
     85        || pname == GL_PACK_SWAP_BYTES
     86#ifdef CR_OPENGL_VERSION_1_2
     87        || pname == GL_PACK_IMAGE_HEIGHT
     88#endif
     89        || pname == GL_PACK_SKIP_ROWS
     90        || pname == GL_DRAW_BUFFER
     91#ifdef CR_OPENGL_VERSION_1_3
     92        || pname == GL_ACTIVE_TEXTURE
     93#endif
     94#ifdef CR_ARB_multitexture
     95        || pname == GL_ACTIVE_TEXTURE_ARB
     96#endif
     97        )
     98        {
     99            crState%s( pname, params );
     100            return;
     101        }
     102            """ % func_name
    100103        params.append( ("&writeback", "foo", 0) )
    101104        print '\tif (pack_spu.swap)'
  • trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special

    r20467 r21308  
    7272GetAttachedObjectsARB
    7373GetInfoLogARB
     74BufferSubDataARB
     75EnableVertexAttribArrayARB
     76DisableVertexAttribArrayARB
     77GetBufferSubDataARB
     78IsEnabled
Note: See TracChangeset for help on using the changeset viewer.

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