VirtualBox

忽略:
時間撮記:
2012-12-12 下午02:21:32 (12 年 以前)
作者:
vboxsync
訊息:

crOpenGL: more state fixes & corrections

位置:
trunk/src/VBox/GuestHost/OpenGL/state_tracker
檔案:
修改 4 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c

    r44105 r44108  
    372372                CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(obj, j)
    373373                {
     374                    /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info,
     375                     * so on restore, we set mark bits as used.
     376                     * This is why g_pAvailableContexts[j] could be NULL
     377                     * also g_pAvailableContexts[0] will hold default context, which we should discard */
    374378                    CRContext *ctx = g_pAvailableContexts[j];
    375                     CRASSERT(ctx);
    376                     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,
    377                                                                         * but not the current context ones*/
     379                    if (j && ctx)
     380                    {
     381                        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,
     382                                                                            * but not the current context ones*/
     383                    }
     384                    else
     385                        CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(obj, j);
    378386                }
    379387
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_client.c

    r44105 r44108  
    111111}
    112112
    113 void crStateClientInit(CRContext *g)
    114 {
    115     CRClientState *c = &(g->client);
     113void crStateClientInit(CRContext *ctx)
     114{
     115    CRClientState *c = &(ctx->client);
    116116    unsigned int i;
    117117
     
    153153    c->array.v.enabled = 0;
    154154#ifdef CR_ARB_vertex_buffer_object
    155     c->array.v.buffer = g ? g->bufferobject.arrayBuffer : NULL;
     155    c->array.v.buffer = ctx->bufferobject.arrayBuffer;
    156156    if (c->array.v.buffer)
    157157        ++c->array.v.buffer->refCount;
     
    170170    c->array.c.enabled = 0;
    171171#ifdef CR_ARB_vertex_buffer_object
    172     c->array.c.buffer = g ? g->bufferobject.arrayBuffer : NULL;
     172    c->array.c.buffer = ctx->bufferobject.arrayBuffer;
    173173    if (c->array.c.buffer)
    174174        ++c->array.c.buffer->refCount;
     
    187187    c->array.f.enabled = 0;
    188188#ifdef CR_ARB_vertex_buffer_object
    189     c->array.f.buffer = g ? g->bufferobject.arrayBuffer : NULL;
     189    c->array.f.buffer = ctx->bufferobject.arrayBuffer;
    190190    if (c->array.f.buffer)
    191191        ++c->array.f.buffer->refCount;
     
    204204    c->array.s.enabled = 0;
    205205#ifdef CR_ARB_vertex_buffer_object
    206     c->array.s.buffer = g ? g->bufferobject.arrayBuffer : NULL;
     206    c->array.s.buffer = ctx->bufferobject.arrayBuffer;
    207207    if (c->array.s.buffer)
    208208        ++c->array.s.buffer->refCount;
     
    221221    c->array.e.enabled = 0;
    222222#ifdef CR_ARB_vertex_buffer_object
    223     c->array.e.buffer = g ? g->bufferobject.arrayBuffer : NULL;
     223    c->array.e.buffer = ctx->bufferobject.arrayBuffer;
    224224    if (c->array.e.buffer)
    225225        ++c->array.e.buffer->refCount;
     
    238238    c->array.i.enabled = 0;
    239239#ifdef CR_ARB_vertex_buffer_object
    240     c->array.i.buffer = g ? g->bufferobject.arrayBuffer : NULL;
     240    c->array.i.buffer = ctx->bufferobject.arrayBuffer;
    241241    if (c->array.i.buffer)
    242242        ++c->array.i.buffer->refCount;
     
    255255    c->array.n.enabled = 0;
    256256#ifdef CR_ARB_vertex_buffer_object
    257     c->array.n.buffer = g ? g->bufferobject.arrayBuffer : NULL;
     257    c->array.n.buffer = ctx->bufferobject.arrayBuffer;
    258258    if (c->array.n.buffer)
    259259        ++c->array.n.buffer->refCount;
     
    274274        c->array.t[i].enabled = 0;
    275275#ifdef CR_ARB_vertex_buffer_object
    276         c->array.t[i].buffer = g ? g->bufferobject.arrayBuffer : NULL;
     276        c->array.t[i].buffer = ctx->bufferobject.arrayBuffer;
    277277        if (c->array.t[i].buffer)
    278278            ++c->array.t[i].buffer->refCount;
     
    293293        c->array.a[i].stride = 0;
    294294#ifdef CR_ARB_vertex_buffer_object
    295         c->array.a[i].buffer = g ? g->bufferobject.arrayBuffer : NULL;
     295        c->array.a[i].buffer = ctx->bufferobject.arrayBuffer;
    296296        if (c->array.a[i].buffer)
    297297            ++c->array.a[i].buffer->refCount;
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c

    r44083 r44108  
    203203}
    204204
     205static void ctStateRenderbufferRefsCleanup(CRContext *g, GLuint fboId, CRRenderbufferObject *rbo)
     206{
     207    CRFramebufferObjectState *fbo = &g->framebufferobject;
     208
     209    if (fbo->renderbuffer==rbo)
     210    {
     211        fbo->renderbuffer = NULL;
     212    }
     213
     214    /* check the attachments of current framebuffers */
     215    crStateCheckFBOAttachments(fbo->readFB, fboId, GL_READ_FRAMEBUFFER);
     216    crStateCheckFBOAttachments(fbo->drawFB, fboId, GL_DRAW_FRAMEBUFFER);
     217
     218#ifndef IN_GUEST
     219    CR_STATE_SHAREDOBJ_USAGE_CLEAR(rbo, g);
     220#endif
     221}
     222
    205223DECLEXPORT(void) STATE_APIENTRY
    206224crStateDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
     
    221239            if (rbo)
    222240            {
    223                 if (fbo->renderbuffer==rbo)
     241#ifndef IN_GUEST
     242                int j;
     243#endif
     244                ctStateRenderbufferRefsCleanup(g, renderbuffers[i], rbo);
     245#ifndef IN_GUEST
     246                CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(rbo, j)
    224247                {
    225                     fbo->renderbuffer = NULL;
     248                    /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info,
     249                     * so on restore, we set mark bits as used.
     250                     * This is why g_pAvailableContexts[j] could be NULL
     251                     * also g_pAvailableContexts[0] will hold default context, which we should discard */
     252                    CRContext *ctx = g_pAvailableContexts[j];
     253                    if (j && ctx)
     254                    {
     255                        CRFramebufferObjectState *ctxFbo;
     256                        CRASSERT(ctx);
     257                        ctxFbo = &ctx->framebufferobject;
     258                        if (ctxFbo->renderbuffer==rbo)
     259                            crWarning("deleting RBO being used by another context %d", ctx->id);
     260
     261                        ctStateRenderbufferRefsCleanup(ctx, renderbuffers[i], rbo);
     262                    }
     263                    else
     264                        CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(rbo, j);
    226265                }
    227 
    228                 /* check the attachments of current framebuffers */
    229                 crStateCheckFBOAttachments(fbo->readFB, renderbuffers[i], GL_READ_FRAMEBUFFER);
    230                 crStateCheckFBOAttachments(fbo->drawFB, renderbuffers[i], GL_DRAW_FRAMEBUFFER);
    231 
     266#endif
    232267                crHashtableDelete(g->shared->rbTable, renderbuffers[i], crStateFreeRBO);
    233268            }
     
    380415}
    381416
     417static void ctStateFramebufferRefsCleanup(CRContext *g, CRFramebufferObject *fb)
     418{
     419    CRFramebufferObjectState *fbo = &g->framebufferobject;
     420    if (fbo->readFB==fb)
     421    {
     422        fbo->readFB = NULL;
     423    }
     424    if (fbo->drawFB==fb)
     425    {
     426        fbo->drawFB = NULL;
     427    }
     428
     429    CR_STATE_SHAREDOBJ_USAGE_CLEAR(fb, g);
     430}
     431
    382432DECLEXPORT(void) STATE_APIENTRY
    383433crStateDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
    384434{
    385435    CRContext *g = GetCurrentContext();
    386     CRFramebufferObjectState *fbo = &g->framebufferobject;
    387436    int i;
    388437
     
    398447            if (fb)
    399448            {
    400                 if (fbo->readFB==fb)
     449#ifndef IN_GUEST
     450                int j;
     451#endif
     452                ctStateFramebufferRefsCleanup(g, fb);
     453#ifndef IN_GUEST
     454                CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(fb, j)
    401455                {
    402                     fbo->readFB = NULL;
     456                    /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info,
     457                     * so on restore, we set mark bits as used.
     458                     * This is why g_pAvailableContexts[j] could be NULL
     459                     * also g_pAvailableContexts[0] will hold default context, which we should discard */
     460                    CRContext *ctx = g_pAvailableContexts[j];
     461                    if (j && ctx)
     462                    {
     463                        CRFramebufferObjectState *ctxFbo;
     464                        CRASSERT(ctx);
     465                        ctxFbo = &ctx->framebufferobject;
     466                        if (ctxFbo->readFB==fb)
     467                            crWarning("deleting FBO being used as read buffer by another context %d", ctx->id);
     468
     469                        if (ctxFbo->drawFB==fb)
     470                            crWarning("deleting FBO being used as draw buffer by another context %d", ctx->id);
     471
     472                        ctStateFramebufferRefsCleanup(ctx, fb);
     473                    }
     474                    else
     475                        CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(fb, j);
    403476                }
    404                 if (fbo->drawFB==fb)
    405                 {
    406                     fbo->drawFB = NULL;
    407                 }
     477#endif
    408478                crHashtableDelete(g->shared->fbTable, framebuffers[i], crStateFreeFBO);
    409479            }
     
    470540    CRFramebufferObjectState *fbo = &g->framebufferobject;
    471541    CRFramebufferObject *apFBOs[2];
    472     GLuint cPBOs = 0, i;
     542    GLuint cFBOs = 0, i;
    473543    GLuint maxtexsizelog2;
    474 
    475544
    476545    CRSTATE_CHECKERR_RET(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end", 0);
     
    478547                         GL_INVALID_ENUM, "invalid target", 0);
    479548
    480     cPBOs = crStateFramebufferGet(fbo, target, apFBOs);
    481     CRSTATE_CHECKERR_RET(!cPBOs, GL_INVALID_ENUM, "unexpected target", 0);
    482 
    483     Assert(cPBOs);
    484     Assert(cPBOs <= 2);
    485 
    486    for (i = 0; i < cPBOs; ++i)
    487     {
    488         CRSTATE_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "no fbo bound", 0);
     549    cFBOs = crStateFramebufferGet(fbo, target, apFBOs);
     550    CRSTATE_CHECKERR_RET(!cFBOs, GL_INVALID_ENUM, "unexpected target", 0);
     551    for (i = 0; i < cFBOs; ++i)
     552    {
     553        CRSTATE_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound", 0);
     554    }
     555
     556    Assert(cFBOs);
     557    Assert(cFBOs <= 2);
     558
     559    for (i = 0; i < cFBOs; ++i)
     560    {
    489561        CRSTATE_CHECKERR_RET(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment", 0);
    490562    }
     
    492564    if (!texture)
    493565    {
    494         return cPBOs;
     566        return cFBOs;
    495567    }
    496568
     
    534606
    535607#ifdef IN_GUEST
    536     for (i = 0; i < cPBOs; ++i)
     608    for (i = 0; i < cFBOs; ++i)
    537609    {
    538610        if ((aap[i])->type!=GL_TEXTURE || (aap[i])->name!=texture || (aap[i])->level!=level)
     
    543615#endif
    544616
    545     Assert(cPBOs);
    546     Assert(cPBOs <= 2);
    547 
    548     return cPBOs;
     617    Assert(cFBOs);
     618    Assert(cFBOs <= 2);
     619
     620    return cFBOs;
    549621}
    550622
     
    668740    CRContext *g = GetCurrentContext();
    669741    CRFramebufferObjectState *fbo = &g->framebufferobject;
    670     CRFramebufferObject *pFBO;
    671     CRFBOAttachmentPoint *ap;
     742    CRFramebufferObject *apFBOs[2];
     743    GLuint cFBOs, i;
     744    CRFBOAttachmentPoint *aap[2];
    672745    CRRenderbufferObject *rb;
    673746
     
    675748    CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
    676749                         GL_INVALID_ENUM, "invalid target");
    677     pFBO = GL_READ_FRAMEBUFFER==target ? fbo->readFB : fbo->drawFB;
    678     CRSTATE_CHECKERR(!pFBO, GL_INVALID_OPERATION, "no fbo bound");
    679     CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(pFBO, attachment, &ap), GL_INVALID_ENUM, "invalid attachment");
     750    cFBOs = crStateFramebufferGet(fbo, target, apFBOs);
     751    CRSTATE_CHECKERR(!cFBOs, GL_INVALID_OPERATION, "no fbo bound");
     752    for (i = 0; i < cFBOs; ++i)
     753    {
     754        CRSTATE_CHECKERR(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound");
     755    }
     756
     757    for (i = 0; i < cFBOs; ++i)
     758    {
     759        CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment");
     760    }
    680761
    681762    if (!renderbuffer)
    682763    {
     764        for (i = 0; i < cFBOs; ++i)
     765        {
    683766#ifdef IN_GUEST
    684         if (ap->type!=GL_NONE)
    685         {
    686             pFBO->status = GL_FRAMEBUFFER_UNDEFINED;
    687         }
    688 #endif
    689         crStateInitFBOAttachmentPoint(ap);
     767            if (&aap[i]->type!=GL_NONE)
     768            {
     769                apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED;
     770            }
     771#endif
     772            crStateInitFBOAttachmentPoint(aap[i]);
     773        }
    690774        return;
    691775    }
     
    698782    }
    699783
     784#ifndef IN_GUEST
     785    CR_STATE_SHAREDOBJ_USAGE_SET(rb, g);
     786#endif
     787
     788    for (i = 0; i < cFBOs; ++i)
     789    {
    700790#ifdef IN_GUEST
    701         if (ap->type!=GL_RENDERBUFFER_EXT || ap->name!=renderbuffer)
    702         {
    703             pFBO->status = GL_FRAMEBUFFER_UNDEFINED;
    704         }
    705 #endif
    706     crStateInitFBOAttachmentPoint(ap);
    707     ap->type = GL_RENDERBUFFER_EXT;
    708     ap->name = renderbuffer;
     791        if (aap[i]->type!=GL_RENDERBUFFER_EXT || aap[i]->name!=renderbuffer)
     792        {
     793            apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED;
     794        }
     795#endif
     796        crStateInitFBOAttachmentPoint(aap[i]);
     797        aap[i]->type = GL_RENDERBUFFER_EXT;
     798        aap[i]->name = renderbuffer;
     799    }
    709800}
    710801
     
    725816
    726817    CRSTATE_CHECKERR(!cFBOs, GL_INVALID_OPERATION, "no fbo bound");
    727 
    728818    for (i = 0; i < cFBOs; ++i)
     819    {
     820        CRSTATE_CHECKERR(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound");
     821    }
     822
     823    if(cFBOs != 1)
     824    {
     825        crWarning("different FBPs attached to draw and read buffers, returning info for the read buffer");
     826    }
     827
     828    for (i = 0; i < 1; ++i)
    729829    {
    730830        CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &ap), GL_INVALID_ENUM, "invalid attachment");
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c

    r44105 r44108  
    776776            CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(tObj, j)
    777777            {
     778                /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info,
     779                 * so on restore, we set mark bits as used.
     780                 * This is why g_pAvailableContexts[j] could be NULL
     781                 * also g_pAvailableContexts[0] will hold default context, which we should discard */
    778782                CRContext *ctx = g_pAvailableContexts[j];
    779                 crStateCleanupTextureRefs(ctx, tObj);
     783                if (j && ctx)
     784                    crStateCleanupTextureRefs(ctx, tObj);
     785                else
     786                    CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(tObj, j);
    780787            }
    781788
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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