VirtualBox

Changeset 81431 in vbox


Ignore:
Timestamp:
Oct 21, 2019 7:54:52 PM (5 years ago)
Author:
vboxsync
Message:

Devices/Graphics: correct fix for flickering with D3D backend

Location:
trunk/src/VBox/Devices/Graphics
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h

    r81360 r81431  
    587587    /** Event query inserted after each GPU operation that updates or uses this surface. */
    588588    IDirect3DQuery9        *pQuery;
    589     /* The type of actually created D3D resource. */
     589    /** The context id where the query has been created. */
     590    uint32_t                idQueryContext;
     591    /** The type of actually created D3D resource. */
    590592    VMSVGA3DD3DRESTYPE      enmD3DResType;
    591593    union
     
    11161118D3DMULTISAMPLE_TYPE vmsvga3dMultipeSampleCount2D3D(uint32_t multisampleCount);
    11171119DECLCALLBACK(int) vmsvga3dSharedSurfaceDestroyTree(PAVLU32NODECORE pNode, void *pvParam);
    1118 int vmsvga3dSurfaceFlush(PVGASTATE pThis, PVMSVGA3DSURFACE pSurface);
     1120int vmsvga3dSurfaceFlush(PVMSVGA3DSURFACE pSurface);
    11191121#endif /* VMSVGA3D_DIRECT3D */
    11201122
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp

    r81360 r81431  
    13171317    LogFunc(("track usage of sid=%x (cid=%d) for cid=%d, pQuery %p\n", pSurface->id, pSurface->idAssociatedContext, pContext->id, pSurface->pQuery));
    13181318
    1319     /* Release the previous query object. */
    1320     D3D_RELEASE(pSurface->pQuery);
    1321 
    1322     /* Use the context where the texture has been created. */
    1323     int rc = vmsvga3dContextFromCid(pState, pSurface->idAssociatedContext, &pContext);
    1324     AssertRCReturn(rc, rc);
     1319    if (pSurface->idQueryContext == pContext->id)
     1320    {
     1321        /* Release the previous query object, if any. */
     1322        D3D_RELEASE(pSurface->pQuery);
     1323    }
     1324    else
     1325    {
     1326        /* Different context. There must be no pending drawing operations. If there are any, then a flush is missing. */
     1327        if (pSurface->pQuery)
     1328        {
     1329            /* Should not happen. */
     1330            AssertFailed();
     1331
     1332            /* Make sure that all drawing has completed. */
     1333            vmsvga3dSurfaceFlush(pSurface);
     1334        }
     1335        pSurface->idQueryContext = pContext->id;
     1336    }
    13251337
    13261338    HRESULT hr = pContext->pDevice->CreateQuery(D3DQUERYTYPE_EVENT, &pSurface->pQuery);
     
    13551367
    13561368/* Wait for all drawing, that uses this surface, to finish. */
    1357 int vmsvga3dSurfaceFlush(PVGASTATE pThis, PVMSVGA3DSURFACE pSurface)
     1369int vmsvga3dSurfaceFlush(PVMSVGA3DSURFACE pSurface)
    13581370{
    1359     RT_NOREF(pThis);
    13601371#ifndef VBOX_VMSVGA3D_WITH_WINE_OPENGL
    13611372    HRESULT hr;
     
    13761387        RTThreadSleep(1);
    13771388    }
     1389
     1390    D3D_RELEASE(pSurface->pQuery);
     1391
    13781392    AssertMsgReturn(hr == S_OK, ("vmsvga3dSurfaceFinishDrawing: GetData failed with %x\n", hr), VERR_INTERNAL_ERROR);
    1379 
    1380     D3D_RELEASE(pSurface->pQuery);
    13811393#endif /* !VBOX_VMSVGA3D_WITH_WINE_OPENGL */
    13821394
     
    15191531
    15201532        /* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
    1521         vmsvga3dSurfaceFlush(pThis, pSurfaceSrc);
    1522         vmsvga3dSurfaceFlush(pThis, pSurfaceDest);
     1533        vmsvga3dSurfaceFlush(pSurfaceSrc);
     1534        vmsvga3dSurfaceFlush(pSurfaceDest);
    15231535
    15241536        IDirect3DSurface9 *pSrc;
     
    16451657                {
    16461658                    /* Can lock both. */
    1647                     vmsvga3dSurfaceFlush(pThis, pSurfaceSrc);
    1648                     vmsvga3dSurfaceFlush(pThis, pSurfaceDest);
     1659                    vmsvga3dSurfaceFlush(pSurfaceSrc);
     1660                    vmsvga3dSurfaceFlush(pSurfaceDest);
    16491661
    16501662                    D3DLOCKED_RECT LockedSrcRect;
     
    17791791            {
    17801792                /* Must flush the context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
    1781                 vmsvga3dSurfaceFlush(pThis, pSurfaceSrc);
     1793                vmsvga3dSurfaceFlush(pSurfaceSrc);
    17821794
    17831795                hr = pD3DSurf->LockRect(&LockedSrcRect, &RectSrc, D3DLOCK_READONLY);
     
    18011813            {
    18021814                /* Must flush the context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
    1803                 vmsvga3dSurfaceFlush(pThis, pSurfaceDest);
     1815                vmsvga3dSurfaceFlush(pSurfaceDest);
    18041816
    18051817                hr = pD3DSurf->LockRect(&LockedDestRect, &RectDest, 0);
     
    18501862#endif
    18511863            AssertMsg(hr2 == D3D_OK, ("UpdateTexture failed with %x\n", hr2)); RT_NOREF(hr2);
     1864
     1865            /* Track the UpdateTexture operation. */
     1866            vmsvga3dSurfaceTrackUsage(pState, pContext, pSurfaceDest);
    18521867        }
    18531868
     
    22552270            pSurface->pMipmapLevels[i].pSurfaceData = NULL;
    22562271        }
     2272
     2273        /* Track the UpdateTexture operation. */
     2274        vmsvga3dSurfaceTrackUsage(pState, pContext, pSurface);
    22572275    }
    22582276    pSurface->fDirty = false;
     
    22882306                                  SVGA3dStretchBltMode enmMode, PVMSVGA3DCONTEXT pContext)
    22892307{
     2308    RT_NOREF(pThis);
     2309
    22902310    HRESULT hr;
    22912311    int rc;
     
    22952315
    22962316    /* Flush the drawing pipeline for this surface as it could be used in a shared context. */
    2297     vmsvga3dSurfaceFlush(pThis, pSrcSurface);
    2298     vmsvga3dSurfaceFlush(pThis, pDstSurface);
     2317    vmsvga3dSurfaceFlush(pSrcSurface);
     2318    vmsvga3dSurfaceFlush(pDstSurface);
    22992319
    23002320    RECT RectSrc;
     
    41804200
    41814201        /* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
    4182         vmsvga3dSurfaceFlush(pThis, pRenderTarget);
     4202        vmsvga3dSurfaceFlush(pRenderTarget);
    41834203
    41844204        if (pRenderTarget->surfaceFlags & SVGA3D_SURFACE_HINT_TEXTURE)
     
    44534473                           || pSurface->enmD3DResType == VMSVGA3D_D3DRESTYPE_VOLUME_TEXTURE);
    44544474                    /* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */
    4455                     vmsvga3dSurfaceFlush(pThis, pSurface);
     4475                    vmsvga3dSurfaceFlush(pSurface);
    44564476                }
    44574477
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp

    r81360 r81431  
    509509#ifdef VMSVGA3D_DIRECT3D
    510510        /* Flush the drawing pipeline for this surface as it could be used in a shared context. */
    511         vmsvga3dSurfaceFlush(pThis, pSurface);
     511        vmsvga3dSurfaceFlush(pSurface);
    512512
    513513#else /* VMSVGA3D_OPENGL */
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