VirtualBox

Ignore:
Timestamp:
Jan 22, 2013 8:18:51 AM (12 years ago)
Author:
vboxsync
Message:

crOpenGL: 1. stencil state fixes, 2. missing gets

File:
1 edited

Legend:

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

    r44290 r44326  
    8686        } while (0)
    8787
     88#define SHCROGL_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
     89#define SHCROGL_ALIGNTAILSIZE(_v, _b) (SHCROGL_ROUNDBOUND((_v),(_b)) - (_v))
     90#define SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT_SIZE(_type, _field, _oldFieldType, _nextFieldAllignment) (SHCROGL_ALIGNTAILSIZE(((RT_OFFSETOF(_type, _field) + sizeof (_oldFieldType))), (_nextFieldAllignment)))
     91#define SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(_type, _field, _oldFieldType, _nextFieldAllignment)  do { \
     92        const int32_t cbAlignment = SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT_SIZE(_type, _field, _oldFieldType, _nextFieldAllignment); \
     93        /*AssertCompile(SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) >= 0 && SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) < sizeof (void*));*/ \
     94        if (cbAlignment) { \
     95            rc = SSMR3Skip(pSSM, cbAlignment); \
     96        } \
     97    } while (0)
     98
     99
    88100#define SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) (sizeof (_type) - RT_OFFSETOF(_type, _lastField) - RT_SIZEOFMEMB(_type, _lastField))
    89101#define SHCROGL_CUT_TAIL_ALIGNMENT(_type, _lastField) do { \
     
    140152}
    141153
     154static int32_t crStateLoadStencilState_v_33(CRStencilState *s, PSSMHANDLE pSSM)
     155{
     156    CRStencilState_v_33 stencilV33;
     157    int32_t rc = SSMR3GetMem(pSSM, &stencilV33, sizeof (stencilV33));
     158    AssertRCReturn(rc, rc);
     159    s->stencilTest = stencilV33.stencilTest;
     160    s->stencilTwoSideEXT = GL_FALSE;
     161    s->activeStencilFace = GL_FRONT;
     162    s->clearValue = stencilV33.clearValue;
     163    s->writeMask = stencilV33.writeMask;
     164    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func = stencilV33.func;
     165    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask = stencilV33.mask;
     166    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref = stencilV33.ref;
     167    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail = stencilV33.fail;
     168    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail = stencilV33.passDepthFail;
     169    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass = stencilV33.passDepthPass;
     170    s->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK] = s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT];
     171    crStateStencilBufferInit(&s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK]);
     172    return VINF_SUCCESS;
     173}
     174
    142175static int32_t crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(CRTextureState *t, PSSMHANDLE pSSM)
    143176{
     
    203236    SHCROGL_CUT_TAIL_ALIGNMENT(CRTextureState, unit);
    204237
     238    return VINF_SUCCESS;
     239}
     240
     241static int32_t crStateStencilBufferStack_v_33(CRStencilBufferStack *s, PSSMHANDLE pSSM)
     242{
     243    CRStencilBufferStack_v_33 stackV33;
     244    int32_t rc = SSMR3GetMem(pSSM, &stackV33, sizeof (stackV33));
     245
     246    s->stencilTest = stackV33.stencilTest;
     247    s->stencilTwoSideEXT = GL_FALSE;
     248    s->activeStencilFace = GL_FRONT;
     249    s->clearValue = stackV33.clearValue;
     250    s->writeMask = stackV33.writeMask;
     251    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func = stackV33.func;
     252    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask = stackV33.mask;
     253    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref = stackV33.ref;
     254    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail = stackV33.fail;
     255    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail = stackV33.passDepthFail;
     256    s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass = stackV33.passDepthPass;
     257    s->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK] = s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT];
     258
     259    s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func = GL_ALWAYS;
     260    s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask = 0xFFFFFFFF;
     261    s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref = 0;
     262    s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail = GL_KEEP;
     263    s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail = GL_KEEP;
     264    s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass = GL_KEEP;
     265
     266    return VINF_SUCCESS;
     267}
     268
     269static int32_t crStateLoadAttribState_v_33(CRAttribState *t, PSSMHANDLE pSSM)
     270{
     271    int32_t i, rc;
     272    SHCROGL_GET_STRUCT_HEAD(t, CRAttribState, stencilBufferStack);
     273    for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i)
     274    {
     275        rc = crStateStencilBufferStack_v_33(&t->stencilBufferStack[i], pSSM);
     276        AssertRCReturn(rc, rc);
     277    }
     278    SHCROGL_GET_STRUCT_TAIL(t, CRAttribState, textureStackDepth);
    205279    return rc;
    206280}
     
    222296{
    223297    int32_t i, rc;
    224     SHCROGL_GET_STRUCT_HEAD(t, CRAttribState, textureStack);
     298
     299    SHCROGL_GET_STRUCT_HEAD(t, CRAttribState, stencilBufferStack);
     300    for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i)
     301    {
     302        rc = crStateStencilBufferStack_v_33(&t->stencilBufferStack[i], pSSM);
     303        AssertRCReturn(rc, rc);
     304    }
     305    SHCROGL_GET_STRUCT_PART(t, CRAttribState, textureStackDepth, textureStack);
    225306    for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i)
    226307    {
     
    16501731            rc = SSMR3GetMem(pSSM, (pBits->_var), _size); \
    16511732            AssertRCReturn(rc, rc);
     1733
     1734        if (u32Version < SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL)
     1735        {
     1736#define CRSTATE_BITS_OP_VERSION (SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL - 1)
     1737#define CRSTATE_BITS_OP_STENCIL_FUNC_V_33(_i, _var) do {} while (0)
     1738#define CRSTATE_BITS_OP_STENCIL_OP_V_33(_i, _var) do {} while (0)
    16521739#include "state_bits_globalop.h"
     1740#undef CRSTATE_BITS_OP_VERSION
     1741#undef CRSTATE_BITS_OP_STENCIL_FUNC_V_33
     1742#undef CRSTATE_BITS_OP_STENCIL_OP_V_33
     1743        }
     1744        else
     1745        {
     1746#include "state_bits_globalop.h"
     1747        }
    16531748#undef CRSTATE_BITS_OP
    16541749        return VINF_SUCCESS;
     
    17451840            AssertRCReturn(rc, rc);
    17461841            SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer);
    1747             SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, texture);
     1842            SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, stencil);
     1843            rc = crStateLoadStencilState_v_33(&pTmpContext->stencil, pSSM);
     1844            AssertRCReturn(rc, rc);
     1845            SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*));
    17481846            rc = crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->texture, pSSM);
    17491847            AssertRCReturn(rc, rc);
     
    17531851        else
    17541852        {
    1755             SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, shared);
     1853            SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, shared, attrib);
     1854            rc = crStateLoadAttribState_v_33(&pTmpContext->attrib, pSSM);
     1855            AssertRCReturn(rc, rc);
     1856            SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer);
     1857            SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, stencil);
     1858            rc = crStateLoadStencilState_v_33(&pTmpContext->stencil, pSSM);
     1859            AssertRCReturn(rc, rc);
     1860            SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*));
     1861            SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, texture);
    17561862        }
    17571863
    17581864        pTmpContext->error = GL_NO_ERROR; /* <- the error state contained some random error data here
    17591865                                                   * treat as no error */
     1866    }
     1867    else if (u32Version < SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL)
     1868    {
     1869        SHCROGL_GET_STRUCT_HEAD(pTmpContext, CRContext, attrib);
     1870        rc = crStateLoadAttribState_v_33(&pTmpContext->attrib, pSSM);
     1871        AssertRCReturn(rc, rc);
     1872        SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer);
     1873        SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, stencil);
     1874        rc = crStateLoadStencilState_v_33(&pTmpContext->stencil, pSSM);
     1875        AssertRCReturn(rc, rc);
     1876        SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*));
     1877        SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, texture);
    17601878    }
    17611879    else
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