VirtualBox

Ignore:
Timestamp:
May 3, 2019 9:51:02 PM (6 years ago)
Author:
vboxsync
Message:

Additions/common/crOpengl,GuestHost/OpenGL,HostServices/SharedOpenGL: Eliminate all global variables from the state tracker library (state_tracker) in preparation of the SPU DLL merging, bugref:9435

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c

    r78116 r78375  
    2828}
    2929
    30 void STATE_APIENTRY crStateGenBuffersARB(GLsizei n, GLuint *buffers)
    31 {
    32     CRContext *g = GetCurrentContext();
     30void STATE_APIENTRY crStateGenBuffersARB(PCRStateTracker pState, GLsizei n, GLuint *buffers)
     31{
     32    CRContext *g = GetCurrentContext(pState);
    3333    crStateGenNames(g, g->shared->buffersTable, n, buffers);
    3434}
    3535
    36 void crStateRegBuffers(GLsizei n, GLuint *buffers)
    37 {
    38     CRContext *g = GetCurrentContext();
     36void crStateRegBuffers(PCRStateTracker pState, GLsizei n, GLuint *buffers)
     37{
     38    CRContext *g = GetCurrentContext(pState);
    3939    crStateRegNames(g, g->shared->buffersTable, n, buffers);
    4040}
     
    6161}
    6262
    63 GLboolean crStateIsBufferBound(GLenum target)
    64 {
    65     CRContext *g = GetCurrentContext();
     63GLboolean crStateIsBufferBound(PCRStateTracker pState, GLenum target)
     64{
     65    CRContext *g = GetCurrentContext(pState);
    6666    return crStateIsBufferBoundForCtx(g, target);
    6767}
     
    8686}
    8787
    88 DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsBufferARB( GLuint buffer )
    89 {
    90     CRContext *g = GetCurrentContext();
     88DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsBufferARB(PCRStateTracker pState, GLuint buffer )
     89{
     90    CRContext *g = GetCurrentContext(pState);
    9191
    9292    FLUSH();
    9393
    9494    if (g->current.inBeginEnd) {
    95         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     95        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    9696                                 "glIsBufferARB called in begin/end");
    9797        return GL_FALSE;
     
    103103void crStateBufferObjectInit (CRContext *ctx)
    104104{
    105     CRStateBits *sb          = GetCurrentBits();
     105    CRStateBits *sb          = GetCurrentBits(ctx->pStateTracker);
    106106    CRBufferObjectBits *bb = &sb->bufferobject;
    107107    CRBufferObjectState *b = &ctx->bufferobject;
     
    114114    RESET(bb->packBinding, ctx->bitid);
    115115#endif
     116
     117    b->pStateTracker = ctx->pStateTracker;
    116118
    117119#ifdef IN_GUEST
     
    134136}
    135137
    136 void crStateFreeBufferObject(void *data)
     138void crStateFreeBufferObject(void *data, void *pvUser)
    137139{
    138140    CRBufferObject *pObj = (CRBufferObject *)data;
     141    PCRStateTracker pState = (PCRStateTracker)pvUser;
    139142    if (pObj->data) crFree(pObj->data);
    140143
    141144#ifndef IN_GUEST
    142     if (diff_api.DeleteBuffersARB)
    143     {
    144         diff_api.DeleteBuffersARB(1, &pObj->hwid);
     145    if (pState->diff_api.DeleteBuffersARB)
     146    {
     147        pState->diff_api.DeleteBuffersARB(1, &pObj->hwid);
    145148    }
    146149#endif
     
    165168}
    166169
    167 DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(GLuint hwid)
    168 {
    169     CRContext *g = GetCurrentContext();
     170DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(PCRStateTracker pState, GLuint hwid)
     171{
     172    CRContext *g = GetCurrentContext(pState);
    170173    crCheckIDHWID_t parms;
    171174
     
    177180}
    178181
    179 DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(GLuint id)
    180 {
    181     CRContext *g = GetCurrentContext();
     182DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(PCRStateTracker pState, GLuint id)
     183{
     184    CRContext *g = GetCurrentContext(pState);
    182185    CRBufferObject *pObj = (CRBufferObject *) crHashtableSearch(g->shared->buffersTable, id);
    183186
     
    186189
    187190void STATE_APIENTRY
    188 crStateBindBufferARB (GLenum target, GLuint buffer)
    189 {
    190     CRContext *g = GetCurrentContext();
     191crStateBindBufferARB (PCRStateTracker pState, GLenum target, GLuint buffer)
     192{
     193    CRContext *g = GetCurrentContext(pState);
    191194    CRBufferObjectState *b = &(g->bufferobject);
    192     CRStateBits *sb = GetCurrentBits();
     195    CRStateBits *sb = GetCurrentBits(pState);
    193196    CRBufferObjectBits *bb = &(sb->bufferobject);
    194197    CRBufferObject *oldObj, *newObj;
    195198
    196199    if (g->current.inBeginEnd) {
    197         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     200        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    198201                                 "glBindBufferARB called in begin/end");
    199202        return;
     
    205208    if (!oldObj)
    206209    {
    207         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBindBufferARB(target)");
     210        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glBindBufferARB(target)");
    208211        return;
    209212    }
     
    219222            CRSTATE_CHECKERR(!newObj, GL_OUT_OF_MEMORY, "glBindBuffer");
    220223#ifndef IN_GUEST
    221             diff_api.GenBuffersARB(1, &newObj->hwid);
     224            pState->diff_api.GenBuffersARB(1, &newObj->hwid);
    222225            if (!newObj->hwid)
    223226            {
     
    268271        /*we shouldn't reach this point*/
    269272        CRASSERT(false);
    270         crHashtableDelete(g->shared->buffersTable, (unsigned long) oldObj->id, crStateFreeBufferObject);
     273        crHashtableDeleteEx(g->shared->buffersTable, (unsigned long) oldObj->id, crStateFreeBufferObject, pState);
    271274    }
    272275
     
    279282}
    280283
    281 static void ctStateBuffersRefsCleanup(CRContext *ctx, CRBufferObject *obj, CRbitvalue *neg_bitid)
     284static void ctStateBuffersRefsCleanup(PCRStateTracker pState, CRContext *ctx, CRBufferObject *obj, CRbitvalue *neg_bitid)
    282285{
    283286    CRBufferObjectState *b = &(ctx->bufferobject);
    284     CRStateBits *sb = GetCurrentBits();
     287    CRStateBits *sb = GetCurrentBits(pState);
    285288    CRBufferObjectBits *bb = &(sb->bufferobject);
    286289    int j, k;
     
    347350
    348351void STATE_APIENTRY
    349 crStateDeleteBuffersARB(GLsizei n, const GLuint *buffers)
    350 {
    351     CRContext *g = GetCurrentContext();
     352crStateDeleteBuffersARB(PCRStateTracker pState, GLsizei n, const GLuint *buffers)
     353{
     354    CRContext *g = GetCurrentContext(pState);
    352355    int i;
    353356
     
    355358
    356359    if (g->current.inBeginEnd) {
    357         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     360        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    358361                                 "glDeleteBuffersARB called in Begin/End");
    359362        return;
     
    361364
    362365    if (n < 0) {
    363         crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
     366        crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE,
    364367                                 "glDeleteBuffersARB(n < 0)");
    365368        return;
     
    373376                int j;
    374377
    375                 ctStateBuffersRefsCleanup(g, obj, g->neg_bitid);
     378                ctStateBuffersRefsCleanup(pState, g, obj, g->neg_bitid);
    376379
    377380                CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(obj, j)
     
    381384                     * This is why g_pAvailableContexts[j] could be NULL
    382385                     * also g_pAvailableContexts[0] will hold default context, which we should discard */
    383                     CRContext *ctx = g_pAvailableContexts[j];
     386                    CRContext *ctx = pState->apAvailableContexts[j];
    384387                    if (j && ctx)
    385388                    {
    386                         ctStateBuffersRefsCleanup(ctx, obj, g->neg_bitid); /* <- yes, use g->neg_bitid, i.e. neg_bitid of the current context to ensure others bits get dirtified,
    387                                                                             * but not the current context ones*/
     389                        ctStateBuffersRefsCleanup(pState, ctx, obj, g->neg_bitid); /* <- yes, use g->neg_bitid, i.e. neg_bitid of the current context to ensure others bits get dirtified,
     390                                                                                    * but not the current context ones*/
    388391                    }
    389392                    else
     
    391394                }
    392395
    393                 crHashtableDelete(g->shared->buffersTable, buffers[i], crStateFreeBufferObject);
     396                crHashtableDeleteEx(g->shared->buffersTable, buffers[i], crStateFreeBufferObject, pState);
    394397            }
    395398        }
     
    398401
    399402void STATE_APIENTRY
    400 crStateBufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)
    401 {
    402     CRContext *g = GetCurrentContext();
     403crStateBufferDataARB(PCRStateTracker pState, GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)
     404{
     405    CRContext *g = GetCurrentContext(pState);
    403406    CRBufferObjectState *b = &g->bufferobject;
    404407    CRBufferObject *obj;
    405     CRStateBits *sb = GetCurrentBits();
     408    CRStateBits *sb = GetCurrentBits(pState);
    406409    CRBufferObjectBits *bb = &sb->bufferobject;
    407410
     
    409412
    410413    if (g->current.inBeginEnd) {
    411         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     414        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    412415                                 "glBufferDataARB called in begin/end");
    413416        return;
     
    415418
    416419    if (size < 0) {
    417         crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
     420        crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE,
    418421                                 "glBufferDataARB(size < 0)");
    419422        return;
     
    433436            break;
    434437        default:
    435             crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     438            crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    436439                                     "glBufferDataARB(usage)");
    437440            return;
     
    441444    if (!obj)
    442445    {
    443         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBufferDataARB(target)");
     446        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glBufferDataARB(target)");
    444447        return;
    445448    }
    446449
    447450    if (obj->id == 0) {
    448         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBufferDataARB");
     451        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glBufferDataARB");
    449452        return;
    450453    }
    451454
    452455    if (obj->pointer) {
    453         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     456        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    454457                                 "glBufferDataARB(buffer is mapped)");
    455458        return;
     
    469472        obj->data = crAlloc(size);
    470473        if (!obj->data) {
    471             crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBufferDataARB");
     474            crStateError(pState, __LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBufferDataARB");
    472475            return;
    473476        }
     
    484487
    485488void STATE_APIENTRY
    486 crStateBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
    487 {
    488     CRContext *g = GetCurrentContext();
     489crStateBufferSubDataARB(PCRStateTracker pState, GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
     490{
     491    CRContext *g = GetCurrentContext(pState);
    489492    CRBufferObjectState *b = &g->bufferobject;
    490493    CRBufferObject *obj;
    491     CRStateBits *sb = GetCurrentBits();
     494    CRStateBits *sb = GetCurrentBits(pState);
    492495    CRBufferObjectBits *bb = &sb->bufferobject;
    493496
     
    495498
    496499    if (g->current.inBeginEnd) {
    497         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     500        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    498501                                 "glBufferSubDataARB called in begin/end");
    499502        return;
     
    503506    if (!obj)
    504507    {
    505         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBufferSubDataARB(target)");
     508        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glBufferSubDataARB(target)");
    506509        return;
    507510    }
    508511
    509512    if (obj->id == 0) {
    510         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     513        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    511514                                 "glBufferSubDataARB");
    512515        return;
     
    514517
    515518    if (obj->pointer) {
    516         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     519        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    517520                                 "glBufferSubDataARB(buffer is mapped)");
    518521        return;
     
    520523
    521524    if (size < 0 || offset < 0 || (unsigned int)offset + size > obj->size) {
    522         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     525        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    523526                                 "glBufferSubDataARB(bad offset and/or size)");
    524527        return;
     
    540543
    541544void STATE_APIENTRY
    542 crStateGetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data)
    543 {
    544     CRContext *g = GetCurrentContext();
     545crStateGetBufferSubDataARB(PCRStateTracker pState, GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data)
     546{
     547    CRContext *g = GetCurrentContext(pState);
    545548    CRBufferObjectState *b = &g->bufferobject;
    546549    CRBufferObject *obj;
     
    549552
    550553    if (g->current.inBeginEnd) {
    551         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     554        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    552555                                 "glGetBufferSubDataARB called in begin/end");
    553556        return;
     
    557560    if (!obj)
    558561    {
    559         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferSubDataARB(target)");
     562        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferSubDataARB(target)");
    560563        return;
    561564    }
    562565
    563566    if (obj->id == 0) {
    564         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     567        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    565568                                 "glGetBufferSubDataARB");
    566569        return;
     
    568571
    569572    if (obj->pointer) {
    570         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     573        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    571574                                 "glGetBufferSubDataARB(buffer is mapped)");
    572575        return;
     
    574577
    575578    if (size < 0 || offset < 0 || (unsigned int)offset + size > obj->size) {
    576         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     579        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    577580                                 "glGetBufferSubDataARB(bad offset and/or size)");
    578581        return;
     
    586589
    587590void * STATE_APIENTRY
    588 crStateMapBufferARB(GLenum target, GLenum access)
    589 {
    590     CRContext *g = GetCurrentContext();
     591crStateMapBufferARB(PCRStateTracker pState, GLenum target, GLenum access)
     592{
     593    CRContext *g = GetCurrentContext(pState);
    591594    CRBufferObjectState *b = &g->bufferobject;
    592595    CRBufferObject *obj;
     
    595598
    596599    if (g->current.inBeginEnd) {
    597         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     600        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    598601                                 "glMapBufferARB called in begin/end");
    599602        return NULL;
     
    603606    if (!obj)
    604607    {
    605         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMapBufferARB(target)");
     608        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glMapBufferARB(target)");
    606609        return NULL;
    607610    }
    608611
    609612    if (obj->id == 0) {
    610         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glMapBufferARB");
     613        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glMapBufferARB");
    611614        return GL_FALSE;
    612615    }
     
    619622            break;
    620623        default:
    621             crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     624            crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    622625                                     "glMapBufferARB(access)");
    623626            return NULL;
     
    632635
    633636GLboolean STATE_APIENTRY
    634 crStateUnmapBufferARB(GLenum target)
    635 {
    636     CRContext *g = GetCurrentContext();
     637crStateUnmapBufferARB(PCRStateTracker pState, GLenum target)
     638{
     639    CRContext *g = GetCurrentContext(pState);
    637640    CRBufferObjectState *b = &g->bufferobject;
    638641    CRBufferObject *obj;
    639     CRStateBits *sb = GetCurrentBits();
     642    CRStateBits *sb = GetCurrentBits(pState);
    640643    CRBufferObjectBits *bb = &sb->bufferobject;
    641644
     
    643646
    644647    if (g->current.inBeginEnd) {
    645         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     648        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    646649                                 "glUnmapBufferARB called in begin/end");
    647650        return GL_FALSE;
     
    651654    if (!obj)
    652655    {
    653         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glUnmapBufferARB(target)");
     656        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glUnmapBufferARB(target)");
    654657        return GL_FALSE;
    655658    }
    656659
    657660    if (obj->id == 0) {
    658         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");
     661        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");
    659662        return GL_FALSE;
    660663    }
    661664
    662665    if (!obj->pointer) {
    663         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");
     666        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");
    664667        return GL_FALSE;
    665668    }
     
    680683
    681684void STATE_APIENTRY
    682 crStateGetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
    683 {
    684     CRContext *g = GetCurrentContext();
     685crStateGetBufferParameterivARB(PCRStateTracker pState, GLenum target, GLenum pname, GLint *params)
     686{
     687    CRContext *g = GetCurrentContext(pState);
    685688    CRBufferObjectState *b = &g->bufferobject;
    686689    CRBufferObject *obj;
     
    689692
    690693    if (g->current.inBeginEnd) {
    691         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     694        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    692695                                 "glGetBufferParameterivARB called in begin/end");
    693696        return;
     
    697700    if (!obj)
    698701    {
    699         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)");
     702        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)");
    700703        return;
    701704    }
     
    715718            break;
    716719        default:
    717             crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
     720            crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
    718721                                     "glGetBufferParameterivARB(pname)");
    719722            return;
     
    723726
    724727void STATE_APIENTRY
    725 crStateGetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
    726 {
    727     CRContext *g = GetCurrentContext();
     728crStateGetBufferPointervARB(PCRStateTracker pState, GLenum target, GLenum pname, GLvoid **params)
     729{
     730    CRContext *g = GetCurrentContext(pState);
    728731    CRBufferObjectState *b = &g->bufferobject;
    729732    CRBufferObject *obj;
     
    732735
    733736    if (g->current.inBeginEnd) {
    734         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
     737        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
    735738                                 "glGetBufferPointervARB called in begin/end");
    736739        return;
     
    740743    if (!obj)
    741744    {
    742         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(target)");
     745        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(target)");
    743746        return;
    744747    }
    745748
    746749    if (pname != GL_BUFFER_MAP_POINTER_ARB) {
    747         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)");
     750        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)");
    748751        return;
    749752    }
     
    763766 */
    764767static GLboolean
    765 HaveBufferObjectExtension(void)
     768HaveBufferObjectExtension(PCRStateTracker pState)
    766769{
    767770    static GLint haveBufferObjectExt = -1;
     
    772775         * GetString into the diff'ing table in order for this to really work.
    773776         */
    774         if (!diff_api.GetString) {
     777        if (!pState->diff_api.GetString) {
    775778            haveBufferObjectExt = 0;
    776779            return 0;
    777780        }
    778         CRASSERT(diff_api.GetString);
    779         ext = (const char *) diff_api.GetString(GL_EXTENSIONS);
     781        CRASSERT(pState->diff_api.GetString);
     782        ext = (const char *) pState->diff_api.GetString(GL_EXTENSIONS);
    780783        if (crStrstr(ext, "GL_ARB_vertex_buffer_object") ||
    781784                crStrstr(ext, "GL_ARB_pixel_buffer_object")) {
     
    793796                                      GLboolean bSwitch)
    794797{
     798    PCRStateTracker pState = fromCtx->pStateTracker;
    795799    CRBufferObjectState *from = &(fromCtx->bufferobject);
    796800    const CRBufferObjectState *to = &(toCtx->bufferobject);
    797801
     802    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
     803
    798804    /* ARRAY_BUFFER */
    799805    if (CHECKDIRTY(bb->arrayBinding, bitID))
     
    802808        {
    803809            GLuint bufferID = to->arrayBuffer ? to->arrayBuffer->hwid : 0;
    804             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID);
     810            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID);
    805811            if (bSwitch)
    806812            {
     
    825831        {
    826832            /* update whole buffer */
    827             diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size,
    828                                    bufObj->data, bufObj->usage);
     833            pState->diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size,
     834                                           bufObj->data, bufObj->usage);
    829835        }
    830836        else
    831837        {
    832838            /* update sub buffer */
    833             diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB,
    834                                       bufObj->dirtyStart, bufObj->dirtyLength,
    835                                       (char *) bufObj->data + bufObj->dirtyStart);
     839            pState->diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB,
     840                                              bufObj->dirtyStart, bufObj->dirtyLength,
     841                                              (char *) bufObj->data + bufObj->dirtyStart);
    836842        }
    837843        if (bSwitch) FILLDIRTY(bufObj->dirty);
     
    845851        {
    846852            GLuint bufferID = to->elementsBuffer ? to->elementsBuffer->hwid : 0;
    847             diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID);
     853            pState->diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID);
    848854            if (bSwitch)
    849855            {
     
    868874        {
    869875            /* update whole buffer */
    870             diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size,
    871                                    bufObj->data, bufObj->usage);
     876            pState->diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size,
     877                                           bufObj->data, bufObj->usage);
    872878        }
    873879        else
    874880        {
    875881            /* update sub buffer */
    876             diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
    877                                       bufObj->dirtyStart, bufObj->dirtyLength,
    878                                       (char *) bufObj->data + bufObj->dirtyStart);
     882            pState->diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
     883                                              bufObj->dirtyStart, bufObj->dirtyLength,
     884                                              (char *) bufObj->data + bufObj->dirtyStart);
    879885        }
    880886        if (bSwitch) FILLDIRTY(bufObj->dirty);
     
    889895        {
    890896            GLuint bufferID = to->packBuffer ? to->packBuffer->hwid : 0;
    891             diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID);
     897            pState->diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID);
    892898            if (bSwitch)
    893899            {
     
    912918        {
    913919            /* update whole buffer */
    914             diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size,
    915                                    bufObj->data, bufObj->usage);
     920            pState->diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size,
     921                                           bufObj->data, bufObj->usage);
    916922        }
    917923        else
    918924        {
    919925            /* update sub buffer */
    920             diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB,
    921                                       bufObj->dirtyStart, bufObj->dirtyLength,
    922                                       (char *) bufObj->data + bufObj->dirtyStart);
     926            pState->diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB,
     927                                              bufObj->dirtyStart, bufObj->dirtyLength,
     928                                              (char *) bufObj->data + bufObj->dirtyStart);
    923929        }
    924930        if (bSwitch) FILLDIRTY(bufObj->dirty);
     
    932938        {
    933939            GLuint bufferID = to->unpackBuffer ? to->unpackBuffer->hwid : 0;
    934             diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID);
     940            pState->diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID);
    935941            if (bSwitch)
    936942            {
     
    955961        {
    956962            /* update whole buffer */
    957             diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size,
    958                                    bufObj->data, bufObj->usage);
     963            pState->diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size,
     964                                           bufObj->data, bufObj->usage);
    959965        }
    960966        else
    961967        {
    962968            /* update sub buffer */
    963             diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,
    964                                       bufObj->dirtyStart, bufObj->dirtyLength,
    965                                       (char *) bufObj->data + bufObj->dirtyStart);
     969            pState->diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,
     970                                              bufObj->dirtyStart, bufObj->dirtyLength,
     971                                              (char *) bufObj->data + bufObj->dirtyStart);
    966972        }
    967973        if (bSwitch) FILLDIRTY(bufObj->dirty);
     
    974980                             CRContext *fromCtx, CRContext *toCtx)
    975981{
    976     /*CRBufferObjectState *from = &(fromCtx->bufferobject); - unused
    977     const CRBufferObjectState *to = &(toCtx->bufferobject); - unused */
    978 
    979     if (!HaveBufferObjectExtension())
     982    PCRStateTracker pState = fromCtx->pStateTracker;
     983    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
     984
     985    if (!HaveBufferObjectExtension(pState))
    980986        return;
    981987
     
    991997    if (pBufferObj->id && !pBufferObj->hwid)
    992998    {
    993         diff_api.GenBuffersARB(1, &pBufferObj->hwid);
     999        pState->pStateTracker->diff_api.GenBuffersARB(1, &pBufferObj->hwid);
    9941000        CRASSERT(pBufferObj->hwid);
    9951001    }
     
    10041010          hurt performance."
    10051011         */
    1006         diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->hwid);
    1007         diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, pBufferObj->size, pBufferObj->data, pBufferObj->usage);
     1012        pState->pStateTracker->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->hwid);
     1013        pState->pStateTracker->diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, pBufferObj->size, pBufferObj->data, pBufferObj->usage);
    10081014
    10091015        if (!pState->retainBufferData)
     
    10211027                               CRContext *fromCtx, CRContext *toCtx)
    10221028{
    1023     /*const CRBufferObjectState *from = &(fromCtx->bufferobject); - unused */
    10241029    CRBufferObjectState *to = &(toCtx->bufferobject);
     1030    PCRStateTracker pState = fromCtx->pStateTracker;
    10251031    int i;
    10261032
    1027     if (!HaveBufferObjectExtension())
     1033    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
     1034
     1035    if (!HaveBufferObjectExtension(pState))
    10281036        return;
    10291037
     
    10401048        if (cp->buffer && (cp->buffer->id || locked))
    10411049        {
    1042             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1043             diff_api.VertexPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1050            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1051            pState->diff_api.VertexPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    10441052        }
    10451053
     
    10471055        if (cp->buffer && (cp->buffer->id || locked))
    10481056        {
    1049             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1050             diff_api.ColorPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1057            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1058            pState->diff_api.ColorPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    10511059        }
    10521060
     
    10541062        if (cp->buffer && (cp->buffer->id || locked))
    10551063        {
    1056             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1057             diff_api.FogCoordPointerEXT(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1064            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1065            pState->diff_api.FogCoordPointerEXT(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    10581066        }
    10591067
     
    10611069        if (cp->buffer && (cp->buffer->id || locked))
    10621070        {
    1063             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1064             diff_api.SecondaryColorPointerEXT(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1071            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1072            pState->diff_api.SecondaryColorPointerEXT(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    10651073        }
    10661074
     
    10681076        if (cp->buffer && (cp->buffer->id || locked))
    10691077        {
    1070             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1071             diff_api.EdgeFlagPointer(cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1078            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1079            pState->diff_api.EdgeFlagPointer(cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    10721080        }
    10731081
     
    10751083        if (cp->buffer && (cp->buffer->id || locked))
    10761084        {
    1077             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1078             diff_api.IndexPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1085            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1086            pState->diff_api.IndexPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    10791087        }
    10801088
     
    10821090        if (cp->buffer && (cp->buffer->id || locked))
    10831091        {
    1084             diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1085             diff_api.NormalPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1092            pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1093            pState->diff_api.NormalPointer(cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    10861094        }
    10871095
     
    10911099            if (cp->buffer && (cp->buffer->id || locked))
    10921100            {
    1093                 if (diff_api.ActiveTextureARB)
    1094                     diff_api.ActiveTextureARB(i+GL_TEXTURE0_ARB);
    1095                 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1096                 diff_api.TexCoordPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    1097             }
    1098         }
    1099 
    1100         if (diff_api.ActiveTextureARB)
    1101             diff_api.ActiveTextureARB(toCtx->client.curClientTextureUnit+GL_TEXTURE0_ARB);
     1101                if (pState->diff_api.ActiveTextureARB)
     1102                    pState->diff_api.ActiveTextureARB(i+GL_TEXTURE0_ARB);
     1103                pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1104                pState->diff_api.TexCoordPointer(cp->size, cp->type, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1105            }
     1106        }
     1107
     1108        if (pState->diff_api.ActiveTextureARB)
     1109            pState->diff_api.ActiveTextureARB(toCtx->client.curClientTextureUnit+GL_TEXTURE0_ARB);
    11021110
    11031111#ifdef CR_NV_vertex_program
     
    11071115            if (cp->buffer && (cp->buffer->id || locked))
    11081116            {
    1109                 diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
    1110                 diff_api.VertexAttribPointerARB(i, cp->size, cp->type, cp->normalized, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
    1111             }
    1112         }
    1113 #endif
    1114         diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, to->arrayBuffer->hwid);
    1115         diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, to->elementsBuffer->hwid);
     1117                pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid);
     1118                pState->diff_api.VertexAttribPointerARB(i, cp->size, cp->type, cp->normalized, cp->stride, cp->p CRVBOX_HOST_ONLY_PARAM(-1 /*fRealPtr*/));
     1119            }
     1120        }
     1121#endif
     1122        pState->diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, to->arrayBuffer->hwid);
     1123        pState->diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, to->elementsBuffer->hwid);
    11161124#ifdef CR_ARB_pixel_buffer_object
    1117         diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->packBuffer->hwid);
    1118         diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->unpackBuffer->hwid);
     1125        pState->diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->packBuffer->hwid);
     1126        pState->diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->unpackBuffer->hwid);
    11191127#endif
    11201128    }
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