VirtualBox

Ignore:
Timestamp:
Jan 9, 2014 4:13:28 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91522
Message:

crOpenGL: crOpenGL: 1. workaround point sprite driver bugs; 2. workaround multi-string shader source driver bug; 3. proper GLhandle for OSX; 4. extended dumping; 5. misc fixes

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/VBox

  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp

    r49261 r50041  
    730730    crRecDumpLog(pRec, hwid);
    731731
    732     GLhandleARB *pShaders = (GLhandleARB*)crCalloc(cShaders * sizeof (*pShaders));
     732    VBoxGLhandleARB *pShaders = (VBoxGLhandleARB*)crCalloc(cShaders * sizeof (*pShaders));
    733733    if (!pShaders)
    734734    {
     
    741741    for (GLint i = 0; i < cShaders; ++i)
    742742    {
    743         crRecDumpShader(pRec, ctx, 0, pShaders[i]);
     743        if (pShaders[i])
     744            crRecDumpShader(pRec, ctx, 0, pShaders[i]);
     745        else
     746            crDmpStrF(pRec->pDumper, "WARNING: Shader[%d] is null", i);
    744747    }
    745748
     
    848851    crDmpStrF(pRec->pDumper, "==RECOMPILE PROGRAM ctx(%d) id(%d) hwid(%d) status(%d) shaders(%d)==", ctx->id, id, hwid, linkStatus, cShaders);
    849852
    850     GLhandleARB *pShaders = (GLhandleARB*)crCalloc(cShaders * sizeof (*pShaders));
     853    VBoxGLhandleARB *pShaders = (VBoxGLhandleARB*)crCalloc(cShaders * sizeof (*pShaders));
    851854    if (!pShaders)
    852855    {
     
    16651668}
    16661669
     1670DECLEXPORT(bool) crDmpHtmlIsInited(struct CR_HTML_DUMPER * pDumper)
     1671{
     1672    return !!pDumper->pFile;
     1673}
     1674
     1675DECLEXPORT(void) crDmpHtmlTerm(struct CR_HTML_DUMPER * pDumper)
     1676{
     1677    crDmpHtmlPrintFooter(pDumper);
     1678    fclose (pDumper->pFile);
     1679    pDumper->pFile = NULL;
     1680}
     1681
    16671682DECLEXPORT(int) crDmpHtmlInit(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile)
    16681683{
     
    17071722}
    17081723
     1724DECLEXPORT(int) crDmpHtmlInitV(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, va_list pArgList)
     1725{
     1726    char szBuffer[4096] = {0};
     1727    vsprintf_s(szBuffer, sizeof (szBuffer), pszFile, pArgList);
     1728    return crDmpHtmlInit(pDumper, pszDir, szBuffer);
     1729}
     1730
     1731DECLEXPORT(int) crDmpHtmlInitF(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, ...)
     1732{
     1733    int rc;
     1734    va_list pArgList;
     1735    va_start(pArgList, pszFile);
     1736    rc = crDmpHtmlInitV(pDumper, pszDir, pszFile, pArgList);
     1737    va_end(pArgList);
     1738    return rc;
     1739}
     1740
    17091741#endif
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py

    r46515 r50041  
    128128#endif
    129129"""
    130 
    131 from get_components import *;
    132130
    133131texenv_mappings = {
     
    195193"""
    196194for pname in texparam_names:
    197     print "\tcComponents = lookupComponents(%s);" % pname
     195    print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
    198196    print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
    199197    print "\tmemset(afBuf, 0, sizeof (afBuf));"
     
    222220    values = texenv_mappings[target]
    223221    for pname in values:
    224         print "\tcComponents = lookupComponents(%s);" % pname
     222        print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
    225223        print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
    226224        print "\tmemset(afBuf, 0, sizeof (afBuf));"
     
    247245    print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord
    248246    for pname in texgen_names:
    249         print "\tcComponents = lookupComponents(%s);" % pname
     247        print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
    250248        print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
    251249        print "\tmemset(afBuf, 0, sizeof (afBuf));"
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py

    r23694 r50041  
    234234        print '\t}'
    235235        print '}'
     236
     237from get_components import *
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c

    r48247 r50041  
    259259}
    260260
    261 DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( GLhandleARB obj )
     261DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( VBoxGLhandleARB obj )
    262262{
    263263    GLuint hwId = crStateGetProgramHWID(obj);
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_point.c

    r46037 r50041  
    201201        crStatePointParameterfvARB( pname, &f_param );
    202202}
     203
     204void crStatePointDiff(CRPointBits *b, CRbitvalue *bitID,
     205        CRContext *fromCtx, CRContext *toCtx)
     206{
     207    CRPointState *from = &(fromCtx->point);
     208    CRPointState *to = &(toCtx->point);
     209    unsigned int j, i;
     210    CRbitvalue nbitID[CR_MAX_BITARRAY];
     211    Assert(0);
     212    for (j=0;j<CR_MAX_BITARRAY;j++)
     213        nbitID[j] = ~bitID[j];
     214    i = 0; /* silence compiler */
     215    if (CHECKDIRTY(b->enableSmooth, bitID))
     216    {
     217        glAble able[2];
     218        able[0] = diff_api.Disable;
     219        able[1] = diff_api.Enable;
     220        if (from->pointSmooth != to->pointSmooth)
     221        {
     222            able[to->pointSmooth](GL_POINT_SMOOTH);
     223            from->pointSmooth = to->pointSmooth;
     224        }
     225        CLEARDIRTY(b->enableSmooth, nbitID);
     226    }
     227    if (CHECKDIRTY(b->size, bitID))
     228    {
     229        if (from->pointSize != to->pointSize)
     230        {
     231            diff_api.PointSize (to->pointSize);
     232            from->pointSize = to->pointSize;
     233        }
     234        CLEARDIRTY(b->size, nbitID);
     235    }
     236    if (CHECKDIRTY(b->minSize, bitID))
     237    {
     238        if (from->minSize != to->minSize)
     239        {
     240            diff_api.PointParameterfARB (GL_POINT_SIZE_MIN_ARB, to->minSize);
     241            from->minSize = to->minSize;
     242        }
     243        CLEARDIRTY(b->minSize, nbitID);
     244    }
     245    if (CHECKDIRTY(b->maxSize, bitID))
     246    {
     247        if (from->maxSize != to->maxSize)
     248        {
     249            diff_api.PointParameterfARB (GL_POINT_SIZE_MAX_ARB, to->maxSize);
     250            from->maxSize = to->maxSize;
     251        }
     252        CLEARDIRTY(b->maxSize, nbitID);
     253    }
     254    if (CHECKDIRTY(b->fadeThresholdSize, bitID))
     255    {
     256        if (from->fadeThresholdSize != to->fadeThresholdSize)
     257        {
     258            diff_api.PointParameterfARB (GL_POINT_FADE_THRESHOLD_SIZE_ARB, to->fadeThresholdSize);
     259            from->fadeThresholdSize = to->fadeThresholdSize;
     260        }
     261        CLEARDIRTY(b->fadeThresholdSize, nbitID);
     262    }
     263    if (CHECKDIRTY(b->spriteCoordOrigin, bitID))
     264    {
     265        if (from->spriteCoordOrigin != to->spriteCoordOrigin)
     266        {
     267            diff_api.PointParameterfARB (GL_POINT_SPRITE_COORD_ORIGIN, to->spriteCoordOrigin);
     268            from->spriteCoordOrigin = to->spriteCoordOrigin;
     269        }
     270        CLEARDIRTY(b->spriteCoordOrigin, nbitID);
     271    }
     272    if (CHECKDIRTY(b->distanceAttenuation, bitID))
     273    {
     274        if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) {
     275            diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation);
     276            from->distanceAttenuation[0] = to->distanceAttenuation[0];
     277            from->distanceAttenuation[1] = to->distanceAttenuation[1];
     278            from->distanceAttenuation[2] = to->distanceAttenuation[2];
     279        }
     280        CLEARDIRTY(b->distanceAttenuation, nbitID);
     281    }
     282    if (CHECKDIRTY(b->enableSprite, bitID))
     283    {
     284        glAble able[2];
     285        able[0] = diff_api.Disable;
     286        able[1] = diff_api.Enable;
     287        if (from->pointSprite != to->pointSprite)
     288        {
     289            able[to->pointSprite](GL_POINT_SPRITE_ARB);
     290            from->pointSprite = to->pointSprite;
     291        }
     292        CLEARDIRTY(b->enableSprite, nbitID);
     293    }
     294    {
     295        unsigned int activeUnit = (unsigned int) -1;
     296        for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) {
     297            if (CHECKDIRTY(b->coordReplacement[i], bitID))
     298            {
     299                GLint replacement = to->coordReplacement[i];
     300                if (activeUnit != i) {
     301                     diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB );
     302                     activeUnit = i;
     303                }
     304                diff_api.TexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &replacement);
     305                from->coordReplacement[i] = to->coordReplacement[i];
     306                CLEARDIRTY(b->coordReplacement[i], nbitID);
     307            }
     308        }
     309        if (activeUnit != toCtx->texture.curTextureUnit)
     310           diff_api.ActiveTextureARB(GL_TEXTURE0 + toCtx->texture.curTextureUnit);
     311    }
     312    CLEARDIRTY(b->dirty, nbitID);
     313}
     314
     315void crStatePointSwitch(CRPointBits *b, CRbitvalue *bitID,
     316        CRContext *fromCtx, CRContext *toCtx)
     317{
     318    CRPointState *from = &(fromCtx->point);
     319    CRPointState *to = &(toCtx->point);
     320    unsigned int j, i;
     321    GLboolean fEnabled;
     322    CRbitvalue nbitID[CR_MAX_BITARRAY];
     323    for (j=0;j<CR_MAX_BITARRAY;j++)
     324        nbitID[j] = ~bitID[j];
     325    i = 0; /* silence compiler */
     326    if (CHECKDIRTY(b->enableSmooth, bitID))
     327    {
     328        glAble able[2];
     329        able[0] = diff_api.Disable;
     330        able[1] = diff_api.Enable;
     331        if (from->pointSmooth != to->pointSmooth)
     332        {
     333            able[to->pointSmooth](GL_POINT_SMOOTH);
     334            FILLDIRTY(b->enableSmooth);
     335            FILLDIRTY(b->dirty);
     336        }
     337        CLEARDIRTY(b->enableSmooth, nbitID);
     338    }
     339    if (CHECKDIRTY(b->size, bitID))
     340    {
     341        if (from->pointSize != to->pointSize)
     342        {
     343            diff_api.PointSize (to->pointSize);
     344            FILLDIRTY(b->size);
     345            FILLDIRTY(b->dirty);
     346        }
     347        CLEARDIRTY(b->size, nbitID);
     348    }
     349    if (CHECKDIRTY(b->minSize, bitID))
     350    {
     351        if (from->minSize != to->minSize)
     352        {
     353            diff_api.PointParameterfARB (GL_POINT_SIZE_MIN_ARB, to->minSize);
     354            FILLDIRTY(b->minSize);
     355            FILLDIRTY(b->dirty);
     356        }
     357        CLEARDIRTY(b->minSize, nbitID);
     358    }
     359    if (CHECKDIRTY(b->maxSize, bitID))
     360    {
     361        if (from->maxSize != to->maxSize)
     362        {
     363            diff_api.PointParameterfARB (GL_POINT_SIZE_MAX_ARB, to->maxSize);
     364            FILLDIRTY(b->maxSize);
     365            FILLDIRTY(b->dirty);
     366        }
     367        CLEARDIRTY(b->maxSize, nbitID);
     368    }
     369    if (CHECKDIRTY(b->fadeThresholdSize, bitID))
     370    {
     371        if (from->fadeThresholdSize != to->fadeThresholdSize)
     372        {
     373            diff_api.PointParameterfARB (GL_POINT_FADE_THRESHOLD_SIZE_ARB, to->fadeThresholdSize);
     374            FILLDIRTY(b->fadeThresholdSize);
     375            FILLDIRTY(b->dirty);
     376        }
     377        CLEARDIRTY(b->fadeThresholdSize, nbitID);
     378    }
     379    if (CHECKDIRTY(b->spriteCoordOrigin, bitID))
     380    {
     381        if (from->spriteCoordOrigin != to->spriteCoordOrigin)
     382        {
     383            diff_api.PointParameterfARB (GL_POINT_SPRITE_COORD_ORIGIN, to->spriteCoordOrigin);
     384            FILLDIRTY(b->spriteCoordOrigin);
     385            FILLDIRTY(b->dirty);
     386        }
     387        CLEARDIRTY(b->spriteCoordOrigin, nbitID);
     388    }
     389    if (CHECKDIRTY(b->distanceAttenuation, bitID))
     390    {
     391        if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) {
     392            diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation);
     393            FILLDIRTY(b->distanceAttenuation);
     394            FILLDIRTY(b->dirty);
     395        }
     396        CLEARDIRTY(b->distanceAttenuation, nbitID);
     397    }
     398    fEnabled = from->pointSprite;
     399    {
     400        unsigned int activeUnit = (unsigned int) -1;
     401        for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) {
     402            if (CHECKDIRTY(b->coordReplacement[i], bitID))
     403            {
     404                if (!fEnabled)
     405                {
     406                    diff_api.Enable(GL_POINT_SPRITE_ARB);
     407                    fEnabled = GL_TRUE;
     408                }
     409#if 0
     410                /*don't set coord replacement, it will be set just before drawing points when necessary,
     411                 * to work around gpu driver bugs
     412                 * See crServerDispatch[Begin|End|Draw*] */
     413                GLint replacement = to->coordReplacement[i];
     414                if (activeUnit != i) {
     415                     diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB );
     416                     activeUnit = i;
     417                }
     418                diff_api.TexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &replacement);
     419#endif
     420                CLEARDIRTY(b->coordReplacement[i], nbitID);
     421            }
     422        }
     423        if (activeUnit != toCtx->texture.curTextureUnit)
     424           diff_api.ActiveTextureARB(GL_TEXTURE0 + toCtx->texture.curTextureUnit);
     425    }
     426    if (CHECKDIRTY(b->enableSprite, bitID))
     427    {
     428        glAble able[2];
     429        able[0] = diff_api.Disable;
     430        able[1] = diff_api.Enable;
     431        if (fEnabled != to->pointSprite)
     432        {
     433            able[to->pointSprite](GL_POINT_SPRITE_ARB);
     434            FILLDIRTY(b->enableSprite);
     435            FILLDIRTY(b->dirty);
     436        }
     437        CLEARDIRTY(b->enableSprite, nbitID);
     438    }
     439    else if (fEnabled != to->pointSprite)
     440    {
     441        glAble able[2];
     442        able[0] = diff_api.Disable;
     443        able[1] = diff_api.Enable;
     444        able[to->pointSprite](GL_POINT_SPRITE_ARB);
     445    }
     446    CLEARDIRTY(b->dirty, nbitID);
     447}
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c

    r48491 r50041  
    32603260                                                    const GLclampf *priorities)
    32613261{
    3262     UNUSED(n);
    3263     UNUSED(textures);
     3262    CRContext *g = GetCurrentContext();
     3263    CRTextureObj *tobj;
     3264    GLsizei i;
    32643265    UNUSED(priorities);
    3265     /* TODO: */
     3266
     3267    for (i = 0; i < n; ++i)
     3268    {
     3269        GLuint tex = textures[i];
     3270        GET_TOBJ(tobj, g, tex);
     3271        if (!tobj)
     3272        {
     3273            Assert(crHashtableIsKeyUsed(g->shared->textureTable, tex));
     3274            tobj = crStateTextureAllocate_t(g, tex);
     3275        }
     3276
     3277        /* so far the code just ensures the tex object is created to make
     3278         * the crserverlib code be able to pass it to host ogl */
     3279
     3280        /* TODO: store texture priorities in the state data to be able to restore it properly
     3281         * on save state load */
     3282    }
     3283
    32663284    return;
    32673285}
Note: See TracChangeset for help on using the changeset viewer.

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