Changeset 37734 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm
- Timestamp:
- Jul 1, 2011 4:36:39 PM (13 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r37640 r37734 1529 1529 return hr; 1530 1530 } 1531 1532 #if 01533 static HRESULT vboxWddmRenderTargetUpdateSurface(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, uint32_t iBBuf)1534 {1535 if (pAlloc->SurfDesc.VidPnSourceId != pDevice->iPrimaryScreen)1536 return S_OK;1537 1538 IDirect3DSurface9 *pD3D9Surf;1539 IDirect3DDevice9 *pDevice9If = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If;1540 HRESULT hr = pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/,1541 iBBuf, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);1542 Assert(hr == S_OK);1543 if (hr == S_OK)1544 {1545 Assert(pD3D9Surf);1546 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);1547 if (pAlloc->pD3DIf)1548 pAlloc->pD3DIf->Release();1549 pAlloc->pD3DIf = pD3D9Surf;1550 }1551 return hr;1552 }1553 static HRESULT vboxWddmRenderTargetUpdate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, uint32_t iNewRTFB)1554 {1555 if (pRc->RcDesc.VidPnSourceId != pDevice->iPrimaryScreen)1556 return S_OK;1557 1558 PVBOXWDDMDISP_ALLOCATION pAlloc;1559 UINT iBBuf = 0;1560 Assert(iNewRTFB < pRc->cAllocations);1561 1562 for (UINT i = 1; i < pRc->cAllocations; ++i, ++iBBuf)1563 {1564 UINT iAlloc = (iNewRTFB + i) % pRc->cAllocations;1565 Assert(iAlloc != iNewRTFB);1566 pAlloc = &pRc->aAllocations[iAlloc];1567 HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, iBBuf);1568 Assert(tmpHr == S_OK);1569 }1570 1571 pAlloc = &pRc->aAllocations[iNewRTFB];1572 if (pRc->cAllocations > 1)1573 {1574 #ifdef VBOXWDDM_WITH_VISIBLE_FB1575 HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, ~0UL /* <- for the frontbuffer */);1576 Assert(tmpHr == S_OK);1577 #else1578 if (pAlloc->pD3DIf)1579 {1580 pAlloc->pD3DIf->Release();1581 pAlloc->pD3DIf = NULL;1582 }1583 #endif1584 }1585 else1586 {1587 #ifndef VBOXDISP_WITH_WINE_BB_WORKAROUND1588 # error "port me!"1589 #endif1590 /* work-around wine backbuffer for devices w/o backbuffers */1591 HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, 0);1592 Assert(tmpHr == S_OK);1593 }1594 1595 #ifdef DEBUG1596 for (UINT i = 0; i < pRc->cAllocations; ++i)1597 {1598 pAlloc = &pRc->aAllocations[i];1599 if (iNewRTFB == i)1600 {1601 Assert((!pAlloc->pD3DIf) == (pRc->cAllocations > 1));1602 }1603 1604 for (UINT j = i+1; j < pRc->cAllocations; ++j)1605 {1606 PVBOXWDDMDISP_ALLOCATION pAllocJ = &pRc->aAllocations[j];1607 Assert(pAlloc->pD3DIf != pAllocJ->pD3DIf);1608 }1609 }1610 #endif1611 return S_OK;1612 }1613 #endif1614 1531 1615 1532 static D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format) … … 1841 1758 { 1842 1759 #ifndef VBOXWDDM_WITH_VISIBLE_FB 1843 pSwapchain->pRenderTargetFbCopy->Release(); 1844 pSwapchain->pRenderTargetFbCopy = NULL; 1845 pSwapchain->bRTFbCopyUpToDate = FALSE; 1760 if (pSwapchain->pRenderTargetFbCopy) 1761 { 1762 pSwapchain->pRenderTargetFbCopy->Release(); 1763 pSwapchain->pRenderTargetFbCopy = NULL; 1764 pSwapchain->bRTFbCopyUpToDate = FALSE; 1765 } 1846 1766 #endif 1847 1767 pSwapchain->pSwapChainIf->Release(); … … 2192 2112 PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[iRt]; 2193 2113 HRESULT hr = pSwapchain->pSwapChainIf->GetBackBuffer(iBb, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 2194 Assert(hr == S_OK); 2195 if (hr == S_OK) 2196 { 2197 PVBOXWDDMDISP_ALLOCATION pAlloc = pRt->pAlloc; 2198 Assert(pD3D9Surf); 2199 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 2200 if (pAlloc->pD3DIf) 2201 { 2202 if (pSwapchain->fFlags.bChanged) 2203 { 2204 IDirect3DSurface9 *pD3D9OldSurf = (IDirect3DSurface9*)pAlloc->pD3DIf; 2205 if (pD3D9OldSurf && pD3D9OldSurf != pD3D9Surf) 2206 { 2207 VOID *pvSwapchain = NULL; 2208 HRESULT tmpHr = pD3D9OldSurf->GetContainer(IID_IDirect3DSwapChain9, &pvSwapchain); 2209 if (tmpHr == S_OK) 2210 { 2211 Assert(pvSwapchain); 2212 ((IDirect3DSwapChain9 *)pvSwapchain)->Release(); 2213 } 2214 else 2215 { 2216 Assert(!pvSwapchain); 2217 } 2218 if (pvSwapchain != pSwapchain->pSwapChainIf) 2219 { 2114 if (FAILED(hr)) 2115 { 2116 WARN(("GetBackBuffer failed, hr (0x%x)",hr)); 2117 return hr; 2118 } 2119 2120 PVBOXWDDMDISP_ALLOCATION pAlloc = pRt->pAlloc; 2121 Assert(pD3D9Surf); 2122 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 2123 if (pAlloc->pD3DIf) 2124 { 2125 if (pSwapchain->fFlags.bChanged) 2126 { 2127 IDirect3DSurface9 *pD3D9OldSurf = (IDirect3DSurface9*)pAlloc->pD3DIf; 2128 if (pD3D9OldSurf && pD3D9OldSurf != pD3D9Surf) 2129 { 2130 VOID *pvSwapchain = NULL; 2131 /* get the old surface's swapchain */ 2132 HRESULT tmpHr = pD3D9OldSurf->GetContainer(IID_IDirect3DSwapChain9, &pvSwapchain); 2133 if (tmpHr == S_OK) 2134 { 2135 Assert(pvSwapchain); 2136 ((IDirect3DSwapChain9 *)pvSwapchain)->Release(); 2137 } 2138 else 2139 { 2140 Assert(!pvSwapchain); 2141 } 2142 2143 if (pvSwapchain != pSwapchain->pSwapChainIf) 2144 { 2145 /* the swapchain has changed, copy data to the new surface */ 2220 2146 #ifdef DEBUG_misha 2221 2222 2147 /* @todo: we can not generally update the render target directly, implement */ 2148 Assert(iBb != (~0)); 2223 2149 #endif 2224 hr = pDevice->pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9Surf, NULL, D3DTEXF_NONE); 2225 Assert(hr == S_OK); 2226 if (pSwapchain->cRTs == 1) 2227 { 2228 /* synch bb and fb */ 2229 hr = pSwapchain->pSwapChainIf->Present(NULL, NULL, NULL, NULL, 0); 2230 Assert(hr == S_OK); 2231 if (hr == S_OK) 2232 { 2233 pD3D9Surf->Release(); 2234 hr = pSwapchain->pSwapChainIf->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 2235 Assert(hr == S_OK); 2236 if (hr == S_OK) 2237 { 2238 hr = pDevice->pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9Surf, NULL, D3DTEXF_NONE); 2239 Assert(hr == S_OK); 2240 } 2241 } 2242 } 2243 } 2244 } 2245 } 2246 pAlloc->pD3DIf->Release(); 2247 } 2248 pAlloc->pD3DIf = pD3D9Surf; 2249 pRt->fFlags.Value = 0; 2250 2251 if (pSwapchain->fFlags.bChanged) 2252 { 2253 for (UINT i = 0; i < pDevice->cRTs; ++i) 2254 { 2255 if (pDevice->apRTs[i] == pAlloc) 2256 { 2257 hr = vboxWddmRenderTargetSet(pDevice, i, pAlloc, TRUE); 2150 hr = pDevice->pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9Surf, NULL, D3DTEXF_NONE); 2258 2151 Assert(hr == S_OK); 2259 2152 } 2260 2153 } 2261 2154 } 2262 } 2155 pAlloc->pD3DIf->Release(); 2156 } 2157 2158 pAlloc->pD3DIf = pD3D9Surf; 2159 pRt->fFlags.Value = 0; 2160 2161 if (pSwapchain->fFlags.bChanged) 2162 { 2163 for (UINT i = 0; i < pDevice->cRTs; ++i) 2164 { 2165 if (pDevice->apRTs[i] == pAlloc) 2166 { 2167 hr = vboxWddmRenderTargetSet(pDevice, i, pAlloc, TRUE); 2168 Assert(hr == S_OK); 2169 } 2170 } 2171 } 2172 2173 #ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND 2174 if (pSwapchain->cRTs == 1) 2175 { 2176 /* here we sync the front-buffer with a backbuffer data*/ 2177 IDirect3DSurface9 *pD3D9Bb = (IDirect3DSurface9*)vboxWddmSwapchainGetBb(pSwapchain)->pAlloc->pD3DIf; 2178 Assert(pD3D9Bb); 2179 pD3D9Bb->AddRef(); 2180 /* we use backbuffer as a rt frontbuffer copy, so release the old one and assign the current bb */ 2181 if (pSwapchain->pRenderTargetFbCopy) 2182 { 2183 pSwapchain->pRenderTargetFbCopy->Release(); 2184 } 2185 pSwapchain->pRenderTargetFbCopy = pD3D9Bb; 2186 HRESULT tmpHr = pSwapchain->pSwapChainIf->GetFrontBufferData(pD3D9Bb); 2187 if (SUCCEEDED(tmpHr)) 2188 { 2189 VBOXVDBG_DUMP_SYNC_RT(pD3D9Bb); 2190 pSwapchain->bRTFbCopyUpToDate = TRUE; 2191 } 2192 else 2193 { 2194 WARN(("GetFrontBufferData failed, hr (0x%x)", hr)); 2195 } 2196 } 2197 #endif 2263 2198 return hr; 2264 2199 } … … 2299 2234 pParams->MultiSampleType = vboxDDI2D3DMultiSampleType(pRc->RcDesc.enmMultisampleType); 2300 2235 pParams->MultiSampleQuality = pRc->RcDesc.MultisampleQuality; 2301 #if def VBOXDISP_WITH_WINE_BB_WORKAROUND2236 #if 0 //def VBOXDISP_WITH_WINE_BB_WORKAROUND /* this does not work so far any way :( */ 2302 2237 if (pSwapchain->cRTs == 1) 2303 2238 pParams->SwapEffect = D3DSWAPEFFECT_COPY; … … 2478 2413 #ifndef VBOXWDDM_WITH_VISIBLE_FB 2479 2414 pSwapchain->bRTFbCopyUpToDate = FALSE; 2415 # ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND 2416 if (pSwapchain->cRTs == 1) 2417 { 2418 /* we will assign it to wine backbuffer on a swapchain synch */ 2419 if (pSwapchain->pRenderTargetFbCopy) 2420 { 2421 pSwapchain->pRenderTargetFbCopy->Release(); 2422 pSwapchain->pRenderTargetFbCopy = NULL; 2423 } 2424 } 2425 else 2426 # endif 2480 2427 if (!pSwapchain->pRenderTargetFbCopy) 2481 2428 { … … 2611 2558 } 2612 2559 2560 /* get the surface for the specified allocation in the swapchain */ 2561 static HRESULT vboxWddmSwapchainSurfGet(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DSurface9 **ppSurf) 2562 { 2563 Assert(pAlloc->pSwapchain == pSwapchain); 2564 2565 #ifndef VBOXWDDM_WITH_VISIBLE_FB 2566 if (vboxWddmSwapchainGetFb(pSwapchain)->pAlloc == pAlloc 2567 # ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND 2568 2569 && vboxWddmSwapchainNumRTs(pSwapchain) != 1 /* for swapchains w/o a backbuffer the alloc will contain the back-buffer actually */ 2570 ) 2571 { 2572 /* this is a front-buffer */ 2573 Assert(vboxWddmSwapchainNumRTs(pSwapchain) > 1); 2574 IDirect3DSurface9 *pSurf = pSwapchain->pRenderTargetFbCopy; 2575 Assert(pSurf); 2576 pSurf->AddRef(); 2577 if (!pSwapchain->bRTFbCopyUpToDate) 2578 { 2579 HRESULT hr = pSwapchain->pSwapChainIf->GetFrontBufferData(pSurf); 2580 if (FAILED(hr)) 2581 { 2582 WARN(("GetFrontBufferData failed, hr (0x%x)", hr)); 2583 return hr; 2584 } 2585 pSwapchain->bRTFbCopyUpToDate = TRUE; 2586 } 2587 2588 *ppSurf = pSurf; 2589 return S_OK; 2590 } 2591 # endif 2592 #endif 2593 2594 /* if this is not a front-buffer - just return the surface associated with the allocation */ 2595 return vboxWddmSurfGet(pAlloc->pRc, pAlloc->iAlloc, ppSurf); 2596 } 2597 2598 static HRESULT vboxWddmSwapchainRtSurfGet(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch, IDirect3DSurface9 **ppSurf) 2599 { 2600 Assert(pAlloc->pSwapchain == pSwapchain); 2601 HRESULT hr = S_OK; 2602 2603 /* do the necessary swapchain synchronization first, 2604 * not needed on swapchain synch since it is done already and we're called here just to set RTs */ 2605 if (!bOnSwapchainSynch) 2606 { 2607 2608 /* iRt != 0 is untested here !! */ 2609 Assert(iRt == 0); 2610 if (iRt == 0) 2611 { 2612 hr = vboxWddmSwapchainBbUpdate(pDevice, pSwapchain, pAlloc); 2613 if (FAILED(hr)) 2614 { 2615 WARN(("vboxWddmSwapchainBbUpdate failed, hr(0x%)",hr)); 2616 return hr; 2617 } 2618 } 2619 2620 Assert(!pSwapchain->fFlags.bChanged); 2621 Assert(pSwapchain->pSwapChainIf); 2622 hr = vboxWddmSwapchainChkCreateIf(pDevice, pSwapchain); 2623 if (FAILED(hr)) 2624 { 2625 WARN(("vboxWddmSwapchainChkCreateIf failed, hr(0x%)",hr)); 2626 return hr; 2627 } 2628 } 2629 2630 2631 Assert(vboxWddmSwapchainGetBb(pSwapchain)->pAlloc == pAlloc || iRt != 0); 2632 IDirect3DSurface9 *pSurf; 2633 hr = vboxWddmSwapchainSurfGet(pDevice, pSwapchain, pAlloc, &pSurf); 2634 if (FAILED(hr)) 2635 { 2636 WARN(("vboxWddmSwapchainSurfGet failed, hr(0x%x)", hr)); 2637 return hr; 2638 } 2639 2640 *ppSurf = pSurf; 2641 return S_OK; 2642 2643 } 2644 2613 2645 static HRESULT vboxWddmSwapchainPresent(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc) 2614 2646 { … … 2689 2721 #endif 2690 2722 2691 #if 02692 static HRESULT vboxWddmD3DDeviceCreate(PVBOXWDDMDISP_DEVICE pDevice, UINT iScreen, PVBOXWDDMDISP_RESOURCE pRc, D3DPRESENT_PARAMETERS * pParams, BOOL bLockable)2693 {2694 UINT cSurfs = pParams->BackBufferCount + 1;2695 Assert(pRc->cAllocations = cSurfs);2696 IDirect3DDevice9 *pPrimaryDevice = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If;2697 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[iScreen];2698 PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter;2699 HRESULT hr;2700 HWND hWnd = NULL;2701 Assert(!pScreen->pDevice9If);2702 Assert(!pScreen->hWnd);2703 hr = VBoxDispWndCreate(pAdapter, pParams->BackBufferWidth, pParams->BackBufferHeight, &hWnd);2704 Assert(hr == S_OK);2705 if (hr == S_OK)2706 {2707 pScreen->hWnd = hWnd;2708 2709 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;2710 if (pDevice->fFlags.AllowMultithreading)2711 fFlags |= D3DCREATE_MULTITHREADED;2712 2713 IDirect3DDevice9 *pDevice9If = NULL;2714 pParams->hDeviceWindow = hWnd;2715 /* @todo: it seems there should be a way to detect this correctly since2716 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */2717 pParams->Windowed = TRUE;2718 // params.EnableAutoDepthStencil = FALSE;2719 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN;2720 // params.Flags;2721 // params.FullScreen_RefreshRateInHz;2722 // params.FullScreen_PresentationInterval;2723 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, fFlags, pParams, &pDevice9If);2724 Assert(hr == S_OK);2725 if (hr == S_OK)2726 {2727 pScreen->pDevice9If = pDevice9If;2728 pScreen->pRenderTargetRc = pRc;2729 ++pDevice->cScreens;2730 2731 for (UINT i = 0; i < cSurfs; ++i)2732 {2733 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];2734 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;2735 }2736 2737 if (pPrimaryDevice)2738 {2739 for (UINT i = 0; i < cSurfs; ++i)2740 {2741 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];2742 IDirect3DSurface9 *pRt;2743 IDirect3DSurface9 *pSecondaryOpenedRt;2744 HANDLE hSharedHandle = NULL;2745 hr = pPrimaryDevice->CreateRenderTarget(2746 pParams->BackBufferWidth, pParams->BackBufferHeight,2747 pParams->BackBufferFormat,2748 pParams->MultiSampleType,2749 pParams->MultiSampleQuality,2750 TRUE, /*BOOL Lockable*/2751 &pRt,2752 &hSharedHandle);2753 Assert(hr == S_OK);2754 if (hr == S_OK)2755 {2756 Assert(hSharedHandle != NULL);2757 /* open render target for primary device */2758 hr = pDevice9If->CreateRenderTarget(2759 pParams->BackBufferWidth, pParams->BackBufferHeight,2760 pParams->BackBufferFormat,2761 pParams->MultiSampleType,2762 pParams->MultiSampleQuality,2763 TRUE, /*BOOL Lockable*/2764 &pSecondaryOpenedRt,2765 &hSharedHandle);2766 Assert(hr == S_OK);2767 if (hr == S_OK)2768 {2769 pAllocation->pD3DIf = pRt;2770 pAllocation->pSecondaryOpenedD3DIf = pSecondaryOpenedRt;2771 pAllocation->hSharedHandle = hSharedHandle;2772 continue;2773 }2774 pRt->Release();2775 }2776 2777 for (UINT j = 0; j < i; ++j)2778 {2779 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[j];2780 pAlloc->pD3DIf->Release();2781 pAlloc->pSecondaryOpenedD3DIf->Release();2782 }2783 2784 break;2785 }2786 }2787 else2788 {2789 pDevice->iPrimaryScreen = iScreen;2790 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0);2791 Assert(hr == S_OK);2792 }2793 2794 if (hr == S_OK)2795 {2796 for (UINT i = 0; i < cSurfs; ++i)2797 {2798 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];2799 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;2800 hr = vboxWddmSurfSynchMem(pRc, pAllocation);2801 Assert(hr == S_OK);2802 if (hr != S_OK)2803 {2804 break;2805 }2806 }2807 2808 #ifndef VBOXWDDM_WITH_VISIBLE_FB2809 if (!pPrimaryDevice)2810 {2811 if (hr == S_OK)2812 {2813 IDirect3DSurface9* pD3D9Surf;2814 hr = pDevice9If->CreateRenderTarget(2815 pParams->BackBufferWidth, pParams->BackBufferHeight,2816 pParams->BackBufferFormat,2817 pParams->MultiSampleType,2818 pParams->MultiSampleQuality,2819 bLockable,2820 &pD3D9Surf,2821 NULL /* HANDLE* pSharedHandle */2822 );2823 Assert(hr == S_OK);2824 if (hr == S_OK)2825 {2826 pDevice->pRenderTargetFbCopy = pD3D9Surf;2827 }2828 }2829 }2830 #endif2831 2832 if (hr != S_OK)2833 {2834 for (UINT i = 0; i < cSurfs; ++i)2835 {2836 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];2837 pAllocation->pD3DIf->Release();2838 }2839 }2840 }2841 2842 if (hr != S_OK)2843 {2844 pDevice9If->Release();2845 --pDevice->cScreens;2846 Assert(pDevice->cScreens < UINT32_MAX/2);2847 }2848 }2849 2850 if (hr != S_OK)2851 {2852 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pScreen->hWnd);2853 Assert(tmpHr == S_OK);2854 }2855 }2856 2857 return hr;2858 }2859 #endif2860 2723 static HRESULT vboxWddmD3DDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice) 2861 2724 { … … 2900 2763 } 2901 2764 2902 #if 02903 static HRESULT APIENTRY vboxWddmDDevDestroyResource(HANDLE hDevice, HANDLE hResource);2904 2905 static HRESULT vboxWddmD3DDeviceUpdate(PVBOXWDDMDISP_DEVICE pDevice, UINT iScreen, PVBOXWDDMDISP_RESOURCE pRc, D3DPRESENT_PARAMETERS * pParams, BOOL bLockable)2906 {2907 UINT cSurfs = pParams->BackBufferCount + 1;2908 Assert(pRc->cAllocations = cSurfs);2909 Assert(iScreen == pDevice->iPrimaryScreen);2910 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[iScreen];2911 PVBOXWDDMDISP_RESOURCE pCurRc = pScreen->pRenderTargetRc;2912 IDirect3DDevice9Ex *pNewDevice;2913 HRESULT hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9Update((IDirect3DDevice9Ex*)pScreen->pDevice9If, pParams, &pNewDevice);2914 Assert(hr == S_OK);2915 if (hr == S_OK)2916 {2917 pScreen->pDevice9If->Release();2918 pScreen->pDevice9If = pNewDevice;2919 pScreen->pRenderTargetRc = pRc;2920 2921 for (UINT i = 0; i < cSurfs; ++i)2922 {2923 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];2924 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;2925 }2926 2927 #ifndef VBOXWDDM_WITH_VISIBLE_FB2928 if (pDevice->pRenderTargetFbCopy)2929 {2930 pDevice->pRenderTargetFbCopy->Release();2931 }2932 IDirect3DSurface9* pD3D9Surf;2933 hr = pNewDevice->CreateRenderTarget(2934 pParams->BackBufferWidth, pParams->BackBufferHeight,2935 pParams->BackBufferFormat,2936 pParams->MultiSampleType,2937 pParams->MultiSampleQuality,2938 bLockable,2939 &pD3D9Surf,2940 NULL /* HANDLE* pSharedHandle */2941 );2942 Assert(hr == S_OK);2943 if (hr == S_OK)2944 {2945 pDevice->pRenderTargetFbCopy = pD3D9Surf;2946 }2947 #endif2948 if (hr == S_OK)2949 {2950 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0);2951 Assert(hr == S_OK);2952 if (hr == S_OK)2953 {2954 for (UINT i = 0; i < cSurfs; ++i)2955 {2956 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];2957 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;2958 hr = vboxWddmSurfSynchMem(pRc, pAllocation);2959 Assert(hr == S_OK);2960 if (hr != S_OK)2961 {2962 break;2963 }2964 }2965 }2966 }2967 }2968 2969 2970 if (!pCurRc->hResource)2971 {2972 HRESULT tmpHr = vboxWddmDDevDestroyResource(pDevice, pCurRc);2973 Assert(tmpHr == S_OK);2974 }2975 2976 return hr;2977 }2978 #endif2979 2765 /******/ 2980 2766 … … 2984 2770 PVBOXWDDMDISP_SWAPCHAIN pSwapchain = vboxWddmSwapchainForAlloc(pAlloc); 2985 2771 HRESULT hr = S_OK; 2772 IDirect3DSurface9 *pD3D9Surf; 2986 2773 if (pSwapchain) 2987 2774 { 2988 hr = vboxWddmSwapchain BbUpdate(pDevice, pSwapchain, pAlloc);2775 hr = vboxWddmSwapchainRtSurfGet(pDevice, pSwapchain, iRt, pAlloc, bOnSwapchainSynch, &pD3D9Surf); 2989 2776 if (FAILED(hr)) 2777 { 2778 WARN(("vboxWddmSwapchainRtSurfGet failed, hr(0x%)",hr)); 2990 2779 return hr; 2991 } 2992 2993 IDirect3DSurface9 *pD3D9Surf; 2994 if (!bOnSwapchainSynch && pSwapchain) 2995 { 2996 /* work-around wine double-buffering for the case we have no backbuffers */ 2997 Assert(!pSwapchain->fFlags.bChanged); 2998 Assert(pSwapchain->pSwapChainIf); 2999 vboxWddmSwapchainChkCreateIf(pDevice, pSwapchain); 3000 } 3001 3002 #ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND 3003 if (pSwapchain && vboxWddmSwapchainNumRTs(pSwapchain) == 1 && iRt == 0) 3004 { 3005 hr = pSwapchain->pSwapChainIf->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 3006 Assert(hr == S_OK); 3007 Assert(pD3D9Surf); 2780 } 3008 2781 } 3009 2782 else 3010 #endif3011 2783 { 3012 2784 hr = vboxWddmSurfGet(pAlloc->pRc, pAlloc->iAlloc, &pD3D9Surf); 3013 Assert(hr == S_OK); 3014 Assert(pD3D9Surf); 3015 } 3016 2785 if (FAILED(hr)) 2786 { 2787 WARN(("vboxWddmSurfGet failed, hr(0x%)",hr)); 2788 return hr; 2789 } 2790 } 2791 2792 Assert(pD3D9Surf); 2793 2794 hr = pDevice9If->SetRenderTarget(iRt, pD3D9Surf); 2795 Assert(hr == S_OK); 3017 2796 if (hr == S_OK) 3018 2797 { 3019 Assert(pD3D9Surf); 3020 hr = pDevice9If->SetRenderTarget(iRt, pD3D9Surf); 3021 Assert(hr == S_OK); 3022 if (hr == S_OK) 3023 { 3024 Assert(iRt < pDevice->cRTs); 3025 pDevice->apRTs[iRt] = pAlloc; 3026 } 3027 pD3D9Surf->Release(); 3028 } 2798 Assert(iRt < pDevice->cRTs); 2799 pDevice->apRTs[iRt] = pAlloc; 2800 } 2801 pD3D9Surf->Release(); 3029 2802 3030 2803 return hr; … … 4973 4746 if (pResource->Flags.SharedResource) 4974 4747 { 4975 Assert(0); /* <-- need to test that */4976 4748 bIssueCreateResource = true; 4977 4749 bCreateKMResource = true; … … 6136 5908 IDirect3DSurface9 *pSrcSurfIf = NULL; 6137 5909 IDirect3DSurface9 *pDstSurfIf = NULL; 5910 Assert(!pDstSwapchain || vboxWddmSwapchainGetFb(pDstSwapchain)->pAlloc != pDstAlloc || vboxWddmSwapchainNumRTs(pDstSwapchain) == 1); 6138 5911 hr = vboxWddmSurfGet(pDstRc, pData->DstSubResourceIndex, &pDstSurfIf); 6139 5912 Assert(hr == S_OK); … … 6143 5916 do 6144 5917 { 6145 #ifndef VBOXWDDM_WITH_VISIBLE_FB 6146 if (pSrcSwapchain 6147 && pSrcSwapchain->pRenderTargetFbCopy 6148 && vboxWddmSwapchainGetFb(pSrcSwapchain)->pAlloc == pSrcAlloc 6149 # ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND 6150 && vboxWddmSwapchainNumRTs(pSrcSwapchain) > 1 /* work-around wine backbuffer */ 6151 # endif 6152 ) 6153 { 6154 # if 0 6155 if (pData->DstRect.left == 0 && pData->DstRect.top == 0 6156 && pData->DstRect.right == pDstAlloc->SurfDesc.width 6157 && pData->DstRect.bottom == pDstAlloc->SurfDesc.height 6158 && pData->SrcRect.left == 0 && pData->SrcRect.top == 0 6159 && pData->SrcRect.right == pSrcAlloc->SurfDesc.width 6160 && pData->SrcRect.bottom == pSrcAlloc->SurfDesc.height 6161 && pSrcAlloc->SurfDesc.width == pDstAlloc->SurfDesc.width 6162 && pSrcAlloc->SurfDesc.height == pDstAlloc->SurfDesc.height 6163 && pSrcAlloc->SurfDesc.format == pDstAlloc->SurfDesc.format) 6164 { 6165 hr = pDevice9If->GetFrontBufferData(0, pDstSurfIf); 6166 Assert(hr == S_OK); 6167 break; 6168 } 6169 else 6170 # endif 6171 { 6172 pSrcSurfIf = pSrcSwapchain->pRenderTargetFbCopy; 6173 Assert(pSrcSurfIf); 6174 if (!pSrcSwapchain->bRTFbCopyUpToDate) 6175 { 6176 hr = pSrcSwapchain->pSwapChainIf->GetFrontBufferData(pSrcSurfIf); 6177 Assert(hr == S_OK); 6178 if (hr == S_OK) 6179 { 6180 /* do pSrcSurfIf->AddRef since we do a Release in the following if (hr == S_OK) branch */ 6181 pSrcSwapchain->bRTFbCopyUpToDate = TRUE; 6182 pSrcSurfIf->AddRef(); 6183 } 6184 } 6185 else 6186 { 6187 pSrcSurfIf->AddRef(); 6188 } 6189 } 5918 if (pSrcSwapchain) 5919 { 5920 hr = vboxWddmSwapchainSurfGet(pDevice, pSrcSwapchain, pSrcAlloc, &pSrcSurfIf); 5921 Assert(hr == S_OK); 6190 5922 } 6191 5923 else 6192 #endif6193 5924 { 6194 5925 hr = vboxWddmSurfGet(pSrcRc, pData->SrcSubResourceIndex, &pSrcSurfIf); … … 6225 5956 Assert(0); 6226 5957 } 6227 6228 6229 #if 06230 if ((use pAlloc->enmD3DIfType instead!!! pDstRc->RcDesc.fFlags.Texture || pDstRc->RcDesc.fFlags.Value == 0)6231 && (pSrcRc->RcDesc.fFlags.Texture || pSrcRc->RcDesc.fFlags.Value == 0))6232 {6233 IDirect3DBaseTexture9 *pD3DIfSrcTex = (IDirect3DBaseTexture9*)pSrcAlloc->pD3DIf;6234 IDirect3DBaseTexture9 *pD3DIfDstTex = (IDirect3DBaseTexture9*)pDstAlloc->pD3DIf;6235 Assert(pD3DIfSrcTex);6236 Assert(pD3DIfDstTex);6237 6238 if (pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat)6239 {6240 if (pSrcRc->aAllocations[0].SurfDesc.width == pDstRc->aAllocations[0].SurfDesc.width6241 && pSrcRc->aAllocations[0].SurfDesc.height == pDstRc->aAllocations[0].SurfDesc.height6242 && pData->DstRect.left == 0 && pData->DstRect.top == 06243 && pData->SrcRect.left == 0 && pData->SrcRect.top == 06244 && pData->SrcRect.right - pData->SrcRect.left == pSrcRc->aAllocations[0].SurfDesc.width6245 && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height6246 && pData->DstRect.right - pData->DstRect.left == pDstRc->aAllocations[0].SurfDesc.width6247 && pData->DstRect.bottom - pData->DstRect.top == pDstRc->aAllocations[0].SurfDesc.height6248 )6249 {6250 hr = pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);6251 Assert(hr == S_OK);6252 }6253 else if (pData->SrcRect.right - pData->SrcRect.left == pData->DstRect.right - pData->DstRect.left6254 && pData->SrcRect.bottom - pData->SrcRect.top == pData->DstRect.bottom - pData->DstRect.top)6255 {6256 Assert(pDstAlloc->SurfDesc.bpp);6257 Assert(pSrcAlloc->SurfDesc.bpp);6258 Assert(pSrcAlloc->SurfDesc.bpp == pDstAlloc->SurfDesc.bpp);6259 D3DLOCKED_RECT DstRect, SrcRect;6260 Assert(!pSrcAlloc->LockInfo.cLocks);6261 Assert(!pDstAlloc->LockInfo.cLocks);6262 hr = pD3DIfDstTex->LockRect(pData->DstSubResourceIndex, &DstRect, &pData->DstRect, D3DLOCK_DISCARD);6263 Assert(hr == S_OK);6264 if (hr == S_OK)6265 {6266 hr = pD3DIfSrcTex->LockRect(pData->SrcSubResourceIndex, &SrcRect, &pData->SrcRect, D3DLOCK_READONLY);6267 Assert(hr == S_OK);6268 if (hr == S_OK)6269 {6270 hr = vboxWddmRectBltPerform((uint8_t *)DstRect.pBits, (uint8_t *)SrcRect.pBits,6271 &pData->DstRect, &pData->SrcRect,6272 DstRect.Pitch, SrcRect.Pitch, pDstAlloc->SurfDesc.bpp);6273 Assert(hr == S_OK);6274 6275 pD3DIfSrcTex->UnlockRect(pData->SrcSubResourceIndex);6276 }6277 pD3DIfDstTex->UnlockRect(pData->DstSubResourceIndex);6278 }6279 }6280 else6281 {6282 6283 Assert(0);6284 /* @todo: impl */6285 }6286 }6287 else6288 {6289 Assert(0);6290 /* @todo: impl */6291 }6292 }6293 else6294 {6295 if (pData->SrcRect.right - pData->SrcRect.left == pData->DstRect.right - pData->DstRect.left6296 && pData->SrcRect.bottom - pData->SrcRect.top == pData->DstRect.bottom - pData->DstRect.top)6297 {6298 Assert(pDstAlloc->SurfDesc.bpp);6299 Assert(pSrcAlloc->SurfDesc.bpp);6300 Assert(pSrcAlloc->SurfDesc.bpp == pDstAlloc->SurfDesc.bpp);6301 6302 D3DLOCKED_RECT DstRect, SrcRect;6303 hr = vboxWddmLockRect(pDstAlloc, pData->DstSubResourceIndex, pDstRc->RcDesc.fFlags,6304 &DstRect, &pData->DstRect, D3DLOCK_DISCARD);6305 Assert(hr == S_OK);6306 if (hr == S_OK)6307 {6308 hr = vboxWddmLockRect(pSrcAlloc, pData->SrcSubResourceIndex, pSrcRc->RcDesc.fFlags,6309 &SrcRect, &pData->SrcRect, D3DLOCK_READONLY);6310 Assert(hr == S_OK);6311 if (hr == S_OK)6312 {6313 hr = vboxWddmRectBltPerform((uint8_t *)DstRect.pBits, (uint8_t *)SrcRect.pBits,6314 &pData->DstRect, &pData->SrcRect,6315 DstRect.Pitch, SrcRect.Pitch, pDstAlloc->SurfDesc.bpp);6316 Assert(hr == S_OK);6317 6318 HRESULT tmpHr = vboxWddmUnlockRect(pSrcAlloc, pData->SrcSubResourceIndex, pSrcRc->RcDesc.fFlags);6319 Assert(tmpHr == S_OK);6320 }6321 HRESULT tmpHr = vboxWddmUnlockRect(pDstAlloc, pData->DstSubResourceIndex, pDstRc->RcDesc.fFlags);6322 Assert(tmpHr == S_OK);6323 }6324 }6325 else6326 {6327 Assert(0);6328 /* @todo: impl */6329 }6330 }6331 #endif6332 5958 6333 5959 PVBOXWDDMDISP_ALLOCATION pDAlloc = &pDstRc->aAllocations[pData->DstSubResourceIndex]; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispDbg.cpp
r37640 r37734 50 50 51 51 #ifdef VBOXWDDMDISP_DEBUG 52 bool g_bVBoxVDbgFDumpSetTexture = false; 53 bool g_bVBoxVDbgFDumpDrawPrim = false; 54 bool g_bVBoxVDbgFDumpTexBlt = false; 55 bool g_bVBoxVDbgFDumpBlt = false; 52 DWORD g_VBoxVDbgFDumpSetTexture = 0; 53 DWORD g_VBoxVDbgFDumpDrawPrim = 0; 54 DWORD g_VBoxVDbgFDumpTexBlt = 0; 55 DWORD g_VBoxVDbgFDumpBlt = 0; 56 DWORD g_VBoxVDbgFDumpRtSynch = 0; 56 57 57 58 typedef enum -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispDbg.h
r37300 r37734 104 104 105 105 #ifdef VBOXWDDMDISP_DEBUG 106 extern bool g_bVBoxVDbgFDumpSetTexture; 107 extern bool g_bVBoxVDbgFDumpDrawPrim; 108 extern bool g_bVBoxVDbgFDumpTexBlt; 109 extern bool g_bVBoxVDbgFDumpBlt; 106 extern DWORD g_VBoxVDbgFDumpSetTexture; 107 extern DWORD g_VBoxVDbgFDumpDrawPrim; 108 extern DWORD g_VBoxVDbgFDumpTexBlt; 109 extern DWORD g_VBoxVDbgFDumpBlt; 110 extern DWORD g_VBoxVDbgFDumpRtSynch; 110 111 111 112 void vboxDispLogDrvF(char * szString, ...); … … 131 132 132 133 #define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { \ 133 if (g_ bVBoxVDbgFDumpDrawPrim) \134 if (g_VBoxVDbgFDumpDrawPrim) \ 134 135 { \ 135 136 vboxVDbgDoDumpRt("==>"__FUNCTION__": RenderTarget Dump\n", (_pDevice), "\n"); \ … … 138 139 139 140 #define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { \ 140 if (g_ bVBoxVDbgFDumpDrawPrim) \141 if (g_VBoxVDbgFDumpDrawPrim) \ 141 142 { \ 142 143 vboxVDbgDoDumpRt("<=="__FUNCTION__": RenderTarget Dump\n", (_pDevice), "\n"); \ … … 145 146 146 147 #define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { \ 147 if (g_ bVBoxVDbgFDumpSetTexture) \148 if (g_VBoxVDbgFDumpSetTexture) \ 148 149 { \ 149 150 vboxVDbgDoDumpRcRectByRc("== "__FUNCTION__": Texture Dump\n", _pRc, NULL, "\n"); \ … … 152 153 153 154 #define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \ 154 if (g_ bVBoxVDbgFDumpTexBlt) \155 if (g_VBoxVDbgFDumpTexBlt) \ 155 156 { \ 156 157 RECT _DstRect; \ … … 162 163 163 164 #define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \ 164 if (g_ bVBoxVDbgFDumpTexBlt) \165 if (g_VBoxVDbgFDumpTexBlt) \ 165 166 { \ 166 167 RECT _DstRect; \ … … 172 173 173 174 #define VBOXVDBG_DUMP_BLT_ENTER(_pSrcSurf, _pSrcRect, _pDstSurf, _pDstRect) do { \ 174 if (g_ bVBoxVDbgFDumpBlt) \175 if (g_VBoxVDbgFDumpBlt) \ 175 176 { \ 176 177 vboxVDbgDoDumpSurfRect("==>"__FUNCTION__" Src:\n", (_pSrcSurf), (_pSrcRect), "\n", true); \ … … 180 181 181 182 #define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcSurf, _pSrcRect, _pDstSurf, _pDstRect) do { \ 182 if (g_ bVBoxVDbgFDumpBlt) \183 if (g_VBoxVDbgFDumpBlt) \ 183 184 { \ 184 185 vboxVDbgDoDumpSurfRect("<=="__FUNCTION__" Src:\n", (_pSrcSurf), (_pSrcRect), "\n", true); \ 185 186 vboxVDbgDoDumpSurfRect("<=="__FUNCTION__" Dst:\n", (_pDstSurf), (_pDstRect), "\n", true); \ 187 } \ 188 } while (0) 189 190 #define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { \ 191 if (g_VBoxVDbgFDumpRtSynch) \ 192 { \ 193 vboxVDbgDoDumpSurfRect("== "__FUNCTION__" Bb:\n", (_pBbSurf), NULL, "\n", true); \ 186 194 } \ 187 195 } while (0) … … 194 202 #define VBOXVDBG_DUMP_BLT_ENTER(_pSrcSurf, _pSrcRect, _pDstSurf, _pDstRect) do { } while (0) 195 203 #define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcSurf, _pSrcRect, _pDstSurf, _pDstRect) do { } while (0) 204 #define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { } while (0) 196 205 #endif 197 206
Note:
See TracChangeset
for help on using the changeset viewer.