VirtualBox

Ignore:
Timestamp:
Aug 28, 2012 11:12:02 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80361
Message:

crOpenGL: fix save state crash (work-around osx driver bug)

File:
1 edited

Legend:

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

    r41403 r43027  
    309309{
    310310    int32_t rc, face, i;
    311     GLboolean bound = GL_FALSE;
     311    GLint bound = 0;
    312312   
    313313    CRASSERT(pTexture && pSSM);
     
    342342                if (!bound)
    343343                {
     344                    GLenum getEnum;
    344345                    diff_api.BindTexture(pTexture->target, pTexture->hwid);
    345                     bound = GL_TRUE;
     346                    bound = 1;
     347
     348                    /* osx nvidia drivers seem to have a bug that 1x1 TEXTURE_2D texture becmes inaccessible for some reason
     349                     * saw that for 1x1 dummy textures generated by wine
     350                     * to avoid crashes we skip texture data save if that is the case */
     351                    switch (pTexture->target)
     352                    {
     353                        case GL_TEXTURE_1D:
     354                            getEnum = GL_TEXTURE_BINDING_1D;
     355                            break;
     356                        case GL_TEXTURE_2D:
     357                            getEnum = GL_TEXTURE_BINDING_2D;
     358                            break;
     359                        case GL_TEXTURE_3D:
     360                            getEnum = GL_TEXTURE_BINDING_3D;
     361                            break;
     362                        case GL_TEXTURE_RECTANGLE_ARB:
     363                            getEnum = GL_TEXTURE_BINDING_RECTANGLE_ARB;
     364                            break;
     365                        case GL_TEXTURE_CUBE_MAP_ARB:
     366                            getEnum = GL_TEXTURE_BINDING_CUBE_MAP_ARB;
     367                            break;
     368                        default:
     369                            crWarning("unknown texture target: 0x%x", pTexture->target);
     370                            getEnum = 0;
     371                            break;
     372                    }
     373
     374                    if (getEnum)
     375                    {
     376                        GLint curTex;
     377                        diff_api.GetIntegerv(getEnum, &curTex);
     378                        if (curTex != pTexture->hwid)
     379                        {
     380                            crWarning("texture not bound properly: expected %d, but was %d. Texture state data: target(0x%x), id(%d), w(%d), h(%d)",
     381                                    pTexture->hwid, curTex,
     382                                    pTexture->target,
     383                                    pTexture->id,
     384                                    ptl->width,
     385                                    ptl->height);
     386                            bound = -1;
     387                        }
     388                    }
     389
    346390                }
    347391
     
    363407
    364408#ifdef DEBUG
     409                *(int*)((char*)pImg+ptl->bytes) = 0xDEADDEAD;
     410#endif
     411                if (bound > 0)
    365412                {
    366                     GLint w,h=0;
    367                     *(int*)((char*)pImg+ptl->bytes) = 0xDEADDEAD;
    368                     crDebug("get image: compressed %i, face %i, level %i, width %i, height %i, bytes %i",
    369                             ptl->compressed, face, i, ptl->width, ptl->height, ptl->bytes);
    370                     diff_api.GetTexLevelParameteriv(target, i, GL_TEXTURE_WIDTH, &w);
    371                     diff_api.GetTexLevelParameteriv(target, i, GL_TEXTURE_HEIGHT, &h);
    372                     if (w!=ptl->width || h!=ptl->height)
     413#ifdef DEBUG
    373414                    {
    374                         crWarning("!!!tex size mismatch %i, %i!!!", w, h);
     415                        GLint w,h=0;
     416                        crDebug("get image: compressed %i, face %i, level %i, width %i, height %i, bytes %i",
     417                                ptl->compressed, face, i, ptl->width, ptl->height, ptl->bytes);
     418                        diff_api.GetTexLevelParameteriv(target, i, GL_TEXTURE_WIDTH, &w);
     419                        diff_api.GetTexLevelParameteriv(target, i, GL_TEXTURE_HEIGHT, &h);
     420                        if (w!=ptl->width || h!=ptl->height)
     421                        {
     422                            crWarning("!!!tex size mismatch %i, %i!!!", w, h);
     423                        }
     424                    }
     425#endif
     426
     427                    /*@todo: ugly workaround for crashes inside ati driver,
     428                     *       they overwrite their own allocated memory in cases where texlevel >=4
     429                             and width or height <=2.
     430                     */
     431                    if (i<4 || (ptl->width>2 && ptl->height>2))
     432                    {
     433                        if (!ptl->compressed)
     434                        {
     435                            diff_api.GetTexImage(target, i, ptl->format, ptl->type, pImg);
     436                        }
     437                        else
     438                        {
     439                            diff_api.GetCompressedTexImageARB(target, i, pImg);
     440                        }
    375441                    }
    376442                }
    377 #endif
    378 
    379                 /*@todo: ugly workaround for crashes inside ati driver,
    380                  *       they overwrite their own allocated memory in cases where texlevel >=4
    381                          and width or height <=2.
    382                  */
    383                 if (i<4 || (ptl->width>2 && ptl->height>2))
     443                else
    384444                {
    385                     if (!ptl->compressed)
    386                     {
    387                         diff_api.GetTexImage(target, i, ptl->format, ptl->type, pImg);
    388                     }
    389                     else
    390                     {
    391                         diff_api.GetCompressedTexImageARB(target, i, pImg);
    392                     }
     445                    crMemset(pImg, 0, ptl->bytes);
    393446                }
    394447
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