VirtualBox

Changeset 54576 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 2, 2015 12:10:21 PM (10 years ago)
Author:
vboxsync
Message:

DevVGA-SVGA3d-ogl.cpp: recreate surfaces in vmsvga3dContextDestroy just like the windows code does, prevents several assertions around the place. We don't need a context in vmsvga3dSurfaceDestroy if there are no buffer/texture associated with the surface, so don't panic with an internal error during shutdown & reset cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp

    r54572 r54576  
    25962596            VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
    25972597        }
    2598         else
    2599         {
    2600             /* Pick any active context; we need something here */
     2598        /* If there is a GL buffer or something associated with the surface, we
     2599           really need something here, so pick any active context. */
     2600        else if (pSurface->oglId.buffer != OPENGL_INVALID_ID)
     2601        {
    26012602            for (cid = 0; cid < pState->cContexts; cid++)
    26022603            {
     
    26082609                }
    26092610            }
    2610             AssertReturn(pContext, VERR_INTERNAL_ERROR);    /* otherwise crashes/fails */
     2611            AssertReturn(pContext, VERR_INTERNAL_ERROR); /* otherwise crashes/fails; create temp context if this ever triggers! */
    26112612        }
    26122613
     
    27102711
    27112712/* Create D3D texture object for the specified surface. */
    2712 static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface)
     2713static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext,
     2714                                 PVMSVGA3DSURFACE pSurface)
    27132715{
    27142716    GLint activeTexture = 0;
     
    28772879}
    28782880
    2879 int vmsvga3dSurfaceDMA(PVGASTATE pThis, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer, uint32_t cCopyBoxes, SVGA3dCopyBox *pBoxes)
     2881int vmsvga3dSurfaceDMA(PVGASTATE pThis, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer,
     2882                       uint32_t cCopyBoxes, SVGA3dCopyBox *pBoxes)
    28802883{
    28812884    PVMSVGA3DSTATE          pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
     
    31433146                    if (RT_LIKELY(pbData != NULL))
    31443147                    {
     3148#if defined(VBOX_STRICT) && defined(RT_OS_DARWIN)
     3149                        GLint cbStrictBufSize;
     3150                        glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &cbStrictBufSize);
     3151                        Assert(VMSVGA3D_GL_IS_SUCCESS(pContext));
     3152                        AssertMsg(cbStrictBufSize >= (int32_t)pMipLevel->cbSurface,
     3153                                  ("cbStrictBufSize=%#x cbSurface=%#x isAssociatedContext=%#x pContext->id=%#x\n",
     3154                                   (uint32_t)cbStrictBufSize, pMipLevel->cbSurface, pSurface->idAssociatedContext, pContext->id));
     3155#endif
     3156
    31453157                        unsigned offDst = pBoxes[i].x * pSurface->cbBlock + pBoxes[i].y * pMipLevel->cbSurfacePitch;
    31463158                        if (RT_LIKELY(   offDst + pBoxes[i].w * pSurface->cbBlock  + (pBoxes[i].h - 1) * pMipLevel->cbSurfacePitch
     
    39663978            AssertRC(rc);
    39673979        }
     3980
     3981#if 1 /* This is done on windows - prevents various assertions at runtime, as well as shutdown & reset assertions when destroying surfaces. */
     3982        /* Check for all surfaces that are associated with this context to remove all dependencies */
     3983        for (uint32_t sid = 0; sid < pState->cSurfaces; sid++)
     3984        {
     3985            PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
     3986            if (    pSurface->idAssociatedContext == cid
     3987                &&  pSurface->id == sid)
     3988            {
     3989                int rc;
     3990
     3991                Log(("vmsvga3dContextDestroy: remove all dependencies for surface %x\n", sid));
     3992
     3993                uint32_t            surfaceFlags = pSurface->flags;
     3994                SVGA3dSurfaceFormat format = pSurface->format;
     3995                SVGA3dSurfaceFace   face[SVGA3D_MAX_SURFACE_FACES];
     3996                uint32_t            multisampleCount = pSurface->multiSampleCount;
     3997                SVGA3dTextureFilter autogenFilter = pSurface->autogenFilter;
     3998                SVGA3dSize         *pMipLevelSize;
     3999                uint32_t            cFaces = pSurface->cFaces;
     4000
     4001                pMipLevelSize = (SVGA3dSize *)RTMemAllocZ(pSurface->faces[0].numMipLevels * pSurface->cFaces * sizeof(SVGA3dSize));
     4002                AssertReturn(pMipLevelSize, VERR_NO_MEMORY);
     4003
     4004                for (uint32_t iFace = 0; iFace < pSurface->cFaces; iFace++)
     4005                {
     4006                    for (uint32_t i = 0; i < pSurface->faces[0].numMipLevels; i++)
     4007                    {
     4008                        uint32_t idx = i + iFace * pSurface->faces[0].numMipLevels;
     4009                        memcpy(&pMipLevelSize[idx], &pSurface->pMipmapLevels[idx].size, sizeof(SVGA3dSize));
     4010                    }
     4011                }
     4012                memcpy(face, pSurface->faces, sizeof(pSurface->faces));
     4013
     4014                /* Recreate the surface with the original settings; destroys the contents, but that seems fairly safe since the context is also destroyed. */
     4015                rc = vmsvga3dSurfaceDestroy(pThis, sid);
     4016                AssertRC(rc);
     4017
     4018                rc = vmsvga3dSurfaceDefine(pThis, sid, surfaceFlags, format, face, multisampleCount, autogenFilter, face[0].numMipLevels * cFaces, pMipLevelSize);
     4019                AssertRC(rc);
     4020            }
     4021        }
     4022#endif
    39684023
    39694024        if (pContext->idFramebuffer != OPENGL_INVALID_ID)
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