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_current.c

    r69392 r78375  
    1919{
    2020    CRCurrentState *c = &ctx->current;
    21     CRStateBits *sb = GetCurrentBits();
     21    CRStateBits *sb = GetCurrentBits(ctx->pStateTracker);
    2222    CRCurrentBits *cb = &(sb->current);
    2323    static const GLfloat default_normal[4]         = {0.0f, 0.0f, 1.0f, 1.0f};
     
    7070}
    7171
    72 void STATE_APIENTRY crStateColor3f( GLfloat r, GLfloat g, GLfloat b )
    73 {
    74     crStateColor4f(r, g, b, 1.0F);
    75 }
    76 
    77 void STATE_APIENTRY crStateColor3fv( const GLfloat *color )
    78 {
    79     crStateColor4f( color[0], color[1], color[2], 1.0F );
    80 }
    81 
    82 void STATE_APIENTRY crStateColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
    83 {
    84     CRContext *g = GetCurrentContext();
     72void STATE_APIENTRY crStateColor3f(PCRStateTracker pState, GLfloat r, GLfloat g, GLfloat b )
     73{
     74    crStateColor4f(pState, r, g, b, 1.0F);
     75}
     76
     77void STATE_APIENTRY crStateColor3fv(PCRStateTracker pState, const GLfloat *color )
     78{
     79    crStateColor4f(pState, color[0], color[1], color[2], 1.0F );
     80}
     81
     82void STATE_APIENTRY crStateColor4f(PCRStateTracker pState, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
     83{
     84    CRContext *g = GetCurrentContext(pState);
    8585    CRCurrentState *c = &(g->current);
    86     CRStateBits *sb = GetCurrentBits();
     86    CRStateBits *sb = GetCurrentBits(pState);
    8787    CRCurrentBits *cb = &(sb->current);
    8888
     
    9898}
    9999
    100 void STATE_APIENTRY crStateColor4fv( const GLfloat *color )
    101 {
    102     crStateColor4f( color[0], color[1], color[2], color[3] );
     100void STATE_APIENTRY crStateColor4fv(PCRStateTracker pState, const GLfloat *color )
     101{
     102    crStateColor4f(pState, color[0], color[1], color[2], color[3] );
    103103}
    104104
     
    118118}
    119119
    120 void STATE_APIENTRY crStateBegin( GLenum mode )
    121 {
    122     CRContext *g = GetCurrentContext();
     120void STATE_APIENTRY crStateBegin(PCRStateTracker pState, GLenum mode )
     121{
     122    CRContext *g = GetCurrentContext(pState);
    123123    CRCurrentState *c = &(g->current);
    124124
    125125    if (mode > GL_POLYGON)
    126126    {
    127         crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Begin called with invalid mode: %d", mode);
     127        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Begin called with invalid mode: %d", mode);
    128128        return;
    129129    }
     
    131131    if (c->inBeginEnd)
    132132    {
    133         crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glBegin called inside Begin/End");
     133        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glBegin called inside Begin/End");
    134134        return;
    135135    }
     
    141141}
    142142
    143 void STATE_APIENTRY crStateEnd( void )
    144 {
    145     CRContext *g = GetCurrentContext();
     143void STATE_APIENTRY crStateEnd(PCRStateTracker pState)
     144{
     145    CRContext *g = GetCurrentContext(pState);
    146146    CRCurrentState *c = &(g->current);
    147147
    148148    if (!c->inBeginEnd)
    149149    {
    150         crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glEnd called outside Begin/End" );
     150        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glEnd called outside Begin/End" );
    151151        return;
    152152    }
     
    158158                                                     CRContext *fromCtx, CRContext *toCtx )
    159159{
     160    PCRStateTracker pState = fromCtx->pStateTracker;
    160161    const CRCurrentState *from = &(fromCtx->current);
    161162    const CRCurrentState *to = &(toCtx->current);
     
    163164    unsigned int i, j;
    164165    CRbitvalue nbitID[CR_MAX_BITARRAY];
     166
     167    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
    165168
    166169    for (j=0;j<CR_MAX_BITARRAY;j++)
     
    177180          if (toX != fromX || toY != fromY || toZ != fromZ) {
    178181                /* Use glWindowPos (which updates raster color) */
    179                 diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]);
     182                pState->diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]);
    180183              FILLDIRTY(c->rasterPos);
    181184              FILLDIRTY(c->dirty);
     
    195198    if (CHECKDIRTY(c->colorIndex, bitID)) {
    196199        if (to->colorIndex != from->colorIndex) {
    197             diff_api.Indexf(to->colorIndex);
     200            pState->diff_api.Indexf(to->colorIndex);
    198201            FILLDIRTY(c->colorIndex);
    199202            FILLDIRTY(c->dirty);
     
    204207    if (CHECKDIRTY(c->edgeFlag, bitID)) {
    205208        if (to->edgeFlag != from->edgeFlag) {
    206             diff_api.EdgeFlag(to->edgeFlag);
     209            pState->diff_api.EdgeFlag(to->edgeFlag);
    207210            FILLDIRTY(c->edgeFlag);
    208211            FILLDIRTY(c->dirty);
     
    223226                    && CHECKDIRTY(c->vertexAttrib[i], bitID)) {
    224227                if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) {
    225                     diff_api.VertexAttrib4fvARB(i, &(to->vertexAttrib[i][0]));
     228                    pState->diff_api.VertexAttrib4fvARB(i, &(to->vertexAttrib[i][0]));
    226229                    FILLDIRTY(c->vertexAttrib[i]);
    227230                    FILLDIRTY(c->dirty);
     
    242245        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) {
    243246            if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttrib[VERT_ATTRIB_COLOR0])) {
    244                 diff_api.Color4fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR0]));
     247                pState->diff_api.Color4fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR0]));
    245248                FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0]);
    246249                FILLDIRTY(c->dirty);
     
    253256        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) {
    254257            if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttrib[VERT_ATTRIB_COLOR1])) {
    255                 diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR1]));
     258                pState->diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR1]));
    256259                FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1]);
    257260                FILLDIRTY(c->dirty);
     
    265268        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) {
    266269            if (from->vertexAttrib[VERT_ATTRIB_FOG][0] != to->vertexAttrib[VERT_ATTRIB_FOG][0] ) {
    267                 diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_FOG][0] ));
     270                pState->diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_FOG][0] ));
    268271                FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG]);
    269272                FILLDIRTY(c->dirty);
     
    275278        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) {
    276279            if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttrib[VERT_ATTRIB_NORMAL])) {
    277                 diff_api.Normal3fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_NORMAL][0]));
     280                pState->diff_api.Normal3fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_NORMAL][0]));
    278281                FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL]);
    279282                FILLDIRTY(c->dirty);
     
    285288            if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) {
    286289                if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) {
    287                     diff_api.MultiTexCoord4fvARB (i+GL_TEXTURE0_ARB, (GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_TEX0+ i][0]));
     290                    pState->diff_api.MultiTexCoord4fvARB (i+GL_TEXTURE0_ARB, (GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_TEX0+ i][0]));
    288291                    FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i]);
    289292                    FILLDIRTY(c->dirty);
     
    301304                    CRContext *fromCtx, CRContext *toCtx )
    302305{
     306    PCRStateTracker pState = fromCtx->pStateTracker;
    303307    CRCurrentState *from = &(fromCtx->current);
    304308    const CRCurrentState *to = &(toCtx->current);
    305309    unsigned int i, j;
    306310    CRbitvalue nbitID[CR_MAX_BITARRAY];
     311
     312    CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
    307313
    308314    for (j=0;j<CR_MAX_BITARRAY;j++)
     
    320326            if (toX != fromX || toY != fromY || toZ != fromZ) {
    321327                /* Use glWindowPos (which updates raster color) */
    322                 diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]);
     328                pState->diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]);
    323329                from->rasterAttrib[VERT_ATTRIB_POS][0] = toX;
    324330                from->rasterAttrib[VERT_ATTRIB_POS][1] = toY;
     
    342348    if (CHECKDIRTY(c->edgeFlag, bitID)) {
    343349        if (from->edgeFlag != to->edgeFlagPre) {
    344             diff_api.EdgeFlag (to->edgeFlagPre);
     350            pState->diff_api.EdgeFlag (to->edgeFlagPre);
    345351        }
    346352        from->edgeFlag = to->edgeFlag;
     
    351357    if (CHECKDIRTY(c->colorIndex, bitID)) {
    352358        if (from->colorIndex != to->colorIndexPre) {
    353             diff_api.Indexf (to->colorIndex);
     359            pState->diff_api.Indexf (to->colorIndex);
    354360        }
    355361        from->colorIndex = to->colorIndex;
     
    370376                    && CHECKDIRTY(c->vertexAttrib[i], bitID)) {
    371377                if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) {
    372                     diff_api.VertexAttrib4fvARB(i, &(to->vertexAttribPre[i][0]));
     378                    pState->diff_api.VertexAttrib4fvARB(i, &(to->vertexAttribPre[i][0]));
    373379                }
    374380                COPY_4V(from->vertexAttrib[i] , to->vertexAttrib[i]);
     
    386392        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) {
    387393            if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttribPre[VERT_ATTRIB_COLOR0])) {
    388                 diff_api.Color4fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR0]));
     394                pState->diff_api.Color4fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR0]));
    389395            }
    390396            COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR0] , to->vertexAttrib[VERT_ATTRIB_COLOR0]);
     
    395401        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) {
    396402            if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttribPre[VERT_ATTRIB_COLOR1])) {
    397                 diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR1]));
     403                pState->diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR1]));
    398404            }
    399405            COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR1] , to->vertexAttrib[VERT_ATTRIB_COLOR1]);
     
    405411        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) {
    406412            if (from->vertexAttrib[VERT_ATTRIB_FOG]  != to->vertexAttribPre[VERT_ATTRIB_FOG]) {
    407                 diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_FOG]));
     413                pState->diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_FOG]));
    408414            }
    409415            COPY_4V(from->vertexAttrib[VERT_ATTRIB_FOG]  , to->vertexAttrib[VERT_ATTRIB_FOG]);
     
    414420        if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) {
    415421            if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttribPre[VERT_ATTRIB_NORMAL])) {
    416                 diff_api.Normal3fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_NORMAL]));
     422                pState->diff_api.Normal3fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_NORMAL]));
    417423            }
    418424            COPY_4V(from->vertexAttrib[VERT_ATTRIB_NORMAL] , to->vertexAttrib[VERT_ATTRIB_NORMAL]);
     
    424430            if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) {
    425431                if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) {
    426                     diff_api.MultiTexCoord4fvARB (GL_TEXTURE0_ARB + i, (GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_TEX0 + i]));
     432                    pState->diff_api.MultiTexCoord4fvARB (GL_TEXTURE0_ARB + i, (GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_TEX0 + i]));
    427433                }
    428434                COPY_4V(from->vertexAttrib[VERT_ATTRIB_TEX0 + i] , to->vertexAttrib[VERT_ATTRIB_TEX0 + i]);
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