VirtualBox

忽略:
時間撮記:
2012-12-7 上午10:34:42 (12 年 以前)
作者:
vboxsync
訊息:

crOpenGL: more gl state fixes

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

圖例:

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

    r39602 r44059  
    99
    1010#include "cr_glstate.h"
     11
     12#define CRSTATE_CHECKERR_RET(expr, result, message, ret)         \
     13    if (expr) {                                             \
     14        crStateError(__LINE__, __FILE__, result, message);  \
     15        return ret;                                             \
     16    }
     17
     18#define CRSTATE_NO_RETURN
     19
     20#define CRSTATE_CHECKERR(expr, result, message) CRSTATE_CHECKERR_RET(expr, result, message, CRSTATE_NO_RETURN)
    1121
    1222typedef struct _crCheckIDHWID {
     
    6272void crStateFreeFBO(void *data);
    6373void crStateFreeRBO(void *data);
     74
     75void crStateGenNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names);
    6476#endif
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c

    r44052 r44059  
    3030}
    3131
     32void STATE_APIENTRY crStateGenBuffersARB(GLsizei n, GLuint *buffers)
     33{
     34    CRContext *g = GetCurrentContext();
     35    crStateGenNames(g, g->shared->buffersTable, n, buffers);
     36}
     37
    3238GLboolean crStateIsBufferBound(GLenum target)
    3339{
     
    185191        newObj = (CRBufferObject *) crHashtableSearch(g->shared->buffersTable, buffer);
    186192        if (!newObj) {
     193            CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->buffersTable, buffer), GL_INVALID_OPERATION, "name is not a buffer object");
    187194            newObj = AllocBufferObject(buffer);
    188             if (!newObj) {
    189                 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBindBuffer");
     195            CRSTATE_CHECKERR(!newObj, GL_OUT_OF_MEMORY, "glBindBuffer");
     196#ifndef IN_GUEST
     197            diff_api.GenBuffersARB(1, &newObj->hwid);
     198            if (!newObj->hwid)
     199            {
     200                crWarning("GenBuffersARB failed!");
     201                crFree(newObj);
    190202                return;
    191203            }
     204#endif
    192205            crHashtableAdd( g->shared->buffersTable, buffer, newObj );
    193206        }
     
    334347}
    335348
    336 
    337 void STATE_APIENTRY
    338 crStateGenBuffersARB(GLsizei n, GLuint * buffers)
    339 {
    340     CRContext *g = GetCurrentContext();
    341     CRBufferObjectState *b = &(g->bufferobject);
    342     GLint start;
    343 
    344     FLUSH();
    345 
    346     if (g->current.inBeginEnd) {
    347         crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
    348                                  "glGenBuffersARB called in Begin/End");
    349         return;
    350     }
    351 
    352     if (n < 0) {
    353         crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
    354                                  "glGenBuffersARB(n < 0)");
    355         return;
    356     }
    357 
    358     start = crHashtableAllocKeys(g->shared->buffersTable, n);
    359     if (start) {
    360         GLint i;
    361         for (i = 0; i < n; i++)
    362             buffers[i] = (GLuint) (start + i);
    363     }
    364     else {
    365         crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenBuffersARB");
    366     }
    367 }
    368 
    369 
    370349GLboolean STATE_APIENTRY
    371350crStateIsBufferARB(GLuint buffer)
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c

    r44053 r44059  
    2323#include "cr_mem.h"
    2424
    25 #define CRSTATE_FBO_CHECKERR_RET(expr, result, message, ret)         \
    26     if (expr) {                                             \
    27         crStateError(__LINE__, __FILE__, result, message);  \
    28         return ret;                                             \
    29     }
    30 
    31 #define CRSTATE_NO_RETURN
    32 
    33 #define CRSTATE_FBO_CHECKERR(expr, result, message) CRSTATE_FBO_CHECKERR_RET(expr, result, message, CRSTATE_NO_RETURN)
    34 
    3525DECLEXPORT(void) STATE_APIENTRY
    3626crStateFramebufferObjectInit(CRContext *ctx)
     
    4434}
    4535
     36void STATE_APIENTRY crStateGenFramebuffersEXT(GLsizei n, GLuint *buffers)
     37{
     38    CRContext *g = GetCurrentContext();
     39    crStateGenNames(g, g->shared->fbTable, n, buffers);
     40}
     41
     42void STATE_APIENTRY crStateGenRenderbuffersEXT(GLsizei n, GLuint *buffers)
     43{
     44    CRContext *g = GetCurrentContext();
     45    crStateGenNames(g, g->shared->rbTable, n, buffers);
     46}
     47
     48static void crStateInitFrameBuffer(CRFramebufferObject *fbo);
     49
     50static CRFramebufferObject *
     51crStateFramebufferAllocate(CRContext *ctx, GLuint name)
     52{
     53    CRFramebufferObject *buffer = (CRFramebufferObject*) crCalloc(sizeof(CRFramebufferObject));
     54    CRSTATE_CHECKERR_RET(!buffer, GL_OUT_OF_MEMORY, "crStateFramebufferAllocate", NULL);
     55    buffer->id = name;
     56#ifndef IN_GUEST
     57    diff_api.GenFramebuffersEXT(1, &buffer->hwid);
     58    if (!buffer->hwid)
     59    {
     60        crWarning("GenFramebuffersEXT failed!");
     61        crFree(buffer);
     62        return NULL;
     63    }
     64#else
     65    buffer->hwid = name;
     66#endif
     67
     68    crStateInitFrameBuffer(buffer);
     69    crHashtableAdd(ctx->shared->fbTable, name, buffer);
     70#ifndef IN_GUEST
     71    CR_STATE_SHAREDOBJ_USAGE_INIT(buffer);
     72#endif
     73
     74    return buffer;
     75}
     76
     77static CRRenderbufferObject *
     78crStateRenderbufferAllocate(CRContext *ctx, GLuint name)
     79{
     80    CRRenderbufferObject *buffer = (CRRenderbufferObject*) crCalloc(sizeof(CRRenderbufferObject));
     81    CRSTATE_CHECKERR_RET(!buffer, GL_OUT_OF_MEMORY, "crStateRenderbufferAllocate", NULL);
     82    buffer->id = name;
     83#ifndef IN_GUEST
     84    diff_api.GenRenderbuffersEXT(1, &buffer->hwid);
     85    if (!buffer->hwid)
     86    {
     87        crWarning("GenRenderbuffersEXT failed!");
     88        crFree(buffer);
     89        return NULL;
     90    }
     91#else
     92    buffer->hwid = name;
     93#endif
     94
     95    buffer->internalformat = GL_RGBA;
     96    crHashtableAdd(ctx->shared->rbTable, name, buffer);
     97#ifndef IN_GUEST
     98    CR_STATE_SHAREDOBJ_USAGE_INIT(buffer);
     99#endif
     100
     101    return buffer;
     102}
     103
    46104void crStateFreeFBO(void *data)
    47105{
     
    88146    CRFramebufferObjectState *fbo = &g->framebufferobject;
    89147
    90     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    91     CRSTATE_FBO_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target");
     148    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     149    CRSTATE_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target");
    92150
    93151    if (renderbuffer)
     
    96154        if (!fbo->renderbuffer)
    97155        {
    98             fbo->renderbuffer = (CRRenderbufferObject*) crCalloc(sizeof(CRRenderbufferObject));
    99             CRSTATE_FBO_CHECKERR(!fbo->renderbuffer, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT");
    100             fbo->renderbuffer->id = renderbuffer;
    101             fbo->renderbuffer->hwid = renderbuffer;
    102             fbo->renderbuffer->internalformat = GL_RGBA;
    103             crHashtableAdd(g->shared->rbTable, renderbuffer, fbo->renderbuffer);
    104 #ifndef IN_GUEST
    105         CR_STATE_SHAREDOBJ_USAGE_INIT(fbo->renderbuffer);
    106 #endif
     156            CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->rbTable, renderbuffer), GL_INVALID_OPERATION, "name is not a renderbuffer");
     157            fbo->renderbuffer = crStateRenderbufferAllocate(g, renderbuffer);
    107158        }
    108159#ifndef IN_GUEST
     
    159210    int i;
    160211
    161     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    162     CRSTATE_FBO_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0");
     212    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     213    CRSTATE_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0");
    163214
    164215    for (i = 0; i < n; i++)
     
    192243    CRRenderbufferObject *rb = fbo->renderbuffer;
    193244
    194     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    195     CRSTATE_FBO_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target");
    196     CRSTATE_FBO_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer");
     245    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     246    CRSTATE_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target");
     247    CRSTATE_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer");
    197248
    198249    rb->width = width;
     
    208259    CRRenderbufferObject *rb = fbo->renderbuffer;
    209260
    210     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    211     CRSTATE_FBO_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target");
    212     CRSTATE_FBO_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer");
     261    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     262    CRSTATE_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target");
     263    CRSTATE_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer");
    213264
    214265    switch (pname)
     
    229280        case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
    230281        case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
    231             CRSTATE_FBO_CHECKERR(GL_TRUE, GL_INVALID_OPERATION, "unimplemented");
     282            CRSTATE_CHECKERR(GL_TRUE, GL_INVALID_OPERATION, "unimplemented");
    232283            break;
    233284        default:
    234             CRSTATE_FBO_CHECKERR(GL_TRUE, GL_INVALID_ENUM, "invalid pname");
     285            CRSTATE_CHECKERR(GL_TRUE, GL_INVALID_ENUM, "invalid pname");
    235286    }
    236287}
     
    291342    CRFramebufferObject *pFBO=NULL;
    292343
    293     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    294     CRSTATE_FBO_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
     344    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     345    CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
    295346                         GL_INVALID_ENUM, "invalid target");
    296347
     
    300351        if (!pFBO)
    301352        {
    302             pFBO = (CRFramebufferObject*) crCalloc(sizeof(CRFramebufferObject));
    303             CRSTATE_FBO_CHECKERR(!pFBO, GL_OUT_OF_MEMORY, "glBindFramebufferEXT");
    304             pFBO->id = framebuffer;
    305             pFBO->hwid = framebuffer;
    306             crStateInitFrameBuffer(pFBO);
    307             crHashtableAdd(g->shared->fbTable, framebuffer, pFBO);
    308 #ifndef IN_GUEST
    309             CR_STATE_SHAREDOBJ_USAGE_INIT(pFBO);
    310 #endif
     353            CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->fbTable, framebuffer), GL_INVALID_OPERATION, "name is not a framebuffer");
     354            pFBO = crStateFramebufferAllocate(g, framebuffer);
    311355        }
    312356
     
    343387    int i;
    344388
    345     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    346     CRSTATE_FBO_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0");
     389    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     390    CRSTATE_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0");
    347391
    348392    for (i = 0; i < n; i++)
     
    385429}
    386430
    387 static GLuint crStateFramebufferTextureCheck(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level,
    388                     CRFBOAttachmentPoint **aap, CRTextureObj **tobj)
    389 {
    390     CRContext *g = GetCurrentContext();
    391     CRFramebufferObjectState *fbo = &g->framebufferobject;
    392     CRFramebufferObject *apFBOs[2];
    393     GLuint cPBOs = 0, i;
    394     GLuint maxtexsizelog2;
    395 
    396 
    397     CRSTATE_FBO_CHECKERR_RET(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end", 0);
    398     CRSTATE_FBO_CHECKERR_RET(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
    399                          GL_INVALID_ENUM, "invalid target", 0);
     431static GLuint crStateFramebufferGet(CRFramebufferObjectState *fbo, GLenum target, CRFramebufferObject **apFBOs)
     432{
     433    GLuint cPBOs = 0;
    400434    switch (target)
    401435    {
     
    422456            break;
    423457        default:
    424             crWarning("unexpected dtarget value: 0x%x", target);
    425             CRSTATE_FBO_CHECKERR_RET(1, GL_INVALID_ENUM, "unexpected target", 0);
    426             break;
    427     }
     458            crWarning("unexpected target value: 0x%x", target);
     459            cPBOs = 0;
     460            break;
     461    }
     462
     463    return cPBOs;
     464}
     465
     466static GLuint crStateFramebufferTextureCheck(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level,
     467                    CRFBOAttachmentPoint **aap, CRTextureObj **tobj)
     468{
     469    CRContext *g = GetCurrentContext();
     470    CRFramebufferObjectState *fbo = &g->framebufferobject;
     471    CRFramebufferObject *apFBOs[2];
     472    GLuint cPBOs = 0, i;
     473    GLuint maxtexsizelog2;
     474
     475
     476    CRSTATE_CHECKERR_RET(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end", 0);
     477    CRSTATE_CHECKERR_RET(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
     478                         GL_INVALID_ENUM, "invalid target", 0);
     479
     480    cPBOs = crStateFramebufferGet(fbo, target, apFBOs);
     481    CRSTATE_CHECKERR_RET(!cPBOs, GL_INVALID_ENUM, "unexpected target", 0);
    428482
    429483    Assert(cPBOs);
     
    432486   for (i = 0; i < cPBOs; ++i)
    433487    {
    434         CRSTATE_FBO_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "no fbo bound", 0);
    435         CRSTATE_FBO_CHECKERR_RET(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment", 0);
     488        CRSTATE_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "no fbo bound", 0);
     489        CRSTATE_CHECKERR_RET(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment", 0);
    436490    }
    437491
     
    466520            break;
    467521        default:
    468             CRSTATE_FBO_CHECKERR_RET(GL_TRUE, GL_INVALID_OPERATION, "invalid textarget", 0);
    469     }
    470 
    471     CRSTATE_FBO_CHECKERR_RET(!*tobj, GL_INVALID_OPERATION, "invalid textarget/texture combo", 0);
     522            CRSTATE_CHECKERR_RET(GL_TRUE, GL_INVALID_OPERATION, "invalid textarget", 0);
     523    }
     524
     525    CRSTATE_CHECKERR_RET(!*tobj, GL_INVALID_OPERATION, "invalid textarget/texture combo", 0);
    472526
    473527    if (GL_TEXTURE_RECTANGLE_ARB==textarget)
    474528    {
    475         CRSTATE_FBO_CHECKERR_RET(level!=0, GL_INVALID_VALUE, "non zero mipmap level", 0);
    476     }
    477 
    478     CRSTATE_FBO_CHECKERR_RET(level<0, GL_INVALID_VALUE, "level<0", 0);
    479     CRSTATE_FBO_CHECKERR_RET(level>maxtexsizelog2, GL_INVALID_VALUE, "level too big", 0);
     529        CRSTATE_CHECKERR_RET(level!=0, GL_INVALID_VALUE, "non zero mipmap level", 0);
     530    }
     531
     532    CRSTATE_CHECKERR_RET(level<0, GL_INVALID_VALUE, "level<0", 0);
     533    CRSTATE_CHECKERR_RET(level>maxtexsizelog2, GL_INVALID_VALUE, "level too big", 0);
    480534
    481535#ifdef IN_GUEST
     
    516570    }
    517571
    518     CRSTATE_FBO_CHECKERR(textarget!=GL_TEXTURE_1D, GL_INVALID_OPERATION, "textarget");
     572    CRSTATE_CHECKERR(textarget!=GL_TEXTURE_1D, GL_INVALID_OPERATION, "textarget");
    519573
    520574#ifndef IN_GUEST
     
    552606    }
    553607
    554     CRSTATE_FBO_CHECKERR(GL_TEXTURE_1D==textarget || GL_TEXTURE_3D==textarget, GL_INVALID_OPERATION, "textarget");
     608    CRSTATE_CHECKERR(GL_TEXTURE_1D==textarget || GL_TEXTURE_3D==textarget, GL_INVALID_OPERATION, "textarget");
    555609
    556610#ifndef IN_GUEST
     
    592646    }
    593647
    594     CRSTATE_FBO_CHECKERR(zoffset>(g->limits.max3DTextureSize-1), GL_INVALID_VALUE, "zoffset too big");
    595     CRSTATE_FBO_CHECKERR(textarget!=GL_TEXTURE_3D, GL_INVALID_OPERATION, "textarget");
     648    CRSTATE_CHECKERR(zoffset>(g->limits.max3DTextureSize-1), GL_INVALID_VALUE, "zoffset too big");
     649    CRSTATE_CHECKERR(textarget!=GL_TEXTURE_3D, GL_INVALID_OPERATION, "textarget");
    596650
    597651#ifndef IN_GUEST
     
    618672    CRRenderbufferObject *rb;
    619673
    620     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    621     CRSTATE_FBO_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
     674    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     675    CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
    622676                         GL_INVALID_ENUM, "invalid target");
    623677    pFBO = GL_READ_FRAMEBUFFER==target ? fbo->readFB : fbo->drawFB;
    624     CRSTATE_FBO_CHECKERR(!pFBO, GL_INVALID_OPERATION, "no fbo bound");
    625     CRSTATE_FBO_CHECKERR(!crStateGetFBOAttachmentPoint(pFBO, attachment, &ap), GL_INVALID_ENUM, "invalid attachment");
     678    CRSTATE_CHECKERR(!pFBO, GL_INVALID_OPERATION, "no fbo bound");
     679    CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(pFBO, attachment, &ap), GL_INVALID_ENUM, "invalid attachment");
    626680
    627681    if (!renderbuffer)
     
    638692
    639693    rb = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, renderbuffer);
    640     CRSTATE_FBO_CHECKERR(!rb, GL_INVALID_OPERATION, "rb doesn't exist");
     694    if (!rb)
     695    {
     696        CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->rbTable, renderbuffer), GL_INVALID_OPERATION, "rb doesn't exist");
     697        rb = crStateRenderbufferAllocate(g, renderbuffer);
     698    }
    641699
    642700#ifdef IN_GUEST
     
    656714    CRContext *g = GetCurrentContext();
    657715    CRFramebufferObjectState *fbo = &g->framebufferobject;
    658     CRFramebufferObject *pFBO;
     716    CRFramebufferObject *apFBOs[2];
     717    GLint cFBOs = 0, i;
    659718    CRFBOAttachmentPoint *ap;
    660719
    661     CRSTATE_FBO_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    662     CRSTATE_FBO_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
     720    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
     721    CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)),
    663722                         GL_INVALID_ENUM, "invalid target");
    664     pFBO = GL_READ_FRAMEBUFFER==target ? fbo->readFB : fbo->drawFB;
    665     CRSTATE_FBO_CHECKERR(!pFBO, GL_INVALID_OPERATION, "no fbo bound");
    666     CRSTATE_FBO_CHECKERR(!crStateGetFBOAttachmentPoint(pFBO, attachment, &ap), GL_INVALID_ENUM, "invalid attachment");
    667 
    668     switch (pname)
    669     {
    670         case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
    671             *params = ap->type;
    672             break;
    673         case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
    674             CRSTATE_FBO_CHECKERR(ap->type!=GL_RENDERBUFFER_EXT && ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "can't query object name when it's not bound")
    675             *params = ap->name;
    676             break;
    677         case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT:
    678             CRSTATE_FBO_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture");
    679             *params = ap->level;
    680             break;
    681         case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT:
    682             CRSTATE_FBO_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture");
    683             *params = ap->face;
    684             break;
    685         case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT:
    686             CRSTATE_FBO_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture");
    687             *params = ap->zoffset;
    688             break;
    689         default:
    690             CRSTATE_FBO_CHECKERR(GL_TRUE, GL_INVALID_ENUM, "invalid pname");
    691     }
     723
     724    cFBOs = crStateFramebufferGet(fbo, target, apFBOs);
     725
     726    CRSTATE_CHECKERR(!cFBOs, GL_INVALID_OPERATION, "no fbo bound");
     727
     728    for (i = 0; i < cFBOs; ++i)
     729    {
     730        CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &ap), GL_INVALID_ENUM, "invalid attachment");
     731
     732        switch (pname)
     733        {
     734            case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
     735                *params = ap->type;
     736                break;
     737            case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
     738                CRSTATE_CHECKERR(ap->type!=GL_RENDERBUFFER_EXT && ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "can't query object name when it's not bound")
     739                *params = ap->name;
     740                break;
     741            case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT:
     742                CRSTATE_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture");
     743                *params = ap->level;
     744                break;
     745            case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT:
     746                CRSTATE_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture");
     747                *params = ap->face;
     748                break;
     749            case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT:
     750                CRSTATE_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture");
     751                *params = ap->zoffset;
     752                break;
     753            default:
     754                CRSTATE_CHECKERR(GL_TRUE, GL_INVALID_ENUM, "invalid pname");
     755        }
     756    }
     757}
     758
     759DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsFramebufferEXT( GLuint framebuffer )
     760{
     761    CRContext *g = GetCurrentContext();
     762    return crHashtableIsKeyUsed(g->shared->fbTable, framebuffer);
     763}
     764
     765DECLEXPORT(GLboolean)  STATE_APIENTRY crStateIsRenderbufferEXT( GLuint renderbuffer )
     766{
     767    CRContext *g = GetCurrentContext();
     768    return crHashtableIsKeyUsed(g->shared->rbTable, renderbuffer);
    692769}
    693770
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_special

    r25154 r44059  
    376376GetUniformLocation
    377377CopyTexImage2D
     378GenFramebuffersEXT
     379GenRenderbuffersEXT
     380GenBuffersARB
     381IsRenderbufferEXT
     382IsFramebufferEXT
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c

    r41313 r44059  
    621621}
    622622
    623 void STATE_APIENTRY crStateGenTextures(GLsizei n, GLuint *textures)
    624 {
    625     CRContext *g = GetCurrentContext();
     623void crStateGenNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names)
     624{
    626625    GLint start;
    627626
     
    631630    {
    632631        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
    633                                  "glGenTextures called in Begin/End");
     632                                 "crStateGenNames called in Begin/End");
    634633        return;
    635634    }
     
    638637    {
    639638        crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
    640                                  "Negative n passed to glGenTextures: %d", n);
    641         return;
    642     }
    643 
    644     start = crHashtableAllocKeys(g->shared->textureTable, n);
     639                                 "Negative n passed to crStateGenNames: %d", n);
     640        return;
     641    }
     642
     643    start = crHashtableAllocKeys(table, n);
    645644    if (start)
    646645    {
    647646        GLint i;
    648647        for (i = 0; i < n; i++)
    649             textures[i] = (GLuint) (start + i);
     648            names[i] = (GLuint) (start + i);
    650649    }
    651650    else
     
    653652        crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenTextures");
    654653    }
     654}
     655
     656void STATE_APIENTRY crStateGenTextures(GLsizei n, GLuint *textures)
     657{
     658    CRContext *g = GetCurrentContext();
     659    crStateGenNames(g, g->shared->textureTable, n, textures);
    655660}
    656661
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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