Changeset 32325 in vbox
- Timestamp:
- Sep 8, 2010 3:56:34 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r32281 r32325 856 856 } 857 857 858 static void vboxResourceFree(PVBOXWDDMDISP_RESOURCE pRc) 859 { 860 RTMemFree(pRc); 861 } 862 858 863 static PVBOXWDDMDISP_RESOURCE vboxResourceAlloc(UINT cAllocs) 859 864 { … … 1067 1072 } 1068 1073 1074 static HRESULT vboxWddmSurfSynchMem(PVBOXWDDMDISP_RESOURCE pRc, PVBOXWDDMDISP_ALLOCATION pAllocation) 1075 { 1076 HRESULT hr = S_OK; 1077 Assert(pAllocation->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 1078 if (pRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM) 1079 { 1080 Assert(pAllocation->pvMem); 1081 D3DLOCKED_RECT lockInfo; 1082 IDirect3DSurface9 *pD3D9Surf = (IDirect3DSurface9*)pAllocation->pD3DIf; 1083 hr = pD3D9Surf->LockRect(&lockInfo, NULL, D3DLOCK_DISCARD); 1084 Assert(hr == S_OK); 1085 if (hr == S_OK) 1086 { 1087 vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/); 1088 HRESULT tmpHr = pD3D9Surf->UnlockRect(); 1089 Assert(tmpHr == S_OK); 1090 } 1091 } 1092 else 1093 { 1094 Assert(!pAllocation->pvMem); 1095 } 1096 return hr; 1097 } 1098 1099 1069 1100 static HRESULT vboxWddmRenderTargetUpdateSurface(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, uint32_t iBBuf) 1070 1101 { … … 1150 1181 IDirect3DSurface9 *pD3D9Surf; 1151 1182 Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE); 1152 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1153 Assert(pScreen->hWnd); 1154 Assert(pScreen->pDevice9If); 1155 HRESULT hr = pScreen->pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/, 1183 IDirect3DDevice9 * pDevice9If = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If; 1184 HRESULT hr = pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/, 1156 1185 iBBuf, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 1157 1186 Assert(hr == S_OK); … … 1205 1234 # define VBOXVDBG_RTGT_STATECHECK(_pDev) do{}while(0) 1206 1235 #endif 1236 1237 static HRESULT vboxWddmD3DDeviceCreate(PVBOXWDDMDISP_DEVICE pDevice, UINT iScreen, PVBOXWDDMDISP_RESOURCE pRc, D3DPRESENT_PARAMETERS * pParams, BOOL bLockable) 1238 { 1239 UINT cSurfs = pParams->BackBufferCount + 1; 1240 Assert(pRc->cAllocations = cSurfs); 1241 IDirect3DDevice9 *pPrimaryDevice = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If; 1242 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[iScreen]; 1243 PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter; 1244 HRESULT hr; 1245 HWND hWnd = NULL; 1246 Assert(!pScreen->pDevice9If); 1247 Assert(!pScreen->hWnd); 1248 hr = VBoxDispWndCreate(pAdapter, pParams->BackBufferWidth, pParams->BackBufferHeight, &hWnd); 1249 Assert(hr == S_OK); 1250 if (hr == S_OK) 1251 { 1252 pScreen->hWnd = hWnd; 1253 1254 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 1255 if (pDevice->fFlags.AllowMultithreading) 1256 fFlags |= D3DCREATE_MULTITHREADED; 1257 1258 IDirect3DDevice9 *pDevice9If = NULL; 1259 pParams->hDeviceWindow = hWnd; 1260 /* @todo: it seems there should be a way to detect this correctly since 1261 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */ 1262 pParams->Windowed = TRUE; 1263 // params.EnableAutoDepthStencil = FALSE; 1264 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN; 1265 // params.Flags; 1266 // params.FullScreen_RefreshRateInHz; 1267 // params.FullScreen_PresentationInterval; 1268 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, fFlags, pParams, &pDevice9If); 1269 Assert(hr == S_OK); 1270 if (hr == S_OK) 1271 { 1272 pScreen->pDevice9If = pDevice9If; 1273 pScreen->pRenderTargetRc = pRc; 1274 ++pDevice->cScreens; 1275 1276 for (UINT i = 0; i < cSurfs; ++i) 1277 { 1278 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1279 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 1280 } 1281 1282 if (pPrimaryDevice) 1283 { 1284 for (UINT i = 0; i < cSurfs; ++i) 1285 { 1286 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1287 IDirect3DSurface9 *pRt; 1288 IDirect3DSurface9 *pSecondaryOpenedRt; 1289 HANDLE hSharedHandle = NULL; 1290 hr = pPrimaryDevice->CreateRenderTarget( 1291 pParams->BackBufferWidth, pParams->BackBufferHeight, 1292 pParams->BackBufferFormat, 1293 pParams->MultiSampleType, 1294 pParams->MultiSampleQuality, 1295 TRUE, /*BOOL Lockable*/ 1296 &pRt, 1297 &hSharedHandle); 1298 Assert(hr == S_OK); 1299 if (hr == S_OK) 1300 { 1301 Assert(hSharedHandle != NULL); 1302 /* open render target for primary device */ 1303 hr = pDevice9If->CreateRenderTarget( 1304 pParams->BackBufferWidth, pParams->BackBufferHeight, 1305 pParams->BackBufferFormat, 1306 pParams->MultiSampleType, 1307 pParams->MultiSampleQuality, 1308 TRUE, /*BOOL Lockable*/ 1309 &pSecondaryOpenedRt, 1310 &hSharedHandle); 1311 Assert(hr == S_OK); 1312 if (hr == S_OK) 1313 { 1314 pAllocation->pD3DIf = pRt; 1315 pAllocation->pSecondaryOpenedD3DIf = pSecondaryOpenedRt; 1316 pAllocation->hSharedHandle = hSharedHandle; 1317 continue; 1318 } 1319 pRt->Release(); 1320 } 1321 1322 for (UINT j = 0; j < i; ++j) 1323 { 1324 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[j]; 1325 pAlloc->pD3DIf->Release(); 1326 pAlloc->pSecondaryOpenedD3DIf->Release(); 1327 } 1328 1329 break; 1330 } 1331 } 1332 else 1333 { 1334 pDevice->iPrimaryScreen = iScreen; 1335 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0); 1336 Assert(hr == S_OK); 1337 } 1338 1339 if (hr == S_OK) 1340 { 1341 for (UINT i = 0; i < cSurfs; ++i) 1342 { 1343 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1344 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 1345 hr = vboxWddmSurfSynchMem(pRc, pAllocation); 1346 Assert(hr == S_OK); 1347 if (hr != S_OK) 1348 { 1349 break; 1350 } 1351 } 1352 1353 #ifndef VBOXWDDM_WITH_VISIBLE_FB 1354 if (!pPrimaryDevice) 1355 { 1356 if (hr == S_OK) 1357 { 1358 IDirect3DSurface9* pD3D9Surf; 1359 hr = pDevice9If->CreateRenderTarget( 1360 pParams->BackBufferWidth, pParams->BackBufferHeight, 1361 pParams->BackBufferFormat, 1362 pParams->MultiSampleType, 1363 pParams->MultiSampleQuality, 1364 bLockable, 1365 &pD3D9Surf, 1366 NULL /* HANDLE* pSharedHandle */ 1367 ); 1368 Assert(hr == S_OK); 1369 if (hr == S_OK) 1370 { 1371 pDevice->pRenderTargetFbCopy = pD3D9Surf; 1372 } 1373 } 1374 } 1375 #endif 1376 1377 if (hr != S_OK) 1378 { 1379 for (UINT i = 0; i < cSurfs; ++i) 1380 { 1381 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1382 pAllocation->pD3DIf->Release(); 1383 } 1384 } 1385 } 1386 1387 if (hr != S_OK) 1388 { 1389 pDevice9If->Release(); 1390 --pDevice->cScreens; 1391 Assert(pDevice->cScreens < UINT32_MAX/2); 1392 } 1393 } 1394 1395 if (hr != S_OK) 1396 { 1397 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pScreen->hWnd); 1398 Assert(tmpHr == S_OK); 1399 } 1400 } 1401 1402 return hr; 1403 } 1404 1405 static HRESULT vboxWddmD3DDeviceCreateDummy(PVBOXWDDMDISP_DEVICE pDevice) 1406 { 1407 HRESULT hr; 1408 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(2); 1409 Assert(pRc); 1410 if (pRc) 1411 { 1412 D3DPRESENT_PARAMETERS params; 1413 memset(¶ms, 0, sizeof (params)); 1414 // params.BackBufferWidth = 640; 1415 // params.BackBufferHeight = 480; 1416 params.BackBufferWidth = 0x400; 1417 params.BackBufferHeight = 0x300; 1418 params.BackBufferFormat = D3DFMT_A8R8G8B8; 1419 // params.BackBufferCount = 0; 1420 params.BackBufferCount = 1; 1421 params.MultiSampleType = D3DMULTISAMPLE_NONE; 1422 params.SwapEffect = D3DSWAPEFFECT_DISCARD; 1423 // params.hDeviceWindow = hWnd; 1424 /* @todo: it seems there should be a way to detect this correctly since 1425 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */ 1426 params.Windowed = TRUE; 1427 // params.EnableAutoDepthStencil = FALSE; 1428 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN; 1429 // params.Flags; 1430 // params.FullScreen_RefreshRateInHz; 1431 // params.FullScreen_PresentationInterval; 1432 1433 hr = vboxWddmD3DDeviceCreate(pDevice, 0, pRc, ¶ms, TRUE /*BOOL bLockable*/); 1434 Assert(hr == S_OK); 1435 if (hr != S_OK) 1436 vboxResourceFree(pRc); 1437 } 1438 else 1439 { 1440 hr = E_OUTOFMEMORY; 1441 } 1442 1443 return hr; 1444 } 1445 1446 DECLINLINE(IDirect3DDevice9*) vboxWddmD3DDeviceGetPrimary(PVBOXWDDMDISP_DEVICE pDevice) 1447 { 1448 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1449 if (pScreen->pDevice9If) 1450 return pScreen->pDevice9If; 1451 HRESULT hr = vboxWddmD3DDeviceCreateDummy(pDevice); 1452 Assert(hr == S_OK); 1453 Assert(pScreen->pDevice9If); 1454 return pScreen->pDevice9If; 1455 } 1456 1457 static HRESULT APIENTRY vboxWddmDDevDestroyResource(HANDLE hDevice, HANDLE hResource); 1458 1459 static HRESULT vboxWddmD3DDeviceUpdate(PVBOXWDDMDISP_DEVICE pDevice, UINT iScreen, PVBOXWDDMDISP_RESOURCE pRc, D3DPRESENT_PARAMETERS * pParams, BOOL bLockable) 1460 { 1461 UINT cSurfs = pParams->BackBufferCount + 1; 1462 Assert(pRc->cAllocations = cSurfs); 1463 Assert(iScreen == pDevice->iPrimaryScreen); 1464 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[iScreen]; 1465 PVBOXWDDMDISP_RESOURCE pCurRc = pScreen->pRenderTargetRc; 1466 IDirect3DDevice9Ex *pNewDevice; 1467 HRESULT hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9Update((IDirect3DDevice9Ex*)pScreen->pDevice9If, pParams, &pNewDevice); 1468 Assert(hr == S_OK); 1469 if (hr == S_OK) 1470 { 1471 pScreen->pDevice9If->Release(); 1472 pScreen->pDevice9If = pNewDevice; 1473 pScreen->pRenderTargetRc = pRc; 1474 1475 for (UINT i = 0; i < cSurfs; ++i) 1476 { 1477 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1478 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 1479 } 1480 1481 #ifndef VBOXWDDM_WITH_VISIBLE_FB 1482 if (pDevice->pRenderTargetFbCopy) 1483 { 1484 pDevice->pRenderTargetFbCopy->Release(); 1485 } 1486 IDirect3DSurface9* pD3D9Surf; 1487 hr = pNewDevice->CreateRenderTarget( 1488 pParams->BackBufferWidth, pParams->BackBufferHeight, 1489 pParams->BackBufferFormat, 1490 pParams->MultiSampleType, 1491 pParams->MultiSampleQuality, 1492 bLockable, 1493 &pD3D9Surf, 1494 NULL /* HANDLE* pSharedHandle */ 1495 ); 1496 Assert(hr == S_OK); 1497 if (hr == S_OK) 1498 { 1499 pDevice->pRenderTargetFbCopy = pD3D9Surf; 1500 } 1501 #endif 1502 if (hr == S_OK) 1503 { 1504 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0); 1505 Assert(hr == S_OK); 1506 if (hr == S_OK) 1507 { 1508 for (UINT i = 0; i < cSurfs; ++i) 1509 { 1510 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1511 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE; 1512 hr = vboxWddmSurfSynchMem(pRc, pAllocation); 1513 Assert(hr == S_OK); 1514 if (hr != S_OK) 1515 { 1516 break; 1517 } 1518 } 1519 } 1520 } 1521 } 1522 1523 1524 if (!pCurRc->hResource) 1525 { 1526 HRESULT tmpHr = vboxWddmDDevDestroyResource(pDevice, pCurRc); 1527 Assert(tmpHr == S_OK); 1528 } 1529 1530 return hr; 1531 } 1207 1532 1208 1533 static D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format) … … 1352 1677 Assert((fFlags.Value & (~(0x00000100 | 0x00000200 | 0x00000400))) == 0); 1353 1678 return D3DTEXF_NONE; 1354 }1355 1356 static void vboxResourceFree(PVBOXWDDMDISP_RESOURCE pRc)1357 {1358 RTMemFree(pRc);1359 1679 } 1360 1680 … … 1805 2125 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1806 2126 Assert(pDevice); 1807 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1808 Assert(pScreen->hWnd); 1809 Assert(pScreen->pDevice9If); 1810 HRESULT hr = pScreen->pDevice9If->SetRenderState(vboxDDI2D3DRenderStateType(pData->State), pData->Value); 2127 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2128 HRESULT hr = pDevice9If->SetRenderState(vboxDDI2D3DRenderStateType(pData->State), pData->Value); 1811 2129 Assert(hr == S_OK); 1812 2130 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1834 2152 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1835 2153 Assert(pDevice); 1836 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1837 Assert(pScreen->hWnd); 1838 Assert(pScreen->pDevice9If); 2154 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 1839 2155 1840 2156 VBOXWDDMDISP_TSS_LOOKUP lookup = vboxDDI2D3DTestureStageStateType(pData->State); … … 1843 2159 if (!lookup.bSamplerState) 1844 2160 { 1845 hr = p Screen->pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value);1846 } 2161 hr = pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value); 2162 } 1847 2163 else 1848 2164 { 1849 hr = p Screen->pDevice9If->SetSamplerState(pData->Stage, D3DSAMPLERSTATETYPE(lookup.dType), pData->Value);2165 hr = pDevice9If->SetSamplerState(pData->Stage, D3DSAMPLERSTATETYPE(lookup.dType), pData->Value); 1850 2166 } 1851 2167 … … 1860 2176 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1861 2177 Assert(pDevice); 1862 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1863 Assert(pScreen->hWnd); 1864 Assert(pScreen->pDevice9If); 2178 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 1865 2179 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)hTexture; 1866 2180 // Assert(pRc); … … 1883 2197 1884 2198 // Assert(pD3DIfTex); 1885 HRESULT hr = p Screen->pDevice9If->SetTexture(Stage, pD3DIfTex);2199 HRESULT hr = pDevice9If->SetTexture(Stage, pD3DIfTex); 1886 2200 Assert(hr == S_OK); 1887 2201 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1894 2208 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1895 2209 Assert(pDevice); 1896 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1897 Assert(pScreen->hWnd); 1898 Assert(pScreen->pDevice9If); 2210 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 1899 2211 IDirect3DPixelShader9 *pShader = (IDirect3DPixelShader9*)hShaderHandle; 1900 2212 Assert(pShader); 1901 HRESULT hr = p Screen->pDevice9If->SetPixelShader(pShader);2213 HRESULT hr = pDevice9If->SetPixelShader(pShader); 1902 2214 Assert(hr == S_OK); 1903 2215 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1910 2222 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1911 2223 Assert(pDevice); 1912 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1913 Assert(pScreen->hWnd); 1914 Assert(pScreen->pDevice9If); 1915 HRESULT hr = pScreen->pDevice9If->SetPixelShaderConstantF(pData->Register, pRegisters, pData->Count); 2224 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2225 HRESULT hr = pDevice9If->SetPixelShaderConstantF(pData->Register, pRegisters, pData->Count); 1916 2226 Assert(hr == S_OK); 1917 2227 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 1924 2234 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1925 2235 Assert(pDevice); 1926 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen];1927 Assert(pScreen->hWnd);1928 Assert(pScreen->pDevice9If);1929 2236 HRESULT hr = S_OK; 1930 2237 // IDirect3DVertexBuffer9 *pStreamData; … … 1957 2264 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1958 2265 Assert(pDevice); 1959 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 1960 Assert(pScreen->hWnd); 1961 Assert(pScreen->pDevice9If); 2266 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 1962 2267 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hIndexBuffer; 1963 2268 PVBOXWDDMDISP_ALLOCATION pAlloc = NULL; … … 1970 2275 pIndexBuffer = (IDirect3DIndexBuffer9*)pAlloc->pD3DIf; 1971 2276 } 1972 HRESULT hr = p Screen->pDevice9If->SetIndices(pIndexBuffer);2277 HRESULT hr = pDevice9If->SetIndices(pIndexBuffer); 1973 2278 Assert(hr == S_OK); 1974 2279 if (hr == S_OK) … … 1986 2291 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1987 2292 Assert(pDevice); 1988 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen];1989 Assert(pScreen->hWnd);1990 Assert(pScreen->pDevice9If);1991 2293 HRESULT hr = S_OK; 1992 2294 pDevice->IndiciesUm.pvBuffer = pUMBuffer; … … 2001 2303 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2002 2304 Assert(pDevice); 2003 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2004 Assert(pScreen->hWnd); 2005 Assert(pScreen->pDevice9If); 2305 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2006 2306 Assert(!pFlagBuffer); 2007 2307 HRESULT hr = S_OK; … … 2023 2323 } 2024 2324 #endif 2025 hr = p Screen->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType,2325 hr = pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, 2026 2326 pData->PrimitiveCount, 2027 2327 ((uint8_t*)pDevice->aStreamSourceUm[0].pvBuffer) + pData->VStart * pDevice->aStreamSourceUm[0].cbStride, … … 2059 2359 Assert(cStreams == pDevice->cStreamSources); 2060 2360 #endif 2061 hr = p Screen->pDevice9If->DrawPrimitive(pData->PrimitiveType,2361 hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, 2062 2362 pData->VStart, 2063 2363 pData->PrimitiveCount); … … 2067 2367 #if 0 2068 2368 IDirect3DVertexDeclaration9* pDecl; 2069 hr = p Screen->pDevice9If->GetVertexDeclaration(&pDecl);2369 hr = pDevice9If->GetVertexDeclaration(&pDecl); 2070 2370 Assert(hr == S_OK); 2071 2371 if (hr == S_OK) … … 2192 2492 UINT cbOffset; 2193 2493 UINT cbStride; 2194 hr = p Screen->pDevice9If->GetStreamSource(iStream, &pCurVb, &cbOffset, &cbStride);2494 hr = pDevice9If->GetStreamSource(iStream, &pCurVb, &cbOffset, &cbStride); 2195 2495 Assert(hr == S_OK); 2196 2496 if (hr == S_OK) … … 2219 2519 if (!pVb) 2220 2520 { 2221 hr = p Screen->pDevice9If->CreateVertexBuffer(cbVertexes,2521 hr = pDevice9If->CreateVertexBuffer(cbVertexes, 2222 2522 0, /* DWORD Usage */ 2223 2523 0, /* DWORD FVF */ … … 2228 2528 if (hr == S_OK) 2229 2529 { 2230 hr = p Screen->pDevice9If->SetStreamSource(iStream, pVb, 0, pStrSrc->cbStride);2530 hr = pDevice9If->SetStreamSource(iStream, pVb, 0, pStrSrc->cbStride); 2231 2531 Assert(hr == S_OK); 2232 2532 if (hr == S_OK) … … 2265 2565 if (hr == S_OK) 2266 2566 { 2267 hr = p Screen->pDevice9If->DrawPrimitive(pData->PrimitiveType,2567 hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, 2268 2568 0 /* <- since we use our owne StreamSource buffer which has data at the very beginning*/, 2269 2569 pData->PrimitiveCount); … … 2289 2589 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2290 2590 Assert(pDevice); 2291 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2292 Assert(pScreen->hWnd); 2293 Assert(pScreen->pDevice9If); 2591 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2294 2592 //#ifdef DEBUG_misha 2295 2593 // uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; … … 2321 2619 #endif 2322 2620 2323 HRESULT hr = p Screen->pDevice9If->DrawIndexedPrimitive(2621 HRESULT hr = pDevice9If->DrawIndexedPrimitive( 2324 2622 pData->PrimitiveType, 2325 2623 pData->BaseVertexIndex, … … 2362 2660 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2363 2661 Assert(pDevice); 2364 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2365 Assert(pScreen->hWnd); 2366 Assert(pScreen->pDevice9If); 2662 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2367 2663 HRESULT hr; 2368 2664 … … 2394 2690 } 2395 2691 2396 hr = p Screen->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount);2692 hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount); 2397 2693 #else 2398 2694 //#ifdef DEBUG_misha … … 2423 2719 2424 2720 Assert(pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite)); 2425 hr = p Screen->pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, pData->PrimitiveCount,2721 hr = pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, pData->PrimitiveCount, 2426 2722 (void*)((uintptr_t)pDevice->aStreamSource[stream]->pvMem+pDevice->StreamSourceInfo[stream].uiOffset+pData->FirstVertexOffset), 2427 2723 pDevice->StreamSourceInfo[stream].uiStride); 2428 2724 Assert(hr == S_OK); 2429 hr = p Screen->pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride);2725 hr = pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride); 2430 2726 Assert(hr == S_OK); 2431 2727 } … … 2434 2730 // vboxVDbgMpPrint((pDevice, __FUNCTION__": DrawPrimitive\n")); 2435 2731 2436 hr = p Screen->pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);2732 hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount); 2437 2733 Assert(hr == S_OK); 2438 2734 } … … 2486 2782 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2487 2783 Assert(pDevice); 2488 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2489 Assert(pScreen->hWnd); 2490 Assert(pScreen->pDevice9If); 2784 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2491 2785 PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource; 2492 2786 PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; … … 2510 2804 && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height) 2511 2805 { 2512 hr = p Screen->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);2806 hr = pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex); 2513 2807 Assert(hr == S_OK); 2514 2808 } … … 2558 2852 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2559 2853 Assert(pDevice); 2560 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2561 Assert(pScreen->hWnd); 2562 Assert(pScreen->pDevice9If); 2563 HRESULT hr = pScreen->pDevice9If->Clear(NumRect, (D3DRECT*)pRect /* see AssertCompile above */, 2854 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2855 HRESULT hr = pDevice9If->Clear(NumRect, (D3DRECT*)pRect /* see AssertCompile above */, 2564 2856 pData->Flags, 2565 2857 pData->FillColor, … … 2591 2883 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2592 2884 Assert(pDevice); 2593 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2594 Assert(pScreen->hWnd); 2595 Assert(pScreen->pDevice9If); 2596 HRESULT hr = pScreen->pDevice9If->SetVertexShaderConstantF( 2885 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2886 HRESULT hr = pDevice9If->SetVertexShaderConstantF( 2597 2887 pData->Register, 2598 2888 (CONST float*)pRegisters, … … 2621 2911 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2622 2912 Assert(pDevice); 2623 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2624 Assert(pScreen->hWnd); 2625 Assert(pScreen->pDevice9If); 2913 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2626 2914 pDevice->ViewPort.X = pData->X; 2627 2915 pDevice->ViewPort.Y = pData->Y; 2628 2916 pDevice->ViewPort.Width = pData->Width; 2629 2917 pDevice->ViewPort.Height = pData->Height; 2630 HRESULT hr = p Screen->pDevice9If->SetViewport(&pDevice->ViewPort);2918 HRESULT hr = pDevice9If->SetViewport(&pDevice->ViewPort); 2631 2919 Assert(hr == S_OK); 2632 2920 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 2638 2926 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2639 2927 Assert(pDevice); 2640 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2641 Assert(pScreen->hWnd); 2642 Assert(pScreen->pDevice9If); 2928 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2643 2929 pDevice->ViewPort.MinZ = pData->MinZ; 2644 2930 pDevice->ViewPort.MaxZ = pData->MaxZ; 2645 HRESULT hr = p Screen->pDevice9If->SetViewport(&pDevice->ViewPort);2931 HRESULT hr = pDevice9If->SetViewport(&pDevice->ViewPort); 2646 2932 Assert(hr == S_OK); 2647 2933 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 2681 2967 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2682 2968 Assert(pDevice); 2683 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 2684 Assert(pScreen->hWnd); 2685 Assert(pScreen->pDevice9If); 2686 HRESULT hr = pScreen->pDevice9If->SetClipPlane(pData->Index, pData->Plane); 2969 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 2970 HRESULT hr = pDevice9If->SetClipPlane(pData->Index, pData->Plane); 2687 2971 Assert(hr == S_OK); 2688 2972 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 3164 3448 --pAlloc->LockInfo.cLocks; 3165 3449 Assert(pAlloc->LockInfo.cLocks < UINT32_MAX); 3166 if (!pAlloc->LockInfo.cLocks 3450 if (!pAlloc->LockInfo.cLocks 3167 3451 && (!pAlloc->LockInfo.fFlags.MightDrawFromLocked 3168 3452 || (!pAlloc->LockInfo.fFlags.Discard && !pAlloc->LockInfo.fFlags.NoOverwrite))) … … 3333 3617 } 3334 3618 3335 static HRESULT vboxWddmSurfSynchMem(PVBOXWDDMDISP_RESOURCE pRc, PVBOXWDDMDISP_ALLOCATION pAllocation)3336 {3337 HRESULT hr = S_OK;3338 Assert(pAllocation->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);3339 if (pRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM)3340 {3341 Assert(pAllocation->pvMem);3342 D3DLOCKED_RECT lockInfo;3343 IDirect3DSurface9 *pD3D9Surf = (IDirect3DSurface9*)pAllocation->pD3DIf;3344 hr = pD3D9Surf->LockRect(&lockInfo, NULL, D3DLOCK_DISCARD);3345 Assert(hr == S_OK);3346 if (hr == S_OK)3347 {3348 vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/);3349 HRESULT tmpHr = pD3D9Surf->UnlockRect();3350 Assert(tmpHr == S_OK);3351 }3352 }3353 else3354 {3355 Assert(!pAllocation->pvMem);3356 }3357 return hr;3358 }3359 3360 static HRESULT vboxWddmD3DDeviceCreate(PVBOXWDDMDISP_DEVICE pDevice, UINT iScreen, PVBOXWDDMDISP_RESOURCE pRc, D3DPRESENT_PARAMETERS * pParams, BOOL bLockable)3361 {3362 UINT cSurfs = pParams->BackBufferCount + 1;3363 Assert(pRc->cAllocations = cSurfs);3364 IDirect3DDevice9 *pPrimaryDevice = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If;3365 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[iScreen];3366 PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter;3367 HRESULT hr;3368 HWND hWnd = NULL;3369 Assert(!pScreen->pDevice9If);3370 Assert(!pScreen->hWnd);3371 hr = VBoxDispWndCreate(pAdapter, pParams->BackBufferWidth, pParams->BackBufferHeight, &hWnd);3372 Assert(hr == S_OK);3373 if (hr == S_OK)3374 {3375 pScreen->hWnd = hWnd;3376 3377 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;3378 if (pDevice->fFlags.AllowMultithreading)3379 fFlags |= D3DCREATE_MULTITHREADED;3380 3381 IDirect3DDevice9 *pDevice9If = NULL;3382 pParams->hDeviceWindow = hWnd;3383 /* @todo: it seems there should be a way to detect this correctly since3384 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */3385 pParams->Windowed = TRUE;3386 // params.EnableAutoDepthStencil = FALSE;3387 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN;3388 // params.Flags;3389 // params.FullScreen_RefreshRateInHz;3390 // params.FullScreen_PresentationInterval;3391 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, fFlags, pParams, &pDevice9If);3392 Assert(hr == S_OK);3393 if (hr == S_OK)3394 {3395 pScreen->pDevice9If = pDevice9If;3396 pScreen->pRenderTargetRc = pRc;3397 ++pDevice->cScreens;3398 3399 for (UINT i = 0; i < cSurfs; ++i)3400 {3401 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];3402 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;3403 }3404 3405 if (pPrimaryDevice)3406 {3407 for (UINT i = 0; i < cSurfs; ++i)3408 {3409 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];3410 IDirect3DSurface9 *pRt;3411 IDirect3DSurface9 *pSecondaryOpenedRt;3412 HANDLE hSharedHandle = NULL;3413 hr = pPrimaryDevice->CreateRenderTarget(3414 pParams->BackBufferWidth, pParams->BackBufferHeight,3415 pParams->BackBufferFormat,3416 pParams->MultiSampleType,3417 pParams->MultiSampleQuality,3418 TRUE, /*BOOL Lockable*/3419 &pRt,3420 &hSharedHandle);3421 Assert(hr == S_OK);3422 if (hr == S_OK)3423 {3424 Assert(hSharedHandle != NULL);3425 /* open render target for primary device */3426 hr = pDevice9If->CreateRenderTarget(3427 pParams->BackBufferWidth, pParams->BackBufferHeight,3428 pParams->BackBufferFormat,3429 pParams->MultiSampleType,3430 pParams->MultiSampleQuality,3431 TRUE, /*BOOL Lockable*/3432 &pSecondaryOpenedRt,3433 &hSharedHandle);3434 Assert(hr == S_OK);3435 if (hr == S_OK)3436 {3437 pAllocation->pD3DIf = pRt;3438 pAllocation->pSecondaryOpenedD3DIf = pSecondaryOpenedRt;3439 pAllocation->hSharedHandle = hSharedHandle;3440 continue;3441 }3442 pRt->Release();3443 }3444 3445 for (UINT j = 0; j < i; ++j)3446 {3447 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[j];3448 pAlloc->pD3DIf->Release();3449 pAlloc->pSecondaryOpenedD3DIf->Release();3450 }3451 3452 break;3453 }3454 }3455 else3456 {3457 pDevice->iPrimaryScreen = iScreen;3458 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0);3459 Assert(hr == S_OK);3460 }3461 3462 if (hr == S_OK)3463 {3464 for (UINT i = 0; i < cSurfs; ++i)3465 {3466 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];3467 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;3468 hr = vboxWddmSurfSynchMem(pRc, pAllocation);3469 Assert(hr == S_OK);3470 if (hr != S_OK)3471 {3472 break;3473 }3474 }3475 3476 #ifndef VBOXWDDM_WITH_VISIBLE_FB3477 if (!pPrimaryDevice)3478 {3479 if (hr == S_OK)3480 {3481 IDirect3DSurface9* pD3D9Surf;3482 hr = pDevice9If->CreateRenderTarget(3483 pParams->BackBufferWidth, pParams->BackBufferHeight,3484 pParams->BackBufferFormat,3485 pParams->MultiSampleType,3486 pParams->MultiSampleQuality,3487 bLockable,3488 &pD3D9Surf,3489 NULL /* HANDLE* pSharedHandle */3490 );3491 Assert(hr == S_OK);3492 if (hr == S_OK)3493 {3494 pDevice->pRenderTargetFbCopy = pD3D9Surf;3495 }3496 }3497 }3498 #endif3499 3500 if (hr != S_OK)3501 {3502 for (UINT i = 0; i < cSurfs; ++i)3503 {3504 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];3505 pAllocation->pD3DIf->Release();3506 }3507 }3508 }3509 3510 if (hr != S_OK)3511 {3512 pDevice9If->Release();3513 --pDevice->cScreens;3514 Assert(pDevice->cScreens < UINT32_MAX/2);3515 }3516 }3517 3518 if (hr != S_OK)3519 {3520 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pScreen->hWnd);3521 Assert(tmpHr == S_OK);3522 }3523 }3524 3525 return hr;3526 }3527 3528 static HRESULT APIENTRY vboxWddmDDevDestroyResource(HANDLE hDevice, HANDLE hResource);3529 3530 static HRESULT vboxWddmD3DDeviceUpdate(PVBOXWDDMDISP_DEVICE pDevice, UINT iScreen, PVBOXWDDMDISP_RESOURCE pRc, D3DPRESENT_PARAMETERS * pParams, BOOL bLockable)3531 {3532 UINT cSurfs = pParams->BackBufferCount + 1;3533 Assert(pRc->cAllocations = cSurfs);3534 Assert(iScreen == pDevice->iPrimaryScreen);3535 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[iScreen];3536 PVBOXWDDMDISP_RESOURCE pCurRc = pScreen->pRenderTargetRc;3537 IDirect3DDevice9Ex *pNewDevice;3538 HRESULT hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9Update((IDirect3DDevice9Ex*)pScreen->pDevice9If, pParams, &pNewDevice);3539 Assert(hr == S_OK);3540 if (hr == S_OK)3541 {3542 pScreen->pDevice9If->Release();3543 pScreen->pDevice9If = pNewDevice;3544 pScreen->pRenderTargetRc = pRc;3545 3546 for (UINT i = 0; i < cSurfs; ++i)3547 {3548 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];3549 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;3550 }3551 3552 #ifndef VBOXWDDM_WITH_VISIBLE_FB3553 if (pDevice->pRenderTargetFbCopy)3554 {3555 pDevice->pRenderTargetFbCopy->Release();3556 }3557 IDirect3DSurface9* pD3D9Surf;3558 hr = pNewDevice->CreateRenderTarget(3559 pParams->BackBufferWidth, pParams->BackBufferHeight,3560 pParams->BackBufferFormat,3561 pParams->MultiSampleType,3562 pParams->MultiSampleQuality,3563 bLockable,3564 &pD3D9Surf,3565 NULL /* HANDLE* pSharedHandle */3566 );3567 Assert(hr == S_OK);3568 if (hr == S_OK)3569 {3570 pDevice->pRenderTargetFbCopy = pD3D9Surf;3571 }3572 #endif3573 if (hr == S_OK)3574 {3575 hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0);3576 Assert(hr == S_OK);3577 if (hr == S_OK)3578 {3579 for (UINT i = 0; i < cSurfs; ++i)3580 {3581 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];3582 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;3583 hr = vboxWddmSurfSynchMem(pRc, pAllocation);3584 Assert(hr == S_OK);3585 if (hr != S_OK)3586 {3587 break;3588 }3589 }3590 }3591 }3592 }3593 3594 3595 if (!pCurRc->hResource)3596 {3597 HRESULT tmpHr = vboxWddmDDevDestroyResource(pDevice, pCurRc);3598 Assert(tmpHr == S_OK);3599 }3600 3601 return hr;3602 }3603 3604 3619 static HRESULT APIENTRY vboxWddmDDevCreateResource(HANDLE hDevice, D3DDDIARG_CREATERESOURCE* pResource) 3605 3620 { … … 3616 3631 { 3617 3632 bool bIssueCreateResource = false; 3633 bool bCreateKMResource = false; 3618 3634 3619 3635 pRc->hResource = pResource->hResource; … … 3653 3669 Assert(0); /* <-- need to test that */ 3654 3670 bIssueCreateResource = true; 3671 bCreateKMResource = true; 3655 3672 } 3656 3673 3657 3674 if (pResource->Flags.ZBuffer) 3658 3675 { 3659 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3660 Assert(pScreen->hWnd); 3661 Assert(pScreen->pDevice9If); 3676 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 3662 3677 for (UINT i = 0; i < pResource->SurfCount; ++i) 3663 3678 { 3664 3679 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3665 3680 IDirect3DSurface9 *pD3D9Surf; 3666 hr = p Screen->pDevice9If->CreateDepthStencilSurface(pAllocation->SurfDesc.width,3681 hr = pDevice9If->CreateDepthStencilSurface(pAllocation->SurfDesc.width, 3667 3682 pAllocation->SurfDesc.height, 3668 3683 vboxDDI2D3DFormat(pResource->Format), … … 3693 3708 else if (pResource->Flags.VertexBuffer) 3694 3709 { 3695 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3696 Assert(pScreen->hWnd); 3697 Assert(pScreen->pDevice9If); 3710 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 3711 3698 3712 for (UINT i = 0; i < pResource->SurfCount; ++i) 3699 3713 { 3700 3714 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3701 3715 IDirect3DVertexBuffer9 *pD3D9VBuf; 3702 hr = p Screen->pDevice9If->CreateVertexBuffer(pAllocation->SurfDesc.width,3716 hr = pDevice9If->CreateVertexBuffer(pAllocation->SurfDesc.width, 3703 3717 vboxDDI2D3DUsage(pResource->Flags), 3704 3718 pResource->Fvf, … … 3743 3757 else if (pResource->Flags.IndexBuffer) 3744 3758 { 3745 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3746 Assert(pScreen->hWnd); 3747 Assert(pScreen->pDevice9If); 3759 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 3760 3748 3761 for (UINT i = 0; i < pResource->SurfCount; ++i) 3749 3762 { … … 3751 3764 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 3752 3765 IDirect3DIndexBuffer9 *pD3D9IBuf; 3753 hr = p Screen->pDevice9If->CreateIndexBuffer(pSurf->Width,3766 hr = pDevice9If->CreateIndexBuffer(pSurf->Width, 3754 3767 vboxDDI2D3DUsage(pResource->Flags), 3755 3768 vboxDDI2D3DFormat(pResource->Format), … … 3795 3808 else if (pResource->Flags.Texture || pResource->Flags.Value == 0) 3796 3809 { 3797 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3798 Assert(pScreen->hWnd); 3799 Assert(pScreen->pDevice9If); 3810 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 3811 3800 3812 #ifdef DEBUG 3801 3813 { … … 3813 3825 #endif 3814 3826 3815 if (pResource->Flags.RenderTarget)3816 bIssueCreateResource = true;3827 // if (pResource->Flags.RenderTarget) 3828 // bIssueCreateResource = true; 3817 3829 3818 3830 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; … … 3821 3833 HANDLE hSharedHandle = NULL; 3822 3834 #if 0 3823 hr = p Screen->pDevice9If->CreateTexture(pSurf->Width,3835 hr = pDevice9If->CreateTexture(pSurf->Width, 3824 3836 pSurf->Height, 3825 3837 pResource->SurfCount, … … 3831 3843 ); 3832 3844 #else 3833 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)p Screen->pDevice9If,3845 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If, 3834 3846 pSurf->Width, 3835 3847 pSurf->Height, … … 3891 3903 bIssueCreateResource = true; 3892 3904 Assert(pResource->SurfCount); 3893 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 3894 IDirect3DDevice9 *pPrimaryDevice = pScreen->pDevice9If; 3895 if (!pPrimaryDevice || !pScreen->pRenderTargetRc->hResource || pResource->Flags.Primary) 3905 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pResource->VidPnSourceId]; 3906 bool bDevAdjusted = pScreen->pRenderTargetRc && pScreen->pRenderTargetRc->hResource; 3907 bool bIsPrimary = !(pDevice->aScreens[pDevice->iPrimaryScreen].pRenderTargetRc 3908 && pDevice->aScreens[pDevice->iPrimaryScreen].pRenderTargetRc->hResource); 3909 if (!bDevAdjusted) 3896 3910 { 3897 3911 D3DPRESENT_PARAMETERS params; … … 3901 3915 params.BackBufferFormat = vboxDDI2D3DFormat(pResource->Format); 3902 3916 Assert(pResource->SurfCount); 3903 params.BackBufferCount = !pPrimaryDevice? pResource->SurfCount - 1 : 0;3917 params.BackBufferCount = bIsPrimary ? pResource->SurfCount - 1 : 0; 3904 3918 params.MultiSampleType = vboxDDI2D3DMultiSampleType(pResource->MultisampleType); 3905 3919 if (pResource->Flags.DiscardRenderTarget) … … 3915 3929 // params.FullScreen_PresentationInterval; 3916 3930 3917 if (!p PrimaryDevice || pResource->Flags.Primary)3931 if (!pScreen->pDevice9If) 3918 3932 { 3933 #ifdef VBOXDISP_EARLYCREATEDEVICE 3934 Assert(!bIsPrimary); 3935 #endif 3919 3936 hr = vboxWddmD3DDeviceCreate(pDevice, pResource->VidPnSourceId, pRc, ¶ms, !pResource->Flags.NotLockable /*BOOL bLockable*/); 3920 3937 Assert(hr == S_OK); … … 3922 3939 else 3923 3940 { 3924 Assert( 0);3941 Assert(bIsPrimary); 3925 3942 hr = vboxWddmD3DDeviceUpdate(pDevice, pResource->VidPnSourceId, pRc, ¶ms, !pResource->Flags.NotLockable /*BOOL bLockable*/); 3926 3943 Assert(hr == S_OK); … … 3980 3997 { 3981 3998 bIssueCreateResource = true; 3999 bCreateKMResource = true; 3982 4000 } 3983 4001 … … 4044 4062 } 4045 4063 4046 hr = pDevice->RtCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate); 4047 Assert(hr == S_OK); 4048 Assert(pDdiAllocate->hKMResource); 4064 if (bCreateKMResource) 4065 { 4066 hr = pDevice->RtCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate); 4067 Assert(hr == S_OK); 4068 Assert(pDdiAllocate->hKMResource); 4069 } 4070 else 4071 { 4072 pDdiAllocate->hResource = NULL; 4073 pDdiAllocate->NumAllocations = 1; 4074 pDdiAllocate->PrivateDriverDataSize = 0; 4075 pDdiAllocate->pPrivateDriverData = NULL; 4076 D3DDDI_ALLOCATIONINFO *pDdiAllocIBase = pDdiAllocate->pAllocationInfo; 4077 4078 for (UINT i = 0; i < pResource->SurfCount; ++i) 4079 { 4080 pDdiAllocate->pAllocationInfo = &pDdiAllocIBase[i]; 4081 hr = pDevice->RtCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate); 4082 Assert(hr == S_OK); 4083 Assert(!pDdiAllocate->hKMResource); 4084 if (hr == S_OK) 4085 { 4086 Assert(pDdiAllocate->pAllocationInfo->hAllocation); 4087 } 4088 else 4089 { 4090 for (UINT j = 0; i < j; ++j) 4091 { 4092 D3DDDI_ALLOCATIONINFO * pCur = &pDdiAllocIBase[i]; 4093 D3DDDICB_DEALLOCATE Dealloc; 4094 Dealloc.hResource = 0; 4095 Dealloc.NumAllocations = 1; 4096 Dealloc.HandleList = &pCur->hAllocation; 4097 HRESULT tmpHr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc); 4098 Assert(tmpHr == S_OK); 4099 } 4100 break; 4101 } 4102 } 4103 4104 pDdiAllocate->pAllocationInfo = pDdiAllocIBase; 4105 } 4106 4049 4107 if (hr == S_OK) 4050 4108 { … … 4135 4193 hr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc); 4136 4194 Assert(hr == S_OK); 4137 // for (UINT j = 0; j < pRc->cAllocations; ++j) 4138 // { 4139 // D3DDDICB_DEALLOCATE Dealloc; 4140 // Dealloc.hResource = NULL; 4141 // Dealloc.NumAllocations = 1; 4142 // Dealloc.HandleList = &pRc->aAllocations[j].hAllocation; 4143 // HRESULT tmpHr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc); 4144 // Assert(tmpHr = S_OK); 4145 // } 4195 } 4196 } 4197 else 4198 { 4199 Assert(!(pRc->fFlags & VBOXWDDM_RESOURCE_F_OPENNED)); 4200 for (UINT j = 0; j < pRc->cAllocations; ++j) 4201 { 4202 if (pRc->aAllocations[j].hAllocation) 4203 { 4204 D3DDDICB_DEALLOCATE Dealloc; 4205 Dealloc.hResource = NULL; 4206 Dealloc.NumAllocations = 1; 4207 Dealloc.HandleList = &pRc->aAllocations[j].hAllocation; 4208 HRESULT tmpHr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc); 4209 Assert(tmpHr == S_OK); 4210 } 4146 4211 } 4147 4212 } … … 4272 4337 { 4273 4338 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; 4274 Assert(pRc->hKMResource);4275 4339 Assert(pRc->cAllocations > pData->SrcSubResourceIndex); 4276 4340 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SrcSubResourceIndex]; … … 4281 4345 { 4282 4346 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource; 4283 Assert(pRc->hKMResource);4284 4347 Assert(pRc->cAllocations > pData->DstSubResourceIndex); 4285 4348 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->DstSubResourceIndex]; … … 4469 4532 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4470 4533 Assert(pDevice); 4471 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4472 Assert(pScreen->hWnd); 4473 Assert(pScreen->pDevice9If); 4534 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4474 4535 IDirect3DVertexDeclaration9 *pDecl; 4475 4536 static D3DVERTEXELEMENT9 DeclEnd = D3DDECL_END(); … … 4494 4555 if (hr == S_OK) 4495 4556 { 4496 hr = p Screen->pDevice9If->CreateVertexDeclaration(4557 hr = pDevice9If->CreateVertexDeclaration( 4497 4558 pVe, 4498 4559 &pDecl … … 4517 4578 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4518 4579 Assert(pDevice); 4519 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4520 Assert(pScreen->hWnd); 4521 Assert(pScreen->pDevice9If); 4580 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4522 4581 IDirect3DVertexDeclaration9 *pDecl = (IDirect3DVertexDeclaration9*)hShaderHandle; 4523 4582 Assert(pDecl); 4524 HRESULT hr = p Screen->pDevice9If->SetVertexDeclaration(pDecl);4583 HRESULT hr = pDevice9If->SetVertexDeclaration(pDecl); 4525 4584 Assert(hr == S_OK); 4526 4585 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4532 4591 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4533 4592 Assert(pDevice); 4534 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen];4535 Assert(pScreen->hWnd);4536 Assert(pScreen->pDevice9If);4537 4593 IDirect3DVertexDeclaration9 *pDecl = (IDirect3DVertexDeclaration9*)hShaderHandle; 4538 4594 HRESULT hr = S_OK; … … 4546 4602 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4547 4603 Assert(pDevice); 4548 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4549 Assert(pScreen->hWnd); 4550 Assert(pScreen->pDevice9If); 4604 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4551 4605 IDirect3DVertexShader9 *pShader; 4552 4606 Assert(*((UINT*)((uint8_t*)pCode + pData->Size-4)) == 0x0000FFFF /* end token */); 4553 HRESULT hr = p Screen->pDevice9If->CreateVertexShader((const DWORD *)pCode, &pShader);4607 HRESULT hr = pDevice9If->CreateVertexShader((const DWORD *)pCode, &pShader); 4554 4608 Assert(hr == S_OK); 4555 4609 if (hr == S_OK) … … 4566 4620 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4567 4621 Assert(pDevice); 4568 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4569 Assert(pScreen->hWnd); 4570 Assert(pScreen->pDevice9If); 4622 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4571 4623 IDirect3DVertexShader9 *pShader = (IDirect3DVertexShader9*)hShaderHandle; 4572 4624 Assert(pShader); 4573 HRESULT hr = p Screen->pDevice9If->SetVertexShader(pShader);4625 HRESULT hr = pDevice9If->SetVertexShader(pShader); 4574 4626 Assert(hr == S_OK); 4575 4627 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4581 4633 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4582 4634 Assert(pDevice); 4583 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen];4584 Assert(pScreen->hWnd);4585 Assert(pScreen->pDevice9If);4586 4635 IDirect3DVertexShader9 *pShader = (IDirect3DVertexShader9*)hShaderHandle; 4587 4636 HRESULT hr = S_OK; … … 4595 4644 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4596 4645 Assert(pDevice); 4597 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4598 Assert(pScreen->hWnd); 4599 Assert(pScreen->pDevice9If); 4600 HRESULT hr = pScreen->pDevice9If->SetVertexShaderConstantI(pData->Register, pRegisters, pData->Count); 4646 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4647 HRESULT hr = pDevice9If->SetVertexShaderConstantI(pData->Register, pRegisters, pData->Count); 4601 4648 Assert(hr == S_OK); 4602 4649 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4608 4655 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4609 4656 Assert(pDevice); 4610 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4611 Assert(pScreen->hWnd); 4612 Assert(pScreen->pDevice9If); 4613 HRESULT hr = pScreen->pDevice9If->SetVertexShaderConstantB(pData->Register, pRegisters, pData->Count); 4657 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4658 HRESULT hr = pDevice9If->SetVertexShaderConstantB(pData->Register, pRegisters, pData->Count); 4614 4659 Assert(hr == S_OK); 4615 4660 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4621 4666 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4622 4667 Assert(pDevice); 4623 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4624 Assert(pScreen->hWnd); 4625 Assert(pScreen->pDevice9If); 4626 HRESULT hr = pScreen->pDevice9If->SetScissorRect(pRect); 4668 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4669 HRESULT hr = pDevice9If->SetScissorRect(pRect); 4627 4670 Assert(hr == S_OK); 4628 4671 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 4634 4677 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 4635 4678 Assert(pDevice); 4636 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4637 Assert(pScreen->hWnd); 4638 Assert(pScreen->pDevice9If); 4679 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4639 4680 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hVertexBuffer; 4640 4681 PVBOXWDDMDISP_ALLOCATION pAlloc = NULL; … … 4647 4688 pStreamData = (IDirect3DVertexBuffer9*)pAlloc->pD3DIf; 4648 4689 } 4649 HRESULT hr = p Screen->pDevice9If->SetStreamSource(pData->Stream, pStreamData, pData->Offset, pData->Stride);4690 HRESULT hr = pDevice9If->SetStreamSource(pData->Stream, pStreamData, pData->Offset, pData->Stride); 4650 4691 Assert(hr == S_OK); 4651 4692 Assert(pData->Stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS); … … 4799 4840 Assert(pDevice); 4800 4841 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 4801 Assert(pScreen->hWnd); 4802 Assert(pScreen->pDevice9If); 4842 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 4803 4843 PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource; 4804 4844 PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource; … … 4850 4890 && pSrcAlloc->SurfDesc.format == pDstAlloc->SurfDesc.format) 4851 4891 { 4852 hr = p Screen->pDevice9If->GetFrontBufferData(0, pDstSurfIf);4892 hr = pDevice9If->GetFrontBufferData(0, pDstSurfIf); 4853 4893 Assert(hr == S_OK); 4854 4894 break; … … 4859 4899 pSrcSurfIf = pDevice->pRenderTargetFbCopy; 4860 4900 Assert(pSrcSurfIf); 4861 hr = p Screen->pDevice9If->GetFrontBufferData(0, pDevice->pRenderTargetFbCopy);4901 hr = pDevice9If->GetFrontBufferData(0, pDevice->pRenderTargetFbCopy); 4862 4902 Assert(hr == S_OK); 4863 4903 if (hr == S_OK) … … 4917 4957 /* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */ 4918 4958 Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001 | 0x00000002))) == 0); 4919 hr = p Screen->pDevice9If->StretchRect(pSrcSurfIf,4959 hr = pDevice9If->StretchRect(pSrcSurfIf, 4920 4960 &pData->SrcRect, 4921 4961 pDstSurfIf, … … 4966 5006 ) 4967 5007 { 4968 hr = p Screen->pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex);5008 hr = pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex); 4969 5009 Assert(hr == S_OK); 4970 5010 } … … 5066 5106 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 5067 5107 Assert(pDevice); 5068 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5069 Assert(pScreen->hWnd); 5070 Assert(pScreen->pDevice9If); 5108 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5071 5109 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hResource; 5072 5110 Assert(pRc); … … 5077 5115 { 5078 5116 Assert(pSurfIf); 5079 hr = p Screen->pDevice9If->ColorFill(pSurfIf, &pData->DstRect, pData->Color);5117 hr = pDevice9If->ColorFill(pSurfIf, &pData->DstRect, pData->Color); 5080 5118 Assert(hr == S_OK); 5081 5119 /* @todo: check what need to do when PresentToDwm flag is set */ … … 5128 5166 Assert(pDevice); 5129 5167 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5130 Assert(pScreen->hWnd); 5131 Assert(pScreen->pDevice9If); 5168 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5132 5169 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hRenderTarget; 5133 5170 Assert(pRc); … … 5145 5182 { 5146 5183 /* work-around wine double-buffering for the case we have no backbuffers */ 5147 hr = p Screen->pDevice9If->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);5184 hr = pDevice9If->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf); 5148 5185 Assert(hr == S_OK); 5149 5186 Assert(pD3D9Surf); … … 5158 5195 { 5159 5196 Assert(pD3D9Surf); 5160 hr = p Screen->pDevice9If->SetRenderTarget(pData->RenderTargetIndex, pD3D9Surf);5197 hr = pDevice9If->SetRenderTarget(pData->RenderTargetIndex, pD3D9Surf); 5161 5198 Assert(hr == S_OK); 5162 5199 pD3D9Surf->Release(); … … 5170 5207 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 5171 5208 Assert(pDevice); 5172 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5173 Assert(pScreen->hWnd); 5174 Assert(pScreen->pDevice9If); 5209 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5175 5210 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hZBuffer; 5176 5211 IDirect3DSurface9 *pD3D9Surf = NULL; … … 5181 5216 Assert(pD3D9Surf); 5182 5217 } 5183 HRESULT hr = p Screen->pDevice9If->SetDepthStencilSurface(pD3D9Surf);5218 HRESULT hr = pDevice9If->SetDepthStencilSurface(pD3D9Surf); 5184 5219 Assert(hr == S_OK); 5185 5220 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 5198 5233 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 5199 5234 Assert(pDevice); 5200 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5201 Assert(pScreen->hWnd); 5202 Assert(pScreen->pDevice9If); 5203 HRESULT hr = pScreen->pDevice9If->SetPixelShaderConstantI(pData->Register, pRegisters, pData->Count); 5235 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5236 HRESULT hr = pDevice9If->SetPixelShaderConstantI(pData->Register, pRegisters, pData->Count); 5204 5237 Assert(hr == S_OK); 5205 5238 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 5211 5244 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 5212 5245 Assert(pDevice); 5213 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5214 Assert(pScreen->hWnd); 5215 Assert(pScreen->pDevice9If); 5216 HRESULT hr = pScreen->pDevice9If->SetPixelShaderConstantB(pData->Register, pRegisters, pData->Count); 5246 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5247 HRESULT hr = pDevice9If->SetPixelShaderConstantB(pData->Register, pRegisters, pData->Count); 5217 5248 Assert(hr == S_OK); 5218 5249 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 5224 5255 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 5225 5256 Assert(pDevice); 5226 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5227 Assert(pScreen->hWnd); 5228 Assert(pScreen->pDevice9If); 5257 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5229 5258 IDirect3DPixelShader9 *pShader; 5230 5259 Assert(*((UINT*)((uint8_t*)pCode + pData->CodeSize-4)) == 0x0000FFFF /* end token */); 5231 HRESULT hr = p Screen->pDevice9If->CreatePixelShader((const DWORD *)pCode, &pShader);5260 HRESULT hr = pDevice9If->CreatePixelShader((const DWORD *)pCode, &pShader); 5232 5261 Assert(hr == S_OK); 5233 5262 if (hr == S_OK) … … 5244 5273 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 5245 5274 Assert(pDevice); 5246 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen];5247 Assert(pScreen->hWnd);5248 Assert(pScreen->pDevice9If);5249 5275 IDirect3DPixelShader9 *pShader = (IDirect3DPixelShader9*)hShaderHandle; 5250 5276 HRESULT hr = S_OK; … … 5718 5744 if (pRc->RcDesc.fFlags.Texture) 5719 5745 { 5720 PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen]; 5721 Assert(pScreen->hWnd); 5722 Assert(pScreen->pDevice9If); 5746 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5723 5747 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 5724 5748 IDirect3DTexture9 *pD3DIfTex; … … 5726 5750 Assert(pAllocation->hSharedHandle); 5727 5751 5728 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)p Screen->pDevice9If,5752 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If, 5729 5753 pAllocation->SurfDesc.width, 5730 5754 pAllocation->SurfDesc.height, … … 5952 5976 D3DPRESENT_PARAMETERS params; 5953 5977 memset(¶ms, 0, sizeof (params)); 5954 params.BackBufferWidth = 0x500; 5955 params.BackBufferHeight = 0x400; 5978 // params.BackBufferWidth = 640; 5979 // params.BackBufferHeight = 480; 5980 params.BackBufferWidth = 0x400; 5981 params.BackBufferHeight = 0x300; 5956 5982 params.BackBufferFormat = D3DFMT_A8R8G8B8; 5983 // params.BackBufferCount = 0; 5957 5984 params.BackBufferCount = 1; 5958 5985 params.MultiSampleType = D3DMULTISAMPLE_NONE; … … 6326 6353 { 6327 6354 case 0x40010006: /* <- OutputDebugString exception, ignore */ 6355 case 0xe06d7363: /* <- ms compiler - generated exception related to C++ exception */ 6328 6356 break; 6329 6357 default: -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h
r32281 r32325 196 196 197 197 #define VBOXDISPMODE_IS_3D(_p) (!!((_p)->pD3D9If)) 198 #ifdef VBOXDISP_EARLYCREATEDEVICE 199 #define VBOXDISP_D3DEV(_p) (_p)->pDevice9If 200 #else 201 #define VBOXDISP_D3DEV(_p) vboxWddmD3DDeviceGetPrimary(_p) 202 #endif 198 203 199 204 #endif /* #ifndef ___VBoxDispD3D_h___ */ -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h
r32281 r32325 40 40 # define VBOXWDDMDISP_DEBUG_DUMPSURFDATA 41 41 #endif 42 43 //#define VBOXDISP_EARLYCREATEDEVICE44 42 45 43 #if 0 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r32281 r32325 4465 4465 Assert(pCreateContext->PrivateDriverDataSize == 0); 4466 4466 Assert(!pCreateContext->pPrivateDriverData); 4467 Assert(pCreateContext->Flags.Value == 1 || pCreateContext->Flags.Value == 0);4467 Assert(pCreateContext->Flags.Value <= 2); /* 2 is a GDI context in Win7 */ 4468 4468 pContext->enmType = VBOXWDDM_CONTEXT_TYPE_SYSTEM; 4469 4469 }
Note:
See TracChangeset
for help on using the changeset viewer.