- Timestamp:
- Aug 19, 2010 5:03:40 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r31740 r31797 1069 1069 static HRESULT vboxWddmRenderTargetUpdateSurface(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, uint32_t iBBuf) 1070 1070 { 1071 if (pAlloc->SurfDesc.VidPnSourceId != pDevice->iPrimaryScreen) 1072 return S_OK; 1073 1071 1074 IDirect3DSurface9 *pD3D9Surf; 1072 HRESULT hr = pDevice->pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/, 1075 IDirect3DDevice9 *pDevice9If = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If; 1076 HRESULT hr = pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/, 1073 1077 iBBuf, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 1074 1078 Assert(hr == S_OK); … … 1085 1089 static HRESULT vboxWddmRenderTargetUpdate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, uint32_t iNewRTFB) 1086 1090 { 1091 if (pRc->RcDesc.VidPnSourceId != pDevice->iPrimaryScreen) 1092 return S_OK; 1093 1087 1094 PVBOXWDDMDISP_ALLOCATION pAlloc; 1088 1095 UINT iBBuf = 0; … … 1134 1141 IDirect3DSurface9 *pD3D9Surf; 1135 1142 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 1136 HRESULT hr = pDevice->pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/, 1143 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1144 Assert(pScreen->hWnd); 1145 Assert(pScreen->pDevice9If); 1146 HRESULT hr = pScreen->pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/, 1137 1147 iBBuf, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 1138 1148 Assert(hr == S_OK); … … 1182 1192 } 1183 1193 1184 # define VBOXVDBG_RTGT_STATECHECK(_pDev) (vboxWddmDbgRenderTargetCheck((_pDev), (_pDev)-> pRenderTargetRc, (_pDev)->iRenderTargetFrontBuf))1194 # define VBOXVDBG_RTGT_STATECHECK(_pDev) (vboxWddmDbgRenderTargetCheck((_pDev), (_pDev)->aScreens[(_pDev)->iPrimaryScreen].pRenderTargetRc, (_pDev)->aScreens[(_pDev)->iPrimaryScreen].iRenderTargetFrontBuf)) 1185 1195 #else 1186 1196 # define VBOXVDBG_RTGT_STATECHECK(_pDev) do{}while(0) … … 1766 1776 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1767 1777 Assert(pDevice); 1768 Assert(pDevice->pDevice9If); 1769 HRESULT hr = pDevice->pDevice9If->SetRenderState(vboxDDI2D3DRenderStateType(pData->State), pData->Value); 1778 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1779 Assert(pScreen->hWnd); 1780 Assert(pScreen->pDevice9If); 1781 HRESULT hr = pScreen->pDevice9If->SetRenderState(vboxDDI2D3DRenderStateType(pData->State), pData->Value); 1770 1782 Assert(hr == S_OK); 1771 1783 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1793 1805 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1794 1806 Assert(pDevice); 1795 Assert(pDevice->pDevice9If); 1807 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1808 Assert(pScreen->hWnd); 1809 Assert(pScreen->pDevice9If); 1796 1810 1797 1811 VBOXWDDMDISP_TSS_LOOKUP lookup = vboxDDI2D3DTestureStageStateType(pData->State); … … 1800 1814 if (!lookup.bSamplerState) 1801 1815 { 1802 hr = p Device->pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value);1816 hr = pScreen->pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value); 1803 1817 } 1804 1818 else 1805 1819 { 1806 hr = p Device->pDevice9If->SetSamplerState(pData->Stage, D3DSAMPLERSTATETYPE(lookup.dType), pData->Value);1820 hr = pScreen->pDevice9If->SetSamplerState(pData->Stage, D3DSAMPLERSTATETYPE(lookup.dType), pData->Value); 1807 1821 } 1808 1822 … … 1817 1831 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1818 1832 Assert(pDevice); 1819 Assert(pDevice->pDevice9If); 1833 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1834 Assert(pScreen->hWnd); 1835 Assert(pScreen->pDevice9If); 1820 1836 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)hTexture; 1821 1837 // Assert(pRc); … … 1830 1846 1831 1847 // Assert(pD3DIfTex); 1832 HRESULT hr = p Device->pDevice9If->SetTexture(Stage, pD3DIfTex);1848 HRESULT hr = pScreen->pDevice9If->SetTexture(Stage, pD3DIfTex); 1833 1849 Assert(hr == S_OK); 1834 1850 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1841 1857 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1842 1858 Assert(pDevice); 1843 Assert(pDevice->pDevice9If); 1859 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1860 Assert(pScreen->hWnd); 1861 Assert(pScreen->pDevice9If); 1844 1862 IDirect3DPixelShader9 *pShader = (IDirect3DPixelShader9*)hShaderHandle; 1845 1863 Assert(pShader); 1846 HRESULT hr = p Device->pDevice9If->SetPixelShader(pShader);1864 HRESULT hr = pScreen->pDevice9If->SetPixelShader(pShader); 1847 1865 Assert(hr == S_OK); 1848 1866 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1855 1873 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1856 1874 Assert(pDevice); 1857 Assert(pDevice->pDevice9If); 1858 HRESULT hr = pDevice->pDevice9If->SetPixelShaderConstantF(pData->Register, pRegisters, pData->Count); 1875 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1876 Assert(pScreen->hWnd); 1877 Assert(pScreen->pDevice9If); 1878 HRESULT hr = pScreen->pDevice9If->SetPixelShaderConstantF(pData->Register, pRegisters, pData->Count); 1859 1879 Assert(hr == S_OK); 1860 1880 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1867 1887 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1868 1888 Assert(pDevice); 1869 Assert(pDevice->pDevice9If); 1889 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1890 Assert(pScreen->hWnd); 1891 Assert(pScreen->pDevice9If); 1870 1892 HRESULT hr = S_OK; 1871 1893 // IDirect3DVertexBuffer9 *pStreamData; … … 1898 1920 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1899 1921 Assert(pDevice); 1900 Assert(pDevice->pDevice9If); 1922 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1923 Assert(pScreen->hWnd); 1924 Assert(pScreen->pDevice9If); 1901 1925 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hIndexBuffer; 1902 1926 PVBOXWDDMDISP_ALLOCATION pAlloc = NULL; … … 1909 1933 pIndexBuffer = (IDirect3DIndexBuffer9*)pAlloc->pD3DIf; 1910 1934 } 1911 HRESULT hr = p Device->pDevice9If->SetIndices(pIndexBuffer);1935 HRESULT hr = pScreen->pDevice9If->SetIndices(pIndexBuffer); 1912 1936 Assert(hr == S_OK); 1913 1937 if (hr == S_OK) … … 1925 1949 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1926 1950 Assert(pDevice); 1927 Assert(pDevice->pDevice9If); 1951 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1952 Assert(pScreen->hWnd); 1953 Assert(pScreen->pDevice9If); 1928 1954 HRESULT hr = S_OK; 1929 1955 pDevice->IndiciesUm.pvBuffer = pUMBuffer; … … 1938 1964 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1939 1965 Assert(pDevice); 1940 Assert(pDevice->pDevice9If); 1966 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1967 Assert(pScreen->hWnd); 1968 Assert(pScreen->pDevice9If); 1941 1969 Assert(!pFlagBuffer); 1942 1970 HRESULT hr = S_OK; … … 1958 1986 } 1959 1987 #endif 1960 hr = p Device->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType,1988 hr = pScreen->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, 1961 1989 pData->PrimitiveCount, 1962 1990 ((uint8_t*)pDevice->aStreamSourceUm[0].pvBuffer) + pData->VStart * pDevice->aStreamSourceUm[0].cbStride, … … 1994 2022 Assert(cStreams == pDevice->cStreamSources); 1995 2023 #endif 1996 hr = p Device->pDevice9If->DrawPrimitive(pData->PrimitiveType,2024 hr = pScreen->pDevice9If->DrawPrimitive(pData->PrimitiveType, 1997 2025 pData->VStart, 1998 2026 pData->PrimitiveCount); … … 2002 2030 #if 0 2003 2031 IDirect3DVertexDeclaration9* pDecl; 2004 hr = p Device->pDevice9If->GetVertexDeclaration(&pDecl);2032 hr = pScreen->pDevice9If->GetVertexDeclaration(&pDecl); 2005 2033 Assert(hr == S_OK); 2006 2034 if (hr == S_OK) … … 2127 2155 UINT cbOffset; 2128 2156 UINT cbStride; 2129 hr = p Device->pDevice9If->GetStreamSource(iStream, &pCurVb, &cbOffset, &cbStride);2157 hr = pScreen->pDevice9If->GetStreamSource(iStream, &pCurVb, &cbOffset, &cbStride); 2130 2158 Assert(hr == S_OK); 2131 2159 if (hr == S_OK) … … 2154 2182 if (!pVb) 2155 2183 { 2156 hr = p Device->pDevice9If->CreateVertexBuffer(cbVertexes,2184 hr = pScreen->pDevice9If->CreateVertexBuffer(cbVertexes, 2157 2185 0, /* DWORD Usage */ 2158 2186 0, /* DWORD FVF */ … … 2163 2191 if (hr == S_OK) 2164 2192 { 2165 hr = p Device->pDevice9If->SetStreamSource(iStream, pVb, 0, pStrSrc->cbStride);2193 hr = pScreen->pDevice9If->SetStreamSource(iStream, pVb, 0, pStrSrc->cbStride); 2166 2194 Assert(hr == S_OK); 2167 2195 if (hr == S_OK) … … 2200 2228 if (hr == S_OK) 2201 2229 { 2202 hr = p Device->pDevice9If->DrawPrimitive(pData->PrimitiveType,2230 hr = pScreen->pDevice9If->DrawPrimitive(pData->PrimitiveType, 2203 2231 0 /* <- since we use our owne StreamSource buffer which has data at the very beginning*/, 2204 2232 pData->PrimitiveCount); … … 2224 2252 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2225 2253 Assert(pDevice); 2226 Assert(pDevice->pDevice9If); 2254 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2255 Assert(pScreen->hWnd); 2256 Assert(pScreen->pDevice9If); 2227 2257 //#ifdef DEBUG_misha 2228 2258 // uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; … … 2254 2284 #endif 2255 2285 2256 HRESULT hr = p Device->pDevice9If->DrawIndexedPrimitive(2286 HRESULT hr = pScreen->pDevice9If->DrawIndexedPrimitive( 2257 2287 pData->PrimitiveType, 2258 2288 pData->BaseVertexIndex, … … 2295 2325 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2296 2326 Assert(pDevice); 2297 Assert(pDevice->pDevice9If); 2327 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2328 Assert(pScreen->hWnd); 2329 Assert(pScreen->pDevice9If); 2298 2330 HRESULT hr; 2299 2331 … … 2325 2357 } 2326 2358 2327 hr = p Device->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount);2359 hr = pScreen->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount); 2328 2360 #else 2329 2361 //#ifdef DEBUG_misha … … 2354 2386 2355 2387 Assert(pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite)); 2356 hr = p Device->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, pData->PrimitiveCount,2388 hr = pScreen->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, pData->PrimitiveCount, 2357 2389 (void*)((uintptr_t)pDevice->aStreamSource[stream]->pvMem+pDevice->StreamSourceInfo[stream].uiOffset+pData->FirstVertexOffset), 2358 2390 pDevice->StreamSourceInfo[stream].uiStride); 2359 2391 Assert(hr == S_OK); 2360 hr = p Device->pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride);2392 hr = pScreen->pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride); 2361 2393 Assert(hr == S_OK); 2362 2394 } … … 2365 2397 // vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n")); 2366 2398 2367 hr = p Device->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);2399 hr = pScreen->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount); 2368 2400 Assert(hr == S_OK); 2369 2401 } … … 2417 2449 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2418 2450 Assert(pDevice); 2419 Assert(pDevice->pDevice9If); 2451 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2452 Assert(pScreen->hWnd); 2453 Assert(pScreen->pDevice9If); 2420 2454 PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource; 2421 2455 PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; … … 2439 2473 && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height) 2440 2474 { 2441 hr = p Device->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);2475 hr = pScreen->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex); 2442 2476 Assert(hr == S_OK); 2443 2477 } … … 2487 2521 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2488 2522 Assert(pDevice); 2489 Assert(pDevice->pDevice9If); 2490 HRESULT hr = pDevice->pDevice9If->Clear(NumRect, (D3DRECT*)pRect /* see AssertCompile above */, 2523 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2524 Assert(pScreen->hWnd); 2525 Assert(pScreen->pDevice9If); 2526 HRESULT hr = pScreen->pDevice9If->Clear(NumRect, (D3DRECT*)pRect /* see AssertCompile above */, 2491 2527 pData->Flags, 2492 2528 pData->FillColor, … … 2518 2554 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2519 2555 Assert(pDevice); 2520 Assert(pDevice->pDevice9If); 2521 HRESULT hr = pDevice->pDevice9If->SetVertexShaderConstantF( 2556 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2557 Assert(pScreen->hWnd); 2558 Assert(pScreen->pDevice9If); 2559 HRESULT hr = pScreen->pDevice9If->SetVertexShaderConstantF( 2522 2560 pData->Register, 2523 2561 (CONST float*)pRegisters, … … 2546 2584 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2547 2585 Assert(pDevice); 2548 Assert(pDevice->pDevice9If); 2586 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2587 Assert(pScreen->hWnd); 2588 Assert(pScreen->pDevice9If); 2549 2589 pDevice->ViewPort.X = pData->X; 2550 2590 pDevice->ViewPort.Y = pData->Y; 2551 2591 pDevice->ViewPort.Width = pData->Width; 2552 2592 pDevice->ViewPort.Height = pData->Height; 2553 HRESULT hr = p Device->pDevice9If->SetViewport(&pDevice->ViewPort);2593 HRESULT hr = pScreen->pDevice9If->SetViewport(&pDevice->ViewPort); 2554 2594 Assert(hr == S_OK); 2555 2595 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 2561 2601 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2562 2602 Assert(pDevice); 2563 Assert(pDevice->pDevice9If); 2603 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2604 Assert(pScreen->hWnd); 2605 Assert(pScreen->pDevice9If); 2564 2606 pDevice->ViewPort.MinZ = pData->MinZ; 2565 2607 pDevice->ViewPort.MaxZ = pData->MaxZ; 2566 HRESULT hr = p Device->pDevice9If->SetViewport(&pDevice->ViewPort);2608 HRESULT hr = pScreen->pDevice9If->SetViewport(&pDevice->ViewPort); 2567 2609 Assert(hr == S_OK); 2568 2610 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 2602 2644 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2603 2645 Assert(pDevice); 2604 Assert(pDevice->pDevice9If); 2605 HRESULT hr = pDevice->pDevice9If->SetClipPlane(pData->Index, pData->Plane); 2646 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2647 Assert(pScreen->hWnd); 2648 Assert(pScreen->pDevice9If); 2649 HRESULT hr = pScreen->pDevice9If->SetClipPlane(pData->Index, pData->Plane); 2606 2650 Assert(hr == S_OK); 2607 2651 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 2651 2695 if (VBOXDISPMODE_IS_3D(pDevice->pAdapter)) 2652 2696 { 2653 Assert(pRc != pDevice->pRenderTargetRc || pDevice->iRenderTargetFrontBuf != pData->SubResourceIndex); 2697 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2698 2699 Assert(pRc != pScreen->pRenderTargetRc || pScreen->iRenderTargetFrontBuf != pData->SubResourceIndex); 2654 2700 2655 2701 if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE) … … 3330 3376 if (pResource->Flags.ZBuffer) 3331 3377 { 3332 Assert(pDevice->pDevice9If); 3378 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3379 Assert(pScreen->hWnd); 3380 Assert(pScreen->pDevice9If); 3333 3381 for (UINT i = 0; i < pResource->SurfCount; ++i) 3334 3382 { 3335 3383 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3336 3384 IDirect3DSurface9 *pD3D9Surf; 3337 hr = p Device->pDevice9If->CreateDepthStencilSurface(pAllocation->SurfDesc.width,3385 hr = pScreen->pDevice9If->CreateDepthStencilSurface(pAllocation->SurfDesc.width, 3338 3386 pAllocation->SurfDesc.height, 3339 3387 vboxDDI2D3DFormat(pResource->Format), … … 3364 3412 else if (pResource->Flags.VertexBuffer) 3365 3413 { 3366 Assert(pDevice->pDevice9If); 3414 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3415 Assert(pScreen->hWnd); 3416 Assert(pScreen->pDevice9If); 3367 3417 for (UINT i = 0; i < pResource->SurfCount; ++i) 3368 3418 { 3369 3419 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3370 3420 IDirect3DVertexBuffer9 *pD3D9VBuf; 3371 hr = p Device->pDevice9If->CreateVertexBuffer(pAllocation->SurfDesc.width,3421 hr = pScreen->pDevice9If->CreateVertexBuffer(pAllocation->SurfDesc.width, 3372 3422 vboxDDI2D3DUsage(pResource->Flags), 3373 3423 pResource->Fvf, … … 3412 3462 else if (pResource->Flags.IndexBuffer) 3413 3463 { 3414 Assert(pDevice->pDevice9If); 3464 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3465 Assert(pScreen->hWnd); 3466 Assert(pScreen->pDevice9If); 3415 3467 for (UINT i = 0; i < pResource->SurfCount; ++i) 3416 3468 { … … 3418 3470 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 3419 3471 IDirect3DIndexBuffer9 *pD3D9IBuf; 3420 hr = p Device->pDevice9If->CreateIndexBuffer(pSurf->Width,3472 hr = pScreen->pDevice9If->CreateIndexBuffer(pSurf->Width, 3421 3473 vboxDDI2D3DUsage(pResource->Flags), 3422 3474 vboxDDI2D3DFormat(pResource->Format), … … 3462 3514 else if (pResource->Flags.Texture || pResource->Flags.Value == 0) 3463 3515 { 3464 Assert(pDevice->pDevice9If); 3516 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3517 Assert(pScreen->hWnd); 3518 Assert(pScreen->pDevice9If); 3465 3519 #ifdef DEBUG 3466 3520 { … … 3486 3540 HANDLE hSharedHandle = NULL; 3487 3541 #if 0 3488 hr = p Device->pDevice9If->CreateTexture(pSurf->Width,3542 hr = pScreen->pDevice9If->CreateTexture(pSurf->Width, 3489 3543 pSurf->Height, 3490 3544 pResource->SurfCount, … … 3496 3550 ); 3497 3551 #else 3498 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)p Device->pDevice9If,3552 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pScreen->pDevice9If, 3499 3553 pSurf->Width, 3500 3554 pSurf->Height, … … 3556 3610 bIssueCreateResource = true; 3557 3611 Assert(pResource->SurfCount); 3558 if (!pDevice->pDevice9If) 3559 { 3560 Assert(!pDevice->hWnd); 3612 IDirect3DDevice9 *pPrimaryDevice = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If; 3613 if (!pPrimaryDevice || pResource->Flags.Primary) 3614 { 3615 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pResource->VidPnSourceId]; 3616 Assert(!pScreen->pDevice9If); 3617 Assert(!pScreen->hWnd); 3561 3618 hr = VBoxDispWndCreate(pAdapter, pResource->pSurfList[0].Width, pResource->pSurfList[0].Height, &hWnd); 3562 3619 Assert(hr == S_OK); 3563 3620 if (hr == S_OK) 3564 3621 { 3622 pScreen->hWnd = hWnd; 3623 3565 3624 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 3566 3625 if (pDevice->fFlags.AllowMultithreading) … … 3574 3633 params.BackBufferFormat = vboxDDI2D3DFormat(pResource->Format); 3575 3634 Assert(pResource->SurfCount); 3576 params.BackBufferCount = pResource->SurfCount - 1;3635 params.BackBufferCount = !pPrimaryDevice ? pResource->SurfCount - 1 : 0; 3577 3636 params.MultiSampleType = vboxDDI2D3DMultiSampleType(pResource->MultisampleType); 3578 3637 if (pResource->Flags.DiscardRenderTarget) … … 3591 3650 if (hr == S_OK) 3592 3651 { 3593 p Device->pDevice9If = pDevice9If;3594 p Device->hWnd = hWnd;3595 pDevice->pRenderTargetRc = pRc;3652 pScreen->pDevice9If = pDevice9If; 3653 pScreen->pRenderTargetRc = pRc; 3654 ++pDevice->cScreens; 3596 3655 3597 3656 for (UINT i = 0; i < pResource->SurfCount; ++i) … … 3601 3660 } 3602 3661 3603 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0); 3604 Assert(hr == S_OK); 3605 if (hr == S_OK) 3662 if (pPrimaryDevice) 3606 3663 { 3607 3664 for (UINT i = 0; i < pResource->SurfCount; ++i) 3608 3665 { 3609 3666 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3610 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 3611 hr = vboxWddmSurfSynchMem(pRc, pAllocation); 3612 Assert(hr == S_OK); 3613 if (hr != S_OK) 3614 { 3615 break; 3616 } 3617 } 3618 3619 #ifndef VBOXWDDM_WITH_VISIBLE_FB 3620 if (hr == S_OK) 3621 { 3622 IDirect3DSurface9* pD3D9Surf; 3623 hr = pDevice->pDevice9If->CreateRenderTarget(pRc->aAllocations[0].SurfDesc.width, 3624 pRc->aAllocations[0].SurfDesc.height, 3667 IDirect3DSurface9 *pRt; 3668 IDirect3DSurface9 *pSecondaryOpenedRt; 3669 HANDLE hSharedHandle = NULL; 3670 hr = pPrimaryDevice->CreateRenderTarget( 3671 pResource->pSurfList[i].Width, 3672 pResource->pSurfList[i].Height, 3625 3673 vboxDDI2D3DFormat(pResource->Format), 3626 3674 vboxDDI2D3DMultiSampleType(pResource->MultisampleType), 3627 pResource->MultisampleQuality, 3628 !pResource->Flags.NotLockable /* BOOL Lockable */, 3629 &pD3D9Surf, 3630 NULL /* HANDLE* pSharedHandle */ 3631 ); 3675 0, /*DWORD MultisampleQuality*/ 3676 TRUE, /*BOOL Lockable*/ 3677 &pRt, 3678 &hSharedHandle); 3632 3679 Assert(hr == S_OK); 3633 3680 if (hr == S_OK) 3634 3681 { 3635 pDevice->pRenderTargetFbCopy = pD3D9Surf; 3682 Assert(hSharedHandle != NULL); 3683 /* open render target for primary device */ 3684 hr = pDevice9If->CreateRenderTarget( 3685 pResource->pSurfList[i].Width, 3686 pResource->pSurfList[i].Height, 3687 vboxDDI2D3DFormat(pResource->Format), 3688 vboxDDI2D3DMultiSampleType(pResource->MultisampleType), 3689 0, /*DWORD MultisampleQuality*/ 3690 TRUE, /*BOOL Lockable*/ 3691 &pSecondaryOpenedRt, 3692 &hSharedHandle); 3693 Assert(hr == S_OK); 3694 if (hr == S_OK) 3695 { 3696 pAllocation->pD3DIf = pRt; 3697 pAllocation->pSecondaryOpenedD3DIf = pSecondaryOpenedRt; 3698 pAllocation->hSharedHandle = hSharedHandle; 3699 continue; 3700 } 3701 pRt->Release(); 3636 3702 } 3703 3704 for (UINT j = 0; j < i; ++j) 3705 { 3706 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[j]; 3707 pAlloc->pD3DIf->Release(); 3708 pAlloc->pSecondaryOpenedD3DIf->Release(); 3709 } 3710 3711 break; 3637 3712 } 3638 #endif 3639 3640 if (hr != S_OK) 3713 } 3714 else 3715 { 3716 pDevice->iPrimaryScreen = pResource->VidPnSourceId; 3717 } 3718 3719 if (hr == S_OK) 3720 { 3721 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0); 3722 Assert(hr == S_OK); 3723 if (hr == S_OK) 3641 3724 { 3642 3725 for (UINT i = 0; i < pResource->SurfCount; ++i) 3643 3726 { 3644 3727 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3645 pAllocation->pD3DIf->Release(); 3728 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 3729 hr = vboxWddmSurfSynchMem(pRc, pAllocation); 3730 Assert(hr == S_OK); 3731 if (hr != S_OK) 3732 { 3733 break; 3734 } 3735 } 3736 3737 #ifndef VBOXWDDM_WITH_VISIBLE_FB 3738 if (!pPrimaryDevice) 3739 { 3740 if (hr == S_OK) 3741 { 3742 IDirect3DSurface9* pD3D9Surf; 3743 hr = pDevice9If->CreateRenderTarget(pRc->aAllocations[0].SurfDesc.width, 3744 pRc->aAllocations[0].SurfDesc.height, 3745 vboxDDI2D3DFormat(pResource->Format), 3746 vboxDDI2D3DMultiSampleType(pResource->MultisampleType), 3747 pResource->MultisampleQuality, 3748 !pResource->Flags.NotLockable /* BOOL Lockable */, 3749 &pD3D9Surf, 3750 NULL /* HANDLE* pSharedHandle */ 3751 ); 3752 Assert(hr == S_OK); 3753 if (hr == S_OK) 3754 { 3755 pDevice->pRenderTargetFbCopy = pD3D9Surf; 3756 } 3757 } 3758 } 3759 #endif 3760 3761 if (hr != S_OK) 3762 { 3763 for (UINT i = 0; i < pResource->SurfCount; ++i) 3764 { 3765 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3766 pAllocation->pD3DIf->Release(); 3767 } 3646 3768 } 3647 3769 } … … 3649 3771 3650 3772 if (hr != S_OK) 3773 { 3651 3774 pDevice9If->Release(); 3775 --pDevice->cScreens; 3776 Assert(pDevice->cScreens < UINT32_MAX/2); 3777 } 3652 3778 } 3653 3779 3654 3780 if (hr != S_OK) 3655 3781 { 3656 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, p Device->hWnd);3782 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pScreen->hWnd); 3657 3783 Assert(tmpHr == S_OK); 3658 3784 } 3659 3785 } 3786 3787 3660 3788 } 3661 3789 else 3662 3790 { 3663 Assert(pDevice->hWnd); 3664 Assert(pDevice->pDevice9If); 3791 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3792 Assert(pScreen->hWnd); 3793 Assert(pScreen->pDevice9If); 3665 3794 for (UINT i = 0; i < pResource->SurfCount; ++i) 3666 3795 { … … 3668 3797 3669 3798 IDirect3DSurface9* pD3D9Surf; 3670 hr = p Device->pDevice9If->CreateRenderTarget(pAllocation->SurfDesc.width,3799 hr = pScreen->pDevice9If->CreateRenderTarget(pAllocation->SurfDesc.width, 3671 3800 pAllocation->SurfDesc.height, 3672 3801 vboxDDI2D3DFormat(pResource->Format), … … 3702 3831 else 3703 3832 { 3704 Assert(pDevice->pDevice9If); 3833 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3834 Assert(pScreen->hWnd); 3835 Assert(pScreen->pDevice9If); 3705 3836 Assert(0); 3706 3837 } 3707 3838 } 3708 3839 else 3840 { 3709 3841 bIssueCreateResource = true; 3842 } 3710 3843 3711 3844 … … 3828 3961 if (VBOXDISPMODE_IS_3D(pAdapter)) 3829 3962 { 3830 if (pRc->RcDesc.fFlags.RenderTarget)3831 {3832 Assert(pDevice->hWnd);3833 Assert(pDevice->pDevice9If);3834 }3963 // if (pRc->RcDesc.fFlags.RenderTarget) 3964 // { 3965 // Assert(pDevice->hWnd); 3966 // Assert(pDevice->pDevice9If); 3967 // } 3835 3968 3836 3969 for (UINT i = 0; i < pRc->cAllocations; ++i) … … 3839 3972 if (pAlloc->pD3DIf) 3840 3973 pAlloc->pD3DIf->Release(); 3974 if (pAlloc->pSecondaryOpenedD3DIf) 3975 pAlloc->pSecondaryOpenedD3DIf->Release(); 3841 3976 } 3842 3977 } … … 3883 4018 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex]; 3884 4019 Assert(pRc->RcDesc.fFlags.RenderTarget); 4020 Assert(pRc->RcDesc.fFlags.Primary); 3885 4021 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 3886 4022 Assert(pAlloc->hAllocation); 4023 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pRc->RcDesc.VidPnSourceId]; 4024 Assert(pScreen->hWnd); 4025 Assert(pScreen->pDevice9If); 3887 4026 D3DDDICB_SETDISPLAYMODE DdiDm = {0}; 3888 4027 DdiDm.hPrimaryAllocation = pAlloc->hAllocation; 3889 4028 // DdiDm.PrivateDriverFormatAttribute = 0; 3890 Assert(p Device->pRenderTargetRc == pRc);3891 Assert(p Device->iRenderTargetFrontBuf == pData->SubResourceIndex);4029 Assert(pScreen->pRenderTargetRc == pRc); 4030 Assert(pScreen->iRenderTargetFrontBuf == pData->SubResourceIndex); 3892 4031 3893 4032 #if 0 3894 IDirect3DSurface9 *p D3DIfSurf = (IDirect3DSurface9*)pAlloc->pD3DIf;3895 hr = p Device->pDevice9If->SetRenderTarget(0, pD3DIfSurf);4033 IDirect3DSurface9 *pSoD3DIfSurf = (IDirect3DSurface9*)pAlloc->pSecondaryOpenedD3DIf; 4034 hr = pScreen->pDevice9If->SetRenderTarget(0, pSoD3DIfSurf); 3896 4035 Assert(hr == S_OK); 3897 4036 if (hr == S_OK) … … 3913 4052 if (VBOXDISPMODE_IS_3D(pDevice->pAdapter)) 3914 4053 { 3915 Assert(pDevice->pDevice9If); 4054 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 4055 Assert(pRc); 4056 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pRc->RcDesc.VidPnSourceId]; 4057 Assert(pScreen->hWnd); 4058 Assert(pScreen->pDevice9If); 4059 Assert(pRc == pScreen->pRenderTargetRc); 3916 4060 #if 1 3917 4061 VBOXVDBG_RTGT_STATECHECK(pDevice); 3918 4062 3919 hr = pDevice->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */ 4063 if (pRc->RcDesc.VidPnSourceId != pDevice->iPrimaryScreen) 4064 { 4065 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SrcSubResourceIndex]; 4066 IDirect3DSurface9 *pSecondaryRt; 4067 IDirect3DSurface9 *pDataRt = (IDirect3DSurface9*)pAlloc->pSecondaryOpenedD3DIf; 4068 Assert(pDataRt); 4069 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 4070 hr = pScreen->pDevice9If->GetRenderTarget(0, &pSecondaryRt); 4071 Assert(hr == S_OK); 4072 if (hr == S_OK) 4073 { 4074 hr = pScreen->pDevice9If->StretchRect(pDataRt, 4075 NULL, 4076 pSecondaryRt, 4077 NULL, 4078 D3DTEXF_NONE); 4079 pSecondaryRt->Release(); 4080 } 4081 } 4082 4083 hr = pScreen->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */ 3920 4084 NULL, /* CONST RECT * pDestRect */ 3921 4085 NULL, /* HWND hDestWindowOverride */ … … 3933 4097 Assert(pData->hSrcResource); 3934 4098 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 3935 Assert(pDevice->pRenderTargetRc == pRc); 4099 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pRc->RcDesc.VidPnSourceId]; 4100 Assert(pScreen->hWnd); 4101 Assert(pScreen->pDevice9If); 4102 Assert(pScreen->pRenderTargetRc == pRc); 3936 4103 Assert(pRc->cAllocations >= 2); 3937 4104 Assert(pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 3938 4105 Assert(pRc->RcDesc.fFlags.RenderTarget); 3939 uint32_t iNewRTFB = (p Device->iRenderTargetFrontBuf + 1) % pRc->cAllocations;3940 3941 Assert(p Device->iRenderTargetFrontBuf != iNewRTFB);4106 uint32_t iNewRTFB = (pScreen->iRenderTargetFrontBuf + 1) % pRc->cAllocations; 4107 4108 Assert(pScreen->iRenderTargetFrontBuf != iNewRTFB); 3942 4109 Assert(pData->SrcSubResourceIndex == iNewRTFB); 3943 4110 … … 3945 4112 3946 4113 /* assign a new frontbuffer index */ 3947 p Device->iRenderTargetFrontBuf = iNewRTFB;4114 pScreen->iRenderTargetFrontBuf = iNewRTFB; 3948 4115 3949 4116 VBOXVDBG_RTGT_STATECHECK(pDevice); … … 3986 4153 if (VBOXDISPMODE_IS_3D(pDevice->pAdapter)) 3987 4154 { 3988 Assert(pDevice-> pDevice9If);3989 #if 0 3990 hr = pDevice->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */3991 NULL, /* CONST RECT * pDestRect */3992 NULL, /* HWND hDestWindowOverride */3993 NULL /*CONST RGNDATA * pDirtyRegion */3994 );3995 Assert(hr == S_OK);3996 #endif 4155 Assert(pDevice->cScreens); 4156 for (UINT i = 0; i < RT_ELEMENTS(pDevice->aScreens); ++i) 4157 { 4158 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[i]; 4159 if (pScreen->pDevice9If) 4160 { 4161 /* @todo: make a flush */ 4162 } 4163 } 3997 4164 } 3998 4165 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4020 4187 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4021 4188 Assert(pDevice); 4022 Assert(pDevice->pDevice9If); 4189 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4190 Assert(pScreen->hWnd); 4191 Assert(pScreen->pDevice9If); 4023 4192 IDirect3DVertexDeclaration9 *pDecl; 4024 4193 static D3DVERTEXELEMENT9 DeclEnd = D3DDECL_END(); … … 4043 4212 if (hr == S_OK) 4044 4213 { 4045 hr = p Device->pDevice9If->CreateVertexDeclaration(4214 hr = pScreen->pDevice9If->CreateVertexDeclaration( 4046 4215 pVe, 4047 4216 &pDecl … … 4066 4235 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4067 4236 Assert(pDevice); 4068 Assert(pDevice->pDevice9If); 4237 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4238 Assert(pScreen->hWnd); 4239 Assert(pScreen->pDevice9If); 4069 4240 IDirect3DVertexDeclaration9 *pDecl = (IDirect3DVertexDeclaration9*)hShaderHandle; 4070 4241 Assert(pDecl); 4071 HRESULT hr = p Device->pDevice9If->SetVertexDeclaration(pDecl);4242 HRESULT hr = pScreen->pDevice9If->SetVertexDeclaration(pDecl); 4072 4243 Assert(hr == S_OK); 4073 4244 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4079 4250 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4080 4251 Assert(pDevice); 4081 Assert(pDevice->pDevice9If); 4252 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4253 Assert(pScreen->hWnd); 4254 Assert(pScreen->pDevice9If); 4082 4255 IDirect3DVertexDeclaration9 *pDecl = (IDirect3DVertexDeclaration9*)hShaderHandle; 4083 4256 HRESULT hr = S_OK; … … 4091 4264 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4092 4265 Assert(pDevice); 4093 Assert(pDevice->pDevice9If); 4266 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4267 Assert(pScreen->hWnd); 4268 Assert(pScreen->pDevice9If); 4094 4269 IDirect3DVertexShader9 *pShader; 4095 4270 Assert(*((UINT*)((uint8_t*)pCode + pData->Size-4)) == 0x0000FFFF /* end token */); 4096 HRESULT hr = p Device->pDevice9If->CreateVertexShader((const DWORD *)pCode, &pShader);4271 HRESULT hr = pScreen->pDevice9If->CreateVertexShader((const DWORD *)pCode, &pShader); 4097 4272 Assert(hr == S_OK); 4098 4273 if (hr == S_OK) … … 4109 4284 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4110 4285 Assert(pDevice); 4111 Assert(pDevice->pDevice9If); 4286 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4287 Assert(pScreen->hWnd); 4288 Assert(pScreen->pDevice9If); 4112 4289 IDirect3DVertexShader9 *pShader = (IDirect3DVertexShader9*)hShaderHandle; 4113 4290 Assert(pShader); 4114 HRESULT hr = p Device->pDevice9If->SetVertexShader(pShader);4291 HRESULT hr = pScreen->pDevice9If->SetVertexShader(pShader); 4115 4292 Assert(hr == S_OK); 4116 4293 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4122 4299 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4123 4300 Assert(pDevice); 4124 Assert(pDevice->pDevice9If); 4301 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4302 Assert(pScreen->hWnd); 4303 Assert(pScreen->pDevice9If); 4125 4304 IDirect3DVertexShader9 *pShader = (IDirect3DVertexShader9*)hShaderHandle; 4126 4305 HRESULT hr = S_OK; … … 4134 4313 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4135 4314 Assert(pDevice); 4136 Assert(pDevice->pDevice9If); 4137 HRESULT hr = pDevice->pDevice9If->SetVertexShaderConstantI(pData->Register, pRegisters, pData->Count); 4315 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4316 Assert(pScreen->hWnd); 4317 Assert(pScreen->pDevice9If); 4318 HRESULT hr = pScreen->pDevice9If->SetVertexShaderConstantI(pData->Register, pRegisters, pData->Count); 4138 4319 Assert(hr == S_OK); 4139 4320 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4145 4326 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4146 4327 Assert(pDevice); 4147 Assert(pDevice->pDevice9If); 4148 HRESULT hr = pDevice->pDevice9If->SetVertexShaderConstantB(pData->Register, pRegisters, pData->Count); 4328 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4329 Assert(pScreen->hWnd); 4330 Assert(pScreen->pDevice9If); 4331 HRESULT hr = pScreen->pDevice9If->SetVertexShaderConstantB(pData->Register, pRegisters, pData->Count); 4149 4332 Assert(hr == S_OK); 4150 4333 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4156 4339 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4157 4340 Assert(pDevice); 4158 Assert(pDevice->pDevice9If); 4159 HRESULT hr = pDevice->pDevice9If->SetScissorRect(pRect); 4341 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4342 Assert(pScreen->hWnd); 4343 Assert(pScreen->pDevice9If); 4344 HRESULT hr = pScreen->pDevice9If->SetScissorRect(pRect); 4160 4345 Assert(hr == S_OK); 4161 4346 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4167 4352 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4168 4353 Assert(pDevice); 4169 Assert(pDevice->pDevice9If); 4354 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4355 Assert(pScreen->hWnd); 4356 Assert(pScreen->pDevice9If); 4170 4357 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hVertexBuffer; 4171 4358 PVBOXWDDMDISP_ALLOCATION pAlloc = NULL; … … 4178 4365 pStreamData = (IDirect3DVertexBuffer9*)pAlloc->pD3DIf; 4179 4366 } 4180 HRESULT hr = p Device->pDevice9If->SetStreamSource(pData->Stream, pStreamData, pData->Offset, pData->Stride);4367 HRESULT hr = pScreen->pDevice9If->SetStreamSource(pData->Stream, pStreamData, pData->Offset, pData->Stride); 4181 4368 Assert(hr == S_OK); 4182 4369 Assert(pData->Stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS); … … 4329 4516 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4330 4517 Assert(pDevice); 4331 Assert(pDevice->pDevice9If); 4518 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4519 Assert(pScreen->hWnd); 4520 Assert(pScreen->pDevice9If); 4332 4521 PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource; 4333 4522 PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 4334 4523 Assert(pDstRc->cAllocations > pData->DstSubResourceIndex); 4335 4524 Assert(pSrcRc->cAllocations > pData->SrcSubResourceIndex); 4336 Assert(pDstRc != p Device->pRenderTargetRc || pDevice->iRenderTargetFrontBuf != pData->DstSubResourceIndex);4525 Assert(pDstRc != pScreen->pRenderTargetRc || pScreen->iRenderTargetFrontBuf != pData->DstSubResourceIndex); 4337 4526 HRESULT hr = S_OK; 4338 4527 /* try StretchRect */ … … 4347 4536 { 4348 4537 #ifndef VBOXWDDM_WITH_VISIBLE_FB 4349 if (pSrcRc == p Device->pRenderTargetRc && pDevice->iRenderTargetFrontBuf == pData->SrcSubResourceIndex)4538 if (pSrcRc == pScreen->pRenderTargetRc && pScreen->iRenderTargetFrontBuf == pData->SrcSubResourceIndex) 4350 4539 { 4351 4540 PVBOXWDDMDISP_ALLOCATION pSrcAlloc = &pSrcRc->aAllocations[pData->SrcSubResourceIndex]; … … 4378 4567 && pSrcAlloc->SurfDesc.format == pDstAlloc->SurfDesc.format) 4379 4568 { 4380 hr = p Device->pDevice9If->GetFrontBufferData(0, pDstSurfIf);4569 hr = pScreen->pDevice9If->GetFrontBufferData(0, pDstSurfIf); 4381 4570 Assert(hr == S_OK); 4382 4571 break; … … 4387 4576 pSrcSurfIf = pDevice->pRenderTargetFbCopy; 4388 4577 Assert(pSrcSurfIf); 4389 hr = p Device->pDevice9If->GetFrontBufferData(0, pDevice->pRenderTargetFbCopy);4578 hr = pScreen->pDevice9If->GetFrontBufferData(0, pDevice->pRenderTargetFbCopy); 4390 4579 Assert(hr == S_OK); 4391 4580 if (hr == S_OK) … … 4445 4634 /* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */ 4446 4635 Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001 | 0x00000002))) == 0); 4447 hr = p Device->pDevice9If->StretchRect(pSrcSurfIf,4636 hr = pScreen->pDevice9If->StretchRect(pSrcSurfIf, 4448 4637 &pData->SrcRect, 4449 4638 pDstSurfIf, … … 4494 4683 ) 4495 4684 { 4496 hr = p Device->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);4685 hr = pScreen->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex); 4497 4686 Assert(hr == S_OK); 4498 4687 } … … 4585 4774 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4586 4775 Assert(pDevice); 4587 Assert(pDevice->pDevice9If); 4776 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4777 Assert(pScreen->hWnd); 4778 Assert(pScreen->pDevice9If); 4588 4779 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hResource; 4589 4780 Assert(pRc); … … 4594 4785 { 4595 4786 Assert(pSurfIf); 4596 hr = p Device->pDevice9If->ColorFill(pSurfIf, &pData->DstRect, pData->Color);4787 hr = pScreen->pDevice9If->ColorFill(pSurfIf, &pData->DstRect, pData->Color); 4597 4788 Assert(hr == S_OK); 4598 4789 /* @todo: check what need to do when PresentToDwm flag is set */ … … 4644 4835 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4645 4836 Assert(pDevice); 4646 Assert(pDevice->pDevice9If); 4837 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4838 Assert(pScreen->hWnd); 4839 Assert(pScreen->pDevice9If); 4647 4840 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hRenderTarget; 4648 4841 Assert(pRc); 4649 4842 Assert(pData->SubResourceIndex < pRc->cAllocations); 4650 if (pRc == pDevice->pRenderTargetRc) 4843 PVBOXWDDMDISP_SCREEN pVisibleScreen = pRc->RcDesc.fFlags.Primary ? &pDevice->aScreens[pRc->RcDesc.VidPnSourceId] : pScreen; 4844 if (pRc == pVisibleScreen->pRenderTargetRc) 4651 4845 { 4652 4846 /* backbuffer */ 4653 Assert(pData->SubResourceIndex == ((p Device->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations));4847 Assert(pData->SubResourceIndex == ((pVisibleScreen->iRenderTargetFrontBuf + 1) % pVisibleScreen->pRenderTargetRc->cAllocations)); 4654 4848 } 4655 4849 4656 4850 HRESULT hr = S_OK; 4657 4851 IDirect3DSurface9 *pD3D9Surf; 4658 if (pRc == p Device->pRenderTargetRc && pRc->cAllocations == 1 && pData->RenderTargetIndex == 0)4852 if (pRc == pScreen->pRenderTargetRc && pRc->cAllocations == 1 && pData->RenderTargetIndex == 0) 4659 4853 { 4660 4854 /* work-around wine double-buffering for the case we have no backbuffers */ 4661 hr = p Device->pDevice9If->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);4855 hr = pScreen->pDevice9If->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 4662 4856 Assert(hr == S_OK); 4663 4857 Assert(pD3D9Surf); … … 4672 4866 { 4673 4867 Assert(pD3D9Surf); 4674 hr = p Device->pDevice9If->SetRenderTarget(pData->RenderTargetIndex, pD3D9Surf);4868 hr = pScreen->pDevice9If->SetRenderTarget(pData->RenderTargetIndex, pD3D9Surf); 4675 4869 Assert(hr == S_OK); 4676 4870 pD3D9Surf->Release(); … … 4684 4878 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4685 4879 Assert(pDevice); 4686 Assert(pDevice->pDevice9If); 4880 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4881 Assert(pScreen->hWnd); 4882 Assert(pScreen->pDevice9If); 4687 4883 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hZBuffer; 4688 4884 IDirect3DSurface9 *pD3D9Surf = NULL; … … 4693 4889 Assert(pD3D9Surf); 4694 4890 } 4695 HRESULT hr = p Device->pDevice9If->SetDepthStencilSurface(pD3D9Surf);4891 HRESULT hr = pScreen->pDevice9If->SetDepthStencilSurface(pD3D9Surf); 4696 4892 Assert(hr == S_OK); 4697 4893 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4710 4906 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4711 4907 Assert(pDevice); 4712 Assert(pDevice->pDevice9If); 4713 HRESULT hr = pDevice->pDevice9If->SetPixelShaderConstantI(pData->Register, pRegisters, pData->Count); 4908 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4909 Assert(pScreen->hWnd); 4910 Assert(pScreen->pDevice9If); 4911 HRESULT hr = pScreen->pDevice9If->SetPixelShaderConstantI(pData->Register, pRegisters, pData->Count); 4714 4912 Assert(hr == S_OK); 4715 4913 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4721 4919 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4722 4920 Assert(pDevice); 4723 Assert(pDevice->pDevice9If); 4724 HRESULT hr = pDevice->pDevice9If->SetPixelShaderConstantB(pData->Register, pRegisters, pData->Count); 4921 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4922 Assert(pScreen->hWnd); 4923 Assert(pScreen->pDevice9If); 4924 HRESULT hr = pScreen->pDevice9If->SetPixelShaderConstantB(pData->Register, pRegisters, pData->Count); 4725 4925 Assert(hr == S_OK); 4726 4926 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4732 4932 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4733 4933 Assert(pDevice); 4734 Assert(pDevice->pDevice9If); 4934 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4935 Assert(pScreen->hWnd); 4936 Assert(pScreen->pDevice9If); 4735 4937 IDirect3DPixelShader9 *pShader; 4736 4938 Assert(*((UINT*)((uint8_t*)pCode + pData->CodeSize-4)) == 0x0000FFFF /* end token */); 4737 HRESULT hr = p Device->pDevice9If->CreatePixelShader((const DWORD *)pCode, &pShader);4939 HRESULT hr = pScreen->pDevice9If->CreatePixelShader((const DWORD *)pCode, &pShader); 4738 4940 Assert(hr == S_OK); 4739 4941 if (hr == S_OK) … … 4750 4952 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4751 4953 Assert(pDevice); 4752 Assert(pDevice->pDevice9If); 4954 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4955 Assert(pScreen->hWnd); 4956 Assert(pScreen->pDevice9If); 4753 4957 IDirect3DPixelShader9 *pShader = (IDirect3DPixelShader9*)hShaderHandle; 4754 4958 HRESULT hr = S_OK; … … 4875 5079 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4876 5080 PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter; 4877 if (pDevice->pDevice9If) 4878 { 5081 // Assert(!pDevice->cScreens); 4879 5082 #ifndef VBOXWDDM_WITH_VISIBLE_FB 5083 if(pDevice->pRenderTargetFbCopy) 4880 5084 pDevice->pRenderTargetFbCopy->Release(); 4881 5085 #endif 4882 pDevice->pDevice9If->Release(); 4883 Assert(pDevice->hWnd); 4884 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pDevice->hWnd); 4885 Assert(tmpHr == S_OK); 4886 } 5086 for (UINT i = 0; i < RT_ELEMENTS(pDevice->aScreens); ++i) 5087 { 5088 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[i]; 5089 if (pScreen->pDevice9If) 5090 { 5091 pScreen->pDevice9If->Release(); 5092 Assert(pScreen->hWnd); 5093 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pScreen->hWnd); 5094 Assert(tmpHr == S_OK); 5095 } 5096 } 5097 4887 5098 HRESULT hr = vboxDispCmCtxDestroy(pDevice, &pDevice->DefaultContext); 4888 5099 Assert(hr == S_OK); … … 5215 5426 if (pRc->RcDesc.fFlags.Texture) 5216 5427 { 5217 Assert(pDevice->pDevice9If); 5218 5428 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5429 Assert(pScreen->hWnd); 5430 Assert(pScreen->pDevice9If); 5219 5431 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 5220 5432 IDirect3DTexture9 *pD3DIfTex; … … 5222 5434 Assert(pAllocation->hSharedHandle); 5223 5435 5224 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)p Device->pDevice9If,5436 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pScreen->pDevice9If, 5225 5437 pAllocation->SurfDesc.width, 5226 5438 pAllocation->SurfDesc.height, … … 5673 5885 Assert(pRc->cAllocations > iAlloc); 5674 5886 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[iAlloc]; 5887 BOOL bPrimary = pRc->RcDesc.fFlags.Primary; 5888 BOOL bFrontBuf = FALSE; 5889 if (bPrimary) 5890 { 5891 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pRc->RcDesc.VidPnSourceId]; 5892 Assert(pRc == pScreen->pRenderTargetRc); 5893 bFrontBuf = (iAlloc == pScreen->iRenderTargetFrontBuf); 5894 } 5675 5895 vboxVDbgDoMpPrintF(pDevice, "%s width(%d), height(%d), format(%d), usage(%s), %s", pPrefix, 5676 5896 pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, pAlloc->SurfDesc.format, 5677 pRc == pDevice->pRenderTargetRc?5678 ( iAlloc == pDevice->iRenderTargetFrontBuf ? "Front Buffer" : "Back Buffer")5897 bPrimary ? 5898 (bFrontBuf ? "Front Buffer" : "Back Buffer") 5679 5899 : "?Everage? Alloc", 5680 5900 pSuffix); -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h
r31713 r31797 91 91 } VBOXWDDMDISP_INDICES_INFO; 92 92 93 typedef struct VBOXWDDMDISP_SCREEN 94 { 95 IDirect3DDevice9 *pDevice9If; 96 struct VBOXWDDMDISP_RESOURCE *pRenderTargetRc; 97 uint32_t iRenderTargetFrontBuf; 98 HWND hWnd; 99 } VBOXWDDMDISP_SCREEN, *PVBOXWDDMDISP_SCREEN; 100 93 101 typedef struct VBOXWDDMDISP_DEVICE 94 102 { … … 101 109 UINT cbCmdBuffer; 102 110 D3DDDI_CREATEDEVICEFLAGS fFlags; 103 HWND hWnd;104 111 #ifndef VBOXWDDM_WITH_VISIBLE_FB 105 112 IDirect3DSurface9 *pRenderTargetFbCopy; 106 113 #endif 107 struct VBOXWDDMDISP_RESOURCE *pRenderTargetRc;108 uint32_t iRenderTargetFrontBuf;109 114 /* number of StreamSources set */ 110 115 UINT cStreamSources; … … 115 120 VBOXWDDMDISP_ALLOCATION *pIndicesAlloc; 116 121 VBOXWDDMDISP_INDICES_INFO IndiciesInfo; 117 IDirect3DDevice9 *pDevice9If;118 122 /* need to cache the ViewPort data because IDirect3DDevice9::SetViewport 119 123 * is split into two calls : SetViewport & SetZRange */ 120 124 D3DVIEWPORT9 ViewPort; 121 125 VBOXWDDMDISP_CONTEXT DefaultContext; 126 127 UINT iPrimaryScreen; 128 UINT cScreens; 129 VBOXWDDMDISP_SCREEN aScreens[VBOX_VIDEO_MAX_SCREENS]; 122 130 } VBOXWDDMDISP_DEVICE, *PVBOXWDDMDISP_DEVICE; 123 131 … … 150 158 /* object type is defined by enmD3DIfType enum */ 151 159 IUnknown *pD3DIf; 160 IUnknown *pSecondaryOpenedD3DIf; 152 161 VBOXDISP_D3DIFTYPE enmD3DIfType; 153 162 HANDLE hSharedHandle; -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispMp.cpp
r30532 r31797 138 138 Assert(pHdr); 139 139 VBOXWDDMDISP_CONTEXT *pContext = (VBOXWDDMDISP_CONTEXT*)pHdr->u64UmData; 140 Assert(pContext->pDevice->hWnd); 141 pRegions->hWnd = pContext->pDevice->hWnd; 142 pRegions->pRegions = (PVBOXVIDEOCM_CMD_RECTS)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR)); 140 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR)); 141 UINT iScreen = pContext->pDevice->cScreens == 1 ? pContext->pDevice->iPrimaryScreen : pCmdInternal->VidPnSourceId; 142 PVBOXWDDMDISP_SCREEN pScreen = &pContext->pDevice->aScreens[iScreen]; 143 Assert(pScreen->hWnd); 144 Assert(pScreen->pDevice9If); 145 pRegions->hWnd = pScreen->hWnd; 146 pRegions->pRegions = &pCmdInternal->Cmd; 143 147 } 144 148 return hr; -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h
r31713 r31797 28 28 29 29 30 /* @todo: implement a check to ensure display & miniport versions match. 31 * One would increase this whenever definitions in this file are changed */ 32 #define VBOXVIDEOIF_VERSION 4 30 /* One would increase this whenever definitions in this file are changed */ 31 #define VBOXVIDEOIF_VERSION 5 33 32 34 33 /* create allocation func */ … … 213 212 } VBOXVIDEOCM_CMD_RECTS, *PVBOXVIDEOCM_CMD_RECTS; 214 213 215 #define VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS, RectsInfo.aRects[(_cRects)])) 216 #define VBOXVIDEOCM_CMD_RECTS_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS((_pCmd)->cRects)) 214 typedef struct VBOXVIDEOCM_CMD_RECTS_INTERNAL 215 { 216 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; 217 UINT u32Reserved; 218 VBOXVIDEOCM_CMD_RECTS Cmd; 219 } VBOXVIDEOCM_CMD_RECTS_INTERNAL, *PVBOXVIDEOCM_CMD_RECTS_INTERNAL; 220 221 #define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS_INTERNAL, Cmd.RectsInfo.aRects[(_cRects)])) 222 #define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS((_pCmd)->cRects)) 217 223 218 224 typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.cpp
r31763 r31797 310 310 PVBOXWDDM_RECTS_INFO pRects = &pRectsInfo->ContextsRects.UpdateRects; 311 311 NTSTATUS Status = STATUS_SUCCESS; 312 PVBOXVIDEOCM_CMD_RECTS pCmd= NULL;313 uint32_t cbCmd = VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(pRects->cRects);312 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = NULL; 313 uint32_t cbCmdInternal = VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(pRects->cRects); 314 314 Assert(KeGetCurrentIrql() < DISPATCH_LEVEL); 315 315 ExAcquireFastMutex(&pDevExt->ContextMutex); … … 319 319 { 320 320 PVBOXWDDM_CONTEXT pCurContext = VBOXWDDMENTRY_2_CONTEXT(pCur); 321 if (!pCmd )322 { 323 pCmd = (PVBOXVIDEOCM_CMD_RECTS)vboxVideoCmCmdCreate(&pCurContext->CmContext, cbCmd);324 Assert(pCmd );325 if (!pCmd )321 if (!pCmdInternal) 322 { 323 pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)vboxVideoCmCmdCreate(&pCurContext->CmContext, cbCmdInternal); 324 Assert(pCmdInternal); 325 if (!pCmdInternal) 326 326 { 327 327 Status = STATUS_NO_MEMORY; … … 331 331 else 332 332 { 333 pCmd = (PVBOXVIDEOCM_CMD_RECTS)vboxVideoCmCmdReinitForContext(pCmd, &pCurContext->CmContext);333 pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)vboxVideoCmCmdReinitForContext(pCmdInternal, &pCurContext->CmContext); 334 334 } 335 335 336 vboxVdmaDirtyRectsCalcIntersection(&pCurContext->ViewRect, pRects, &pCmd ->RectsInfo);337 if (pCmd ->RectsInfo.cRects)336 vboxVdmaDirtyRectsCalcIntersection(&pCurContext->ViewRect, pRects, &pCmdInternal->Cmd.RectsInfo); 337 if (pCmdInternal->Cmd.RectsInfo.cRects) 338 338 { 339 339 bool bSend = false; 340 pCmd ->fFlags.Value = 0;341 pCmd ->fFlags.bAddHiddenRects = 1;340 pCmdInternal->Cmd.fFlags.Value = 0; 341 pCmdInternal->Cmd.fFlags.bAddHiddenRects = 1; 342 342 if (pCurContext->pLastReportedRects) 343 343 { 344 if (pCurContext->pLastReportedRects-> fFlags.bSetVisibleRects)344 if (pCurContext->pLastReportedRects->Cmd.fFlags.bSetVisibleRects) 345 345 { 346 346 RECT *paPrevRects; 347 347 uint32_t cPrevRects; 348 if (pCurContext->pLastReportedRects-> fFlags.bSetViewRect)348 if (pCurContext->pLastReportedRects->Cmd.fFlags.bSetViewRect) 349 349 { 350 paPrevRects = &pCurContext->pLastReportedRects-> RectsInfo.aRects[1];351 cPrevRects = pCurContext->pLastReportedRects-> RectsInfo.cRects - 1;350 paPrevRects = &pCurContext->pLastReportedRects->Cmd.RectsInfo.aRects[1]; 351 cPrevRects = pCurContext->pLastReportedRects->Cmd.RectsInfo.cRects - 1; 352 352 } 353 353 else 354 354 { 355 paPrevRects = &pCurContext->pLastReportedRects-> RectsInfo.aRects[0];356 cPrevRects = pCurContext->pLastReportedRects-> RectsInfo.cRects;355 paPrevRects = &pCurContext->pLastReportedRects->Cmd.RectsInfo.aRects[0]; 356 cPrevRects = pCurContext->pLastReportedRects->Cmd.RectsInfo.cRects; 357 357 } 358 358 359 if (vboxVdmaDirtyRectsHasIntersections(paPrevRects, cPrevRects, pCmd->RectsInfo.aRects, pCmd->RectsInfo.cRects)) 359 if (vboxVdmaDirtyRectsHasIntersections(paPrevRects, cPrevRects, 360 pCmdInternal->Cmd.RectsInfo.aRects, pCmdInternal->Cmd.RectsInfo.cRects)) 360 361 { 361 362 bSend = true; … … 364 365 else 365 366 { 366 Assert(pCurContext->pLastReportedRects-> fFlags.bAddHiddenRects);367 if (!vboxVdmaDirtyRectsIsCover(pCurContext->pLastReportedRects-> RectsInfo.aRects,368 pCurContext->pLastReportedRects-> RectsInfo.cRects,369 pCmd ->RectsInfo.aRects, pCmd->RectsInfo.cRects))367 Assert(pCurContext->pLastReportedRects->Cmd.fFlags.bAddHiddenRects); 368 if (!vboxVdmaDirtyRectsIsCover(pCurContext->pLastReportedRects->Cmd.RectsInfo.aRects, 369 pCurContext->pLastReportedRects->Cmd.RectsInfo.cRects, 370 pCmdInternal->Cmd.RectsInfo.aRects, pCmdInternal->Cmd.RectsInfo.cRects)) 370 371 { 371 372 bSend = true; … … 380 381 if (pCurContext->pLastReportedRects) 381 382 vboxVideoCmCmdRelease(pCurContext->pLastReportedRects); 382 vboxVideoCmCmdRetain(pCmd); 383 pCurContext->pLastReportedRects = pCmd; 384 vboxVideoCmCmdSubmit(pCmd, VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(pCmd->RectsInfo.cRects)); 385 pCmd = NULL; 383 384 pCmdInternal->VidPnSourceId = pRectsInfo->VidPnSourceId; 385 386 vboxVideoCmCmdRetain(pCmdInternal); 387 pCurContext->pLastReportedRects = pCmdInternal; 388 vboxVideoCmCmdSubmit(pCmdInternal, VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(pCmdInternal->Cmd.RectsInfo.cRects)); 389 pCmdInternal = NULL; 386 390 } 387 391 } … … 394 398 || pContext->ViewRect.right != pContextRect->right 395 399 || pContext->ViewRect.bottom != pContextRect->bottom); 396 PVBOXVIDEOCM_CMD_RECTS pDrCmd;400 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pDrCmdInternal; 397 401 398 402 bool bSend = false; … … 400 404 if (bRectShanged) 401 405 { 402 uint32_t cbDrCmd = VBOXVIDEOCM_CMD_RECTS_SIZE4CRECTS(pRects->cRects + 1);403 pDrCmd = (PVBOXVIDEOCM_CMD_RECTS)vboxVideoCmCmdCreate(&pContext->CmContext, cbDrCmd);404 Assert(pDrCmd );405 if (!pDrCmd )406 uint32_t cbDrCmdInternal = VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(pRects->cRects + 1); 407 pDrCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)vboxVideoCmCmdCreate(&pContext->CmContext, cbDrCmdInternal); 408 Assert(pDrCmdInternal); 409 if (!pDrCmdInternal) 406 410 { 407 411 Status = STATUS_NO_MEMORY; 408 412 break; 409 413 } 410 pDrCmd ->fFlags.Value = 0;411 pDrCmd ->RectsInfo.cRects = pRects->cRects + 1;412 pDrCmd ->fFlags.bSetViewRect = 1;413 pDrCmd ->RectsInfo.aRects[0] = *pContextRect;414 pDrCmdInternal->Cmd.fFlags.Value = 0; 415 pDrCmdInternal->Cmd.RectsInfo.cRects = pRects->cRects + 1; 416 pDrCmdInternal->Cmd.fFlags.bSetViewRect = 1; 417 pDrCmdInternal->Cmd.RectsInfo.aRects[0] = *pContextRect; 414 418 pContext->ViewRect = *pContextRect; 415 memcpy(&pDrCmd ->RectsInfo.aRects[1], pRects->aRects, sizeof (RECT) * pRects->cRects);419 memcpy(&pDrCmdInternal->Cmd.RectsInfo.aRects[1], pRects->aRects, sizeof (RECT) * pRects->cRects); 416 420 bSend = true; 417 421 } 418 422 else 419 423 { 420 if (pCmd )421 { 422 pDrCmd = (PVBOXVIDEOCM_CMD_RECTS)vboxVideoCmCmdReinitForContext(pCmd, &pContext->CmContext);423 pCmd = NULL;424 if (pCmdInternal) 425 { 426 pDrCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)vboxVideoCmCmdReinitForContext(pCmdInternal, &pContext->CmContext); 427 pCmdInternal = NULL; 424 428 } 425 429 else 426 430 { 427 pDrCmd = (PVBOXVIDEOCM_CMD_RECTS)vboxVideoCmCmdCreate(&pContext->CmContext, cbCmd);428 Assert(pDrCmd );429 if (!pDrCmd )431 pDrCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)vboxVideoCmCmdCreate(&pContext->CmContext, cbCmdInternal); 432 Assert(pDrCmdInternal); 433 if (!pDrCmdInternal) 430 434 { 431 435 Status = STATUS_NO_MEMORY; … … 433 437 } 434 438 } 435 pDrCmd ->fFlags.Value = 0;436 pDrCmd ->RectsInfo.cRects = pRects->cRects;437 memcpy(&pDrCmd ->RectsInfo.aRects[0], pRects->aRects, sizeof (RECT) * pRects->cRects);439 pDrCmdInternal->Cmd.fFlags.Value = 0; 440 pDrCmdInternal->Cmd.RectsInfo.cRects = pRects->cRects; 441 memcpy(&pDrCmdInternal->Cmd.RectsInfo.aRects[0], pRects->aRects, sizeof (RECT) * pRects->cRects); 438 442 439 443 if (pContext->pLastReportedRects) 440 444 { 441 if (pContext->pLastReportedRects-> fFlags.bSetVisibleRects)445 if (pContext->pLastReportedRects->Cmd.fFlags.bSetVisibleRects) 442 446 { 443 447 RECT *paRects; 444 448 uint32_t cRects; 445 if (pContext->pLastReportedRects-> fFlags.bSetViewRect)449 if (pContext->pLastReportedRects->Cmd.fFlags.bSetViewRect) 446 450 { 447 paRects = &pContext->pLastReportedRects-> RectsInfo.aRects[1];448 cRects = pContext->pLastReportedRects-> RectsInfo.cRects - 1;451 paRects = &pContext->pLastReportedRects->Cmd.RectsInfo.aRects[1]; 452 cRects = pContext->pLastReportedRects->Cmd.RectsInfo.cRects - 1; 449 453 } 450 454 else 451 455 { 452 paRects = &pContext->pLastReportedRects-> RectsInfo.aRects[0];453 cRects = pContext->pLastReportedRects-> RectsInfo.cRects;456 paRects = &pContext->pLastReportedRects->Cmd.RectsInfo.aRects[0]; 457 cRects = pContext->pLastReportedRects->Cmd.RectsInfo.cRects; 454 458 } 455 bSend = (pDrCmd ->RectsInfo.cRects != cRects)456 || memcmp(paRects, pDrCmd ->RectsInfo.aRects, cRects * sizeof (RECT));459 bSend = (pDrCmdInternal->Cmd.RectsInfo.cRects != cRects) 460 || memcmp(paRects, pDrCmdInternal->Cmd.RectsInfo.aRects, cRects * sizeof (RECT)); 457 461 } 458 462 else 459 463 { 460 Assert(pContext->pLastReportedRects-> fFlags.bAddHiddenRects);464 Assert(pContext->pLastReportedRects->Cmd.fFlags.bAddHiddenRects); 461 465 bSend = true; 462 466 } … … 473 477 vboxVideoCmCmdRelease(pContext->pLastReportedRects); 474 478 475 pDrCmd->fFlags.bSetVisibleRects = 1; 476 477 vboxVideoCmCmdRetain(pDrCmd); 478 pContext->pLastReportedRects = pDrCmd; 479 vboxVideoCmCmdSubmit(pDrCmd, VBOXVIDEOCM_SUBMITSIZE_DEFAULT); 479 pDrCmdInternal->Cmd.fFlags.bSetVisibleRects = 1; 480 pDrCmdInternal->VidPnSourceId = pRectsInfo->VidPnSourceId; 481 482 vboxVideoCmCmdRetain(pDrCmdInternal); 483 pContext->pLastReportedRects = pDrCmdInternal; 484 vboxVideoCmCmdSubmit(pDrCmdInternal, VBOXVIDEOCM_SUBMITSIZE_DEFAULT); 480 485 } 481 486 else 482 487 { 483 if (!pCmd )484 pCmd = pDrCmd;488 if (!pCmdInternal) 489 pCmdInternal = pDrCmdInternal; 485 490 else 486 vboxVideoCmCmdRelease(pDrCmd );491 vboxVideoCmCmdRelease(pDrCmdInternal); 487 492 } 488 493 } … … 491 496 492 497 493 if (pCmd )494 vboxVideoCmCmdRelease(pCmd );498 if (pCmdInternal) 499 vboxVideoCmCmdRelease(pCmdInternal); 495 500 496 501 return Status; -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.h
r30953 r31797 79 79 VBOXVDMAPIPE_CMD_DR Hdr; 80 80 struct VBOXWDDM_CONTEXT *pContext; 81 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; 81 82 VBOXVDMAPIPE_RECTS ContextsRects; 82 83 } VBOXVDMAPIPE_CMD_RECTSINFO, *PVBOXVDMAPIPE_CMD_RECTSINFO; -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r31763 r31797 2066 2066 } 2067 2067 2068 static void vboxWddmSubmitBltCmd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ SOURCE pSource, PVBOXWDDM_CONTEXT pContext, PVBOXWDDM_DMA_PRESENT_BLT pBlt)2068 static void vboxWddmSubmitBltCmd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_DMA_PRESENT_BLT pBlt) 2069 2069 { 2070 2070 PVBOXVDMAPIPE_CMD_RECTSINFO pRectsCmd = (PVBOXVDMAPIPE_CMD_RECTSINFO)vboxVdmaGgCmdCreate(&pDevExt->u.primary.Vdma.DmaGg, VBOXVDMAPIPE_CMD_TYPE_RECTSINFO, RT_OFFSETOF(VBOXVDMAPIPE_CMD_RECTSINFO, ContextsRects.UpdateRects.aRects[pBlt->DstRects.UpdateRects.cRects])); … … 2072 2072 if (pRectsCmd) 2073 2073 { 2074 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pBlt->Hdr.DstAllocInfo.srcId]; 2075 VBOXWDDM_CONTEXT *pContext = pBlt->Hdr.pContext; 2074 2076 pRectsCmd->pContext = pContext; 2077 pRectsCmd->VidPnSourceId = pBlt->Hdr.SrcAllocInfo.srcId; 2075 2078 memcpy(&pRectsCmd->ContextsRects, &pBlt->DstRects, RT_OFFSETOF(VBOXVDMAPIPE_RECTS, UpdateRects.aRects[pBlt->DstRects.UpdateRects.cRects])); 2076 2079 vboxWddmRectTranslate(&pRectsCmd->ContextsRects.ContextRect, pSource->VScreenPos.x, pSource->VScreenPos.y); … … 2184 2187 VBOXVBVA_OP_WITHLOCK_ATDPC(ReportDirtyRect, pDevExt, pSource, &rect); 2185 2188 } 2186 vboxWddmSubmitBltCmd(pDevExt, p Source, pContext, pBlt);2189 vboxWddmSubmitBltCmd(pDevExt, pBlt); 2187 2190 break; 2188 2191 } … … 2193 2196 if (pSrcAlloc->fRcFlags.RenderTarget) 2194 2197 { 2195 vboxWddmSubmitBltCmd(pDevExt, p Source, pContext, pBlt);2198 vboxWddmSubmitBltCmd(pDevExt, pBlt); 2196 2199 } 2197 2200 break; … … 2237 2240 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pPrivateData->SrcAllocInfo.srcId]; 2238 2241 pRectsCmd->pContext = pContext; 2242 pRectsCmd->VidPnSourceId = pPrivateData->SrcAllocInfo.srcId; 2239 2243 RECT r; 2240 2244 r.left = pSource->VScreenPos.x; -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h
r30973 r31797 132 132 UINT uLastCompletedCmdFenceId; 133 133 RECT ViewRect; 134 PVBOXVIDEOCM_CMD_RECTS pLastReportedRects;134 PVBOXVIDEOCM_CMD_RECTS_INTERNAL pLastReportedRects; 135 135 VBOXVIDEOCM_CTX CmContext; 136 136 } VBOXWDDM_CONTEXT, *PVBOXWDDM_CONTEXT;
Note:
See TracChangeset
for help on using the changeset viewer.