Changeset 32632 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Display
- Timestamp:
- Sep 20, 2010 10:36:25 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r32580 r32632 1837 1837 { 1838 1838 IDirect3DSurface9 *pD3D9OldSurf = (IDirect3DSurface9*)pAlloc->pD3DIf; 1839 if (pD3D9OldSurf) 1840 { 1841 VOID *pvSwapchain = NULL; 1842 HRESULT tmpHr = pD3D9OldSurf->GetContainer(IID_IDirect3DSwapChain9, &pvSwapchain); 1843 if (tmpHr != S_OK || pvSwapchain != ((IDirect3DSwapChain9 *)pSwapchain->pSwapChainIf)) 1844 { 1845 hr = pDevice->pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9Surf, NULL, D3DTEXF_NONE); 1846 Assert(hr == S_OK); 1847 } 1839 if (pD3D9OldSurf && pD3D9OldSurf != pD3D9Surf) 1840 { 1841 Assert(0); 1842 hr = pDevice->pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9Surf, NULL, D3DTEXF_NONE); 1843 Assert(hr == S_OK); 1848 1844 } 1849 1845 } … … 1871 1867 { 1872 1868 HRESULT hr = S_OK; 1873 for (int iBb = -1; iBb < int(pSwapchain->cRTs - 1); ++iBb) 1874 { 1875 hr = vboxWddmSwapchainRtSynch(pDevice, pSwapchain, (UINT)iBb); 1869 if (pSwapchain->cRTs > 1) 1870 { 1871 for (int iBb = -1; iBb < int(pSwapchain->cRTs - 1); ++iBb) 1872 { 1873 hr = vboxWddmSwapchainRtSynch(pDevice, pSwapchain, (UINT)iBb); 1874 Assert(hr == S_OK); 1875 } 1876 } 1877 else 1878 { 1879 /* work-around wine backbuffer */ 1880 hr = vboxWddmSwapchainRtSynch(pDevice, pSwapchain, 0); 1876 1881 Assert(hr == S_OK); 1877 1882 } … … 1909 1914 /* preserve the old one */ 1910 1915 IDirect3DSwapChain9 * pOldIf = pSwapchain->pSwapChainIf; 1911 /* first create the new one */ 1916 HRESULT hr = S_OK; 1917 BOOL bReuseSwapchain = FALSE; 1912 1918 D3DPRESENT_PARAMETERS Params; 1913 1919 vboxWddmSwapchainFillParams(pSwapchain, &Params); 1920 /* check if we need to re-create the swapchain */ 1921 if (pOldIf) 1922 { 1923 D3DPRESENT_PARAMETERS OldParams; 1924 hr = pOldIf->GetPresentParameters(&OldParams); 1925 Assert(hr == S_OK); 1926 if (hr == S_OK) 1927 { 1928 if (OldParams.BackBufferCount == Params.BackBufferCount) 1929 { 1930 bReuseSwapchain = TRUE; 1931 } 1932 } 1933 } 1934 1935 /* first create the new one */ 1914 1936 IDirect3DSwapChain9 * pNewIf; 1915 1937 /// 1916 1938 PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter; 1917 1939 UINT cSurfs = pSwapchain->cRTs; 1918 HRESULT hr = S_OK;1919 1940 IDirect3DDevice9 *pDevice9If = NULL; 1920 1941 HWND hOldWnd = pSwapchain->hWnd; 1942 if (!bReuseSwapchain) 1943 { 1921 1944 //#define VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE 1922 1945 #ifndef VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE 1923 if (!hOldWnd)1946 if (!hOldWnd) 1924 1947 #endif 1925 { 1926 hr = VBoxDispWndCreate(pAdapter, Params.BackBufferWidth, Params.BackBufferHeight, &pSwapchain->hWnd); 1927 Assert(hr == S_OK); 1928 } 1929 if (hr == S_OK) 1930 { 1931 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 1932 if (pDevice->fFlags.AllowMultithreading) 1933 fFlags |= D3DCREATE_MULTITHREADED; 1934 1935 Params.hDeviceWindow = pSwapchain->hWnd; 1936 /* @todo: it seems there should be a way to detect this correctly since 1937 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */ 1938 Params.Windowed = TRUE; 1939 // params.EnableAutoDepthStencil = FALSE; 1940 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN; 1941 // params.Flags; 1942 // params.FullScreen_RefreshRateInHz; 1943 // params.FullScreen_PresentationInterval; 1944 if (!pDevice->pDevice9If) 1945 { 1946 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pSwapchain->hWnd, fFlags, &Params, &pDevice9If); 1948 { 1949 hr = VBoxDispWndCreate(pAdapter, Params.BackBufferWidth, Params.BackBufferHeight, &pSwapchain->hWnd); 1947 1950 Assert(hr == S_OK); 1948 if (hr == S_OK) 1949 { 1950 pDevice->pDevice9If = pDevice9If; 1951 hr = pDevice9If->GetSwapChain(0, &pNewIf); 1951 } 1952 if (hr == S_OK) 1953 { 1954 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 1955 if (pDevice->fFlags.AllowMultithreading) 1956 fFlags |= D3DCREATE_MULTITHREADED; 1957 1958 Params.hDeviceWindow = pSwapchain->hWnd; 1959 /* @todo: it seems there should be a way to detect this correctly since 1960 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */ 1961 Params.Windowed = TRUE; 1962 // params.EnableAutoDepthStencil = FALSE; 1963 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN; 1964 // params.Flags; 1965 // params.FullScreen_RefreshRateInHz; 1966 // params.FullScreen_PresentationInterval; 1967 if (!pDevice->pDevice9If) 1968 { 1969 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pSwapchain->hWnd, fFlags, &Params, &pDevice9If); 1952 1970 Assert(hr == S_OK); 1953 1971 if (hr == S_OK) 1954 1972 { 1973 pDevice->pDevice9If = pDevice9If; 1974 hr = pDevice9If->GetSwapChain(0, &pNewIf); 1975 Assert(hr == S_OK); 1976 if (hr == S_OK) 1977 { 1978 Assert(pNewIf); 1979 } 1980 else 1981 { 1982 pDevice9If->Release(); 1983 } 1984 } 1985 } 1986 else 1987 { 1988 pDevice9If = pDevice->pDevice9If; 1989 hr = pDevice->pDevice9If->CreateAdditionalSwapChain(&Params, &pNewIf); 1990 Assert(hr == S_OK); 1991 if (hr == S_OK) 1992 { 1955 1993 Assert(pNewIf); 1956 1994 } 1957 else 1958 { 1959 pDevice9If->Release(); 1960 } 1961 } 1962 } 1963 else 1964 { 1965 pDevice9If = pDevice->pDevice9If; 1966 hr = pDevice->pDevice9If->CreateAdditionalSwapChain(&Params, &pNewIf); 1967 Assert(hr == S_OK); 1968 if (hr == S_OK) 1969 { 1970 Assert(pNewIf); 1971 } 1972 } 1973 1974 if (hr == S_OK) 1975 { 1976 Assert(pNewIf); 1977 pSwapchain->pSwapChainIf = pNewIf; 1995 } 1996 } 1997 } 1998 else 1999 { 2000 Assert(pOldIf); 2001 Assert(hOldWnd); 2002 pNewIf = pOldIf; 2003 /* to ensure the swapchain is not deleted once we release the pOldIf */ 2004 pNewIf->AddRef(); 2005 } 2006 2007 if (hr == S_OK) 2008 { 2009 Assert(pNewIf); 2010 pSwapchain->pSwapChainIf = pNewIf; 1978 2011 #ifndef VBOXWDDM_WITH_VISIBLE_FB 1979 1980 1981 1982 2012 if (!pSwapchain->pRenderTargetFbCopy) 2013 { 2014 IDirect3DSurface9* pD3D9Surf; 2015 hr = pDevice9If->CreateRenderTarget( 1983 2016 Params.BackBufferWidth, Params.BackBufferHeight, 1984 2017 Params.BackBufferFormat, … … 1989 2022 NULL /* HANDLE* pSharedHandle */ 1990 2023 ); 2024 Assert(hr == S_OK); 2025 if (hr == S_OK) 2026 { 2027 Assert(pD3D9Surf); 2028 pSwapchain->pRenderTargetFbCopy = pD3D9Surf; 2029 } 2030 } 2031 #endif 2032 2033 if (hr == S_OK) 2034 { 2035 for (UINT i = 0; i < cSurfs; ++i) 2036 { 2037 PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[i]; 2038 pRt->pAlloc->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 2039 } 2040 2041 hr = vboxWddmSwapchainSynch(pDevice, pSwapchain); 2042 Assert(hr == S_OK); 2043 if (hr == S_OK) 2044 { 2045 for (UINT i = 0; i < cSurfs; ++i) 2046 { 2047 PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[i]; 2048 hr = vboxWddmSurfSynchMem(pRt->pAlloc->pRc, pRt->pAlloc); 2049 Assert(hr == S_OK); 2050 if (hr != S_OK) 2051 { 2052 break; 2053 } 2054 } 2055 1991 2056 Assert(hr == S_OK); 1992 2057 if (hr == S_OK) 1993 2058 { 1994 Assert(pD3D9Surf); 1995 pSwapchain->pRenderTargetFbCopy = pD3D9Surf; 1996 } 1997 } 1998 #endif 1999 2000 if (hr == S_OK) 2001 { 2002 for (UINT i = 0; i < cSurfs; ++i) 2003 { 2004 PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[i]; 2005 pRt->pAlloc->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 2006 } 2007 2008 hr = vboxWddmSwapchainSynch(pDevice, pSwapchain); 2009 Assert(hr == S_OK); 2010 if (hr == S_OK) 2011 { 2012 for (UINT i = 0; i < cSurfs; ++i) 2059 Assert(pSwapchain->fFlags.Value == 0); 2060 if (pOldIf) 2013 2061 { 2014 PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[i]; 2015 hr = vboxWddmSurfSynchMem(pRt->pAlloc->pRc, pRt->pAlloc); 2016 Assert(hr == S_OK); 2017 if (hr != S_OK) 2062 Assert(hOldWnd); 2063 pOldIf->Release(); 2064 if (hOldWnd != pSwapchain->hWnd) 2018 2065 { 2019 break;2066 VBoxDispWndDestroy(pAdapter, hOldWnd); 2020 2067 } 2021 2068 } 2022 2023 Assert(hr == S_OK); 2024 if (hr == S_OK) 2069 else 2025 2070 { 2026 Assert(pSwapchain->fFlags.Value == 0); 2027 if (pOldIf) 2028 { 2029 Assert(hOldWnd); 2030 pOldIf->Release(); 2031 #ifdef VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE 2032 VBoxDispWndDestroy(pAdapter, hOldWnd); 2033 #endif 2034 } 2035 else 2036 { 2037 Assert(!hOldWnd); 2038 } 2039 return S_OK; 2071 Assert(!hOldWnd); 2040 2072 } 2073 return S_OK; 2041 2074 } 2042 2075 } … … 2046 2079 2047 2080 Assert(hr != S_OK); 2048 #ifndef VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE 2049 if (!hOldWnd) 2050 #endif 2081 if (hOldWnd != pSwapchain->hWnd) 2051 2082 { 2052 2083 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pSwapchain->hWnd); … … 5083 5114 vboxWddmSwapchainRtRemove(pSwapchain, pRt); 5084 5115 Assert(!vboxWddmSwapchainForAlloc(pAlloc)); 5116 if (!vboxWddmSwapchainNumRTs(pSwapchain)) 5117 vboxWddmSwapchainDestroy(pDevice, pSwapchain); 5085 5118 } 5086 5119
Note:
See TracChangeset
for help on using the changeset viewer.