VirtualBox

Ignore:
Timestamp:
May 2, 2012 8:37:46 AM (13 years ago)
Author:
vboxsync
Message:

crOpenGL,wined3d,wddm: second part of fixing resource leakage, basics for cr commands submission from r0 miniport driver (for r0 visible region reporting, WPF 3D rendering fixes w/o Aero, etc.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp

    r41058 r41109  
    24692469    return hr;
    24702470}
    2471 
    2472 static HRESULT vboxWddmShRcRefAlloc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL fAddRef, DWORD *pcRefs)
    2473 {
    2474     D3DDDICB_ESCAPE DdiEscape = {0};
    2475     VBOXDISPIFESCAPE_SHRC_REF Data = {0};
    2476     DdiEscape.hContext = pDevice->DefaultContext.ContextInfo.hContext;
    2477     DdiEscape.hDevice = pDevice->hDevice;
    2478     DdiEscape.Flags.HardwareAccess = 1;
    2479     DdiEscape.pPrivateDriverData = &Data;
    2480     DdiEscape.PrivateDriverDataSize = sizeof (Data);
    2481     Data.EscapeHdr.escapeCode = fAddRef ? VBOXESC_SHRC_ADDREF : VBOXESC_SHRC_RELEASE;
    2482     Data.hAlloc = (uint64_t)pAlloc->hAllocation;
    2483     HRESULT hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);
    2484     if (FAILED(hr))
    2485     {
    2486         WARN(("pfnEscapeCb, hr (0x%x)", hr));
    2487         return TRUE;
    2488     }
    2489 
    2490     LOG(("shrc(0x%p) refs(%d)", (void*)pAlloc->hSharedHandle, Data.EscapeHdr.u32CmdSpecific));
    2491     if (pcRefs)
    2492         *pcRefs = Data.EscapeHdr.u32CmdSpecific;
    2493 
    2494     return hr;
    2495 }
    2496 
    2497 static HRESULT vboxWddmShRcRefRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, BOOL fAddRef, DWORD *pcRefs)
    2498 {
    2499     Assert(pRc->RcDesc.fFlags.SharedResource);
    2500     DWORD cTotalRefs = 0;
    2501     HRESULT hr = S_OK;
    2502     for (DWORD i = 0; i < pRc->cAllocations; ++i)
    2503     {
    2504         DWORD cRefs = 0;
    2505         PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    2506         if(!pAlloc->hSharedHandle)
    2507             continue;
    2508 
    2509         hr = vboxWddmShRcRefAlloc(pDevice, pAlloc, fAddRef, &cRefs);
    2510 
    2511         if (FAILED(hr))
    2512         {
    2513             WARN(("vboxWddmShRcRefAlloc failed, hr()0x%x", hr));
    2514             for (DWORD j = 0; j < i; ++j)
    2515             {
    2516                 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    2517                 if(!pAlloc->hSharedHandle)
    2518                     continue;
    2519                 HRESULT tmpHr = vboxWddmShRcRefAlloc(pDevice, pAlloc, !fAddRef, NULL);
    2520                 Assert(SUCCEEDED(tmpHr));
    2521             }
    2522             return hr;
    2523         }
    2524 
    2525         /* success! */
    2526         cTotalRefs += cRefs;
    2527     }
    2528 
    2529     Assert(cTotalRefs || !fAddRef);
    2530 
    2531     /* success! */
    2532     if (pcRefs)
    2533         *pcRefs = cTotalRefs;
    2534 
    2535     return S_OK;
    2536 }
    2537 
    25382471
    25392472static HRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
     
    56815614                    if (pResource->Flags.SharedResource)
    56825615                    {
    5683                         if (pAllocation->hSharedHandle)
    5684                         {
    5685                             vboxWddmShRcRefAlloc(pDevice, pAllocation, TRUE, NULL);
    5686                         }
    56875616#ifdef DEBUG_misha
    56885617                        Assert(VBOXWDDMDISP_IS_TEXTURE(pResource->Flags));
     
    57475676        for (UINT i = 0; i < pRc->cAllocations; ++i)
    57485677        {
    5749             BOOL fSetDelete = FALSE;
    57505678            PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
    57515679            if (pAlloc->hSharedHandle)
    57525680            {
    5753                 /* using one and the same shared resource by different clients could lead to the situation where one client can still refer to the resource
    5754                  * while another one has deleted it
    5755                  * this could lead to gl state corruption on both host and guest side.
    5756                  * This is why we take extra care to avoid it.
    5757                  * Until we do a vboxWddmShRcRefAlloc call below the resource is guarantied to be present, however it can be removed any time after the call
    5758                  * if cShRcRefs is non-zero, i.e. the current cliet is not the one deleting it.
    5759                  * We first explicitely say to wine that resource must NOT be accessed any more and that all references to it should be cleaned */
    5760                 pAdapter->D3D.pfnVBoxWineExD3DRc9SetShRcState((IDirect3DResource9*)pAlloc->pD3DIf, VBOXWINEEX_SHRC_STATE_GL_DISABLE);
    5761 
    5762                 DWORD cShRcRefs;
    5763                 HRESULT tmpHr = vboxWddmShRcRefAlloc(pDevice, pAlloc, FALSE, &cShRcRefs);
    5764                 if (!cShRcRefs)
    5765                 {
    5766                     /* the current client IS the one deleting this resource */
    5767                     fSetDelete = TRUE;
    5768                 }
    57695681#ifdef DEBUG_misha
    57705682                vboxVDbgPrint(("\n\n********\n(0x%x:0n%d)Shared DESTROYED pAlloc(0x%p), hRc(0x%p), hAl(0x%p), "
     
    57755687                            ));
    57765688#endif
    5777             }
    5778 
    5779             if (fSetDelete)
    5780             {
    5781                 Assert(pAlloc->pD3DIf);
    5782                 pAdapter->D3D.pfnVBoxWineExD3DRc9SetShRcState((IDirect3DResource9*)pAlloc->pD3DIf, VBOXWINEEX_SHRC_STATE_GL_DELETE);
    57835689            }
    57845690
     
    70916997                    Assert(pAllocation->hSharedHandle);
    70926998#endif
    7093 
    7094                     vboxWddmShRcRefAlloc(pDevice, pAllocation, TRUE, NULL);
    7095 
    70966999                    vboxVDbgPrint(("\n\n********\n(0x%x:0n%d)Shared OPENNED pAlloc(0x%p), hRc(0x%p), hAl(0x%p), "
    70977000                                    "Handle(0x%x), (0n%d) \n***********\n\n",
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