Changeset 41109 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Video/disp
- Timestamp:
- May 2, 2012 8:37:46 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r41058 r41109 2469 2469 return hr; 2470 2470 } 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 2538 2471 2539 2472 static HRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain) … … 5681 5614 if (pResource->Flags.SharedResource) 5682 5615 { 5683 if (pAllocation->hSharedHandle)5684 {5685 vboxWddmShRcRefAlloc(pDevice, pAllocation, TRUE, NULL);5686 }5687 5616 #ifdef DEBUG_misha 5688 5617 Assert(VBOXWDDMDISP_IS_TEXTURE(pResource->Flags)); … … 5747 5676 for (UINT i = 0; i < pRc->cAllocations; ++i) 5748 5677 { 5749 BOOL fSetDelete = FALSE;5750 5678 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i]; 5751 5679 if (pAlloc->hSharedHandle) 5752 5680 { 5753 /* using one and the same shared resource by different clients could lead to the situation where one client can still refer to the resource5754 * while another one has deleted it5755 * 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 call5758 * 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 }5769 5681 #ifdef DEBUG_misha 5770 5682 vboxVDbgPrint(("\n\n********\n(0x%x:0n%d)Shared DESTROYED pAlloc(0x%p), hRc(0x%p), hAl(0x%p), " … … 5775 5687 )); 5776 5688 #endif 5777 }5778 5779 if (fSetDelete)5780 {5781 Assert(pAlloc->pD3DIf);5782 pAdapter->D3D.pfnVBoxWineExD3DRc9SetShRcState((IDirect3DResource9*)pAlloc->pD3DIf, VBOXWINEEX_SHRC_STATE_GL_DELETE);5783 5689 } 5784 5690 … … 7091 6997 Assert(pAllocation->hSharedHandle); 7092 6998 #endif 7093 7094 vboxWddmShRcRefAlloc(pDevice, pAllocation, TRUE, NULL);7095 7096 6999 vboxVDbgPrint(("\n\n********\n(0x%x:0n%d)Shared OPENNED pAlloc(0x%p), hRc(0x%p), hAl(0x%p), " 7097 7000 "Handle(0x%x), (0n%d) \n***********\n\n",
Note:
See TracChangeset
for help on using the changeset viewer.