Changeset 33836 in vbox
- Timestamp:
- Nov 8, 2010 1:01:19 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r33714 r33836 108 108 # include <stdio.h> 109 109 #endif 110 111 #define VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc) (((pRc)->cAllocations)/6) 112 #define VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, idx) ((D3DCUBEMAP_FACES)(D3DCUBEMAP_FACE_POSITIVE_X+(idx)/VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc))) 113 #define VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, idx) ((idx)%VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc)) 110 114 111 115 #define VBOXDISP_WITH_WINE_BB_WORKAROUND … … 1618 1622 Assert(pD3DIfTex); 1619 1623 hr = pD3DIfTex->GetSurfaceLevel(iAlloc, &pSurfaceLevel); 1624 Assert(hr == S_OK); 1625 if (hr == S_OK) 1626 { 1627 *ppSurf = pSurfaceLevel; 1628 } 1629 break; 1630 } 1631 case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE: 1632 { 1633 Assert(0); 1634 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf; 1635 IDirect3DSurface9 *pSurfaceLevel; 1636 Assert(pD3DIfCubeTex); 1637 hr = pD3DIfCubeTex->GetCubeMapSurface(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc), 1638 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc), &pSurfaceLevel); 1620 1639 Assert(hr == S_OK); 1621 1640 if (hr == S_OK) … … 3410 3429 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)hTexture; 3411 3430 // Assert(pRc); 3412 IDirect3D Texture9 *pD3DIfTex;3431 IDirect3DBaseTexture9 *pD3DIfTex; 3413 3432 if (pRc) 3414 3433 { 3415 Assert(pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE); 3416 pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf; 3434 if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE) 3435 { 3436 pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf; 3417 3437 #ifdef DEBUG_misha 3418 bool bDo = false;3419 3420 if (bDo)3421 {3438 bool bDo = false; 3439 3440 if (bDo) 3441 { 3422 3442 vboxVDbgDumpSurfData((pDevice, "SetTexture:\n", pRc, 0 /* alloc index*/, NULL, NULL, "\n")); 3423 } 3424 #endif 3443 } 3444 #endif 3445 } 3446 else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_CUBE_TEXTURE) 3447 { 3448 pD3DIfTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf; 3449 } 3450 else 3451 { 3452 Assert(0); 3453 } 3425 3454 } 3426 3455 else 3427 3456 pD3DIfTex = NULL; 3428 3457 3429 // Assert(pD3DIfTex);3430 3458 HRESULT hr = pDevice9If->SetTexture(Stage, pD3DIfTex); 3431 3459 Assert(hr == S_OK); … … 4113 4141 && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height) 4114 4142 { 4115 IDirect3DTexture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcRc->aAllocations[0].pD3DIf; 4116 IDirect3DTexture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstRc->aAllocations[0].pD3DIf; 4143 Assert(pSrcRc->aAllocations[0].enmD3DIfType==VBOXDISP_D3DIFTYPE_TEXTURE 4144 || pSrcRc->aAllocations[0].enmD3DIfType==VBOXDISP_D3DIFTYPE_CUBE_TEXTURE); 4145 Assert(pDstRc->aAllocations[0].enmD3DIfType==VBOXDISP_D3DIFTYPE_TEXTURE 4146 || pDstRc->aAllocations[0].enmD3DIfType==VBOXDISP_D3DIFTYPE_CUBE_TEXTURE); 4147 IDirect3DBaseTexture9 *pD3DIfSrcTex = (IDirect3DBaseTexture9*)pSrcRc->aAllocations[0].pD3DIf; 4148 IDirect3DBaseTexture9 *pD3DIfDstTex = (IDirect3DBaseTexture9*)pDstRc->aAllocations[0].pD3DIf; 4117 4149 Assert(pD3DIfSrcTex); 4118 4150 Assert(pD3DIfDstTex); … … 4418 4450 // Assert(pRc != pScreen->pRenderTargetRc || pScreen->iRenderTargetFrontBuf != pData->SubResourceIndex); 4419 4451 4420 if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE) 4452 if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE 4453 || pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_CUBE_TEXTURE) 4421 4454 { 4422 4455 PVBOXWDDMDISP_ALLOCATION pTexAlloc = &pRc->aAllocations[0]; … … 4424 4457 PVBOXWDDMDISP_ALLOCATION pLockAlloc = &pRc->aAllocations[pData->SubResourceIndex]; 4425 4458 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pTexAlloc->pD3DIf; 4426 Assert(pD3DIfTex); 4459 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pTexAlloc->pD3DIf; 4460 Assert(pTexAlloc->pD3DIf); 4427 4461 RECT *pRect = NULL; 4428 4462 bool bNeedResynch = false; … … 4439 4473 if (!pLockAlloc->LockInfo.cLocks) 4440 4474 { 4441 hr = pD3DIfTex->LockRect(pData->SubResourceIndex, 4442 &pLockAlloc->LockInfo.LockedRect, 4443 pRect, 4444 vboxDDI2D3DLockFlags(pData->Flags)); 4475 if (pTexAlloc->enmD3DIfType==VBOXDISP_D3DIFTYPE_TEXTURE) 4476 { 4477 hr = pD3DIfTex->LockRect(pData->SubResourceIndex, 4478 &pLockAlloc->LockInfo.LockedRect, 4479 pRect, 4480 vboxDDI2D3DLockFlags(pData->Flags)); 4481 } 4482 else /*VBOXDISP_D3DIFTYPE_CUBE_TEXTURE*/ 4483 { 4484 hr = pD3DIfCubeTex->LockRect(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, pData->SubResourceIndex), 4485 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, pData->SubResourceIndex), 4486 &pLockAlloc->LockInfo.LockedRect, 4487 pRect, 4488 vboxDDI2D3DLockFlags(pData->Flags)); 4489 } 4445 4490 Assert(hr == S_OK); 4446 4491 if (hr == S_OK) … … 4488 4533 (pLockAlloc->LockInfo.fFlags.ReadOnly && !pData->Flags.ReadOnly)) 4489 4534 { 4490 hr = pD3DIfTex->UnlockRect(pData->SubResourceIndex); 4535 if (pTexAlloc->enmD3DIfType==VBOXDISP_D3DIFTYPE_TEXTURE) 4536 { 4537 hr = pD3DIfTex->UnlockRect(pData->SubResourceIndex); 4538 } 4539 else /*VBOXDISP_D3DIFTYPE_CUBE_TEXTURE*/ 4540 { 4541 hr = pD3DIfCubeTex->UnlockRect(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, pData->SubResourceIndex), 4542 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, pData->SubResourceIndex)); 4543 } 4491 4544 Assert(hr == S_OK); 4492 4545 if (hr == S_OK) 4493 4546 { 4494 hr = pD3DIfTex->LockRect(pData->SubResourceIndex, 4495 &pLockAlloc->LockInfo.LockedRect, 4496 pRect, 4497 vboxDDI2D3DLockFlags(pData->Flags)); 4547 if (pTexAlloc->enmD3DIfType==VBOXDISP_D3DIFTYPE_TEXTURE) 4548 { 4549 hr = pD3DIfTex->LockRect(pData->SubResourceIndex, 4550 &pLockAlloc->LockInfo.LockedRect, 4551 pRect, 4552 vboxDDI2D3DLockFlags(pData->Flags)); 4553 } 4554 else /*VBOXDISP_D3DIFTYPE_CUBE_TEXTURE*/ 4555 { 4556 hr = pD3DIfCubeTex->LockRect(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, pData->SubResourceIndex), 4557 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, pData->SubResourceIndex), 4558 &pLockAlloc->LockInfo.LockedRect, 4559 pRect, 4560 vboxDDI2D3DLockFlags(pData->Flags)); 4561 } 4498 4562 Assert(hr == S_OK); 4499 4563 pLockAlloc->LockInfo.fFlags.ReadOnly = 0; … … 4811 4875 if (VBOXDISPMODE_IS_3D(pDevice->pAdapter)) 4812 4876 { 4813 if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE) 4877 if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE 4878 || pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_CUBE_TEXTURE) 4814 4879 { 4815 4880 Assert(pData->SubResourceIndex < pRc->cAllocations); … … 4823 4888 PVBOXWDDMDISP_ALLOCATION pTexAlloc = &pRc->aAllocations[0]; 4824 4889 // Assert(!pLockAlloc->LockInfo.cLocks); 4825 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pTexAlloc->pD3DIf; 4826 Assert(pD3DIfTex); 4890 Assert(pTexAlloc->pD3DIf); 4827 4891 /* this is a sysmem texture, update */ 4828 4892 #if 0 … … 4834 4898 } 4835 4899 #endif 4836 hr = pD3DIfTex->UnlockRect(pData->SubResourceIndex); 4900 if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE) 4901 { 4902 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pTexAlloc->pD3DIf; 4903 hr = pD3DIfTex->UnlockRect(pData->SubResourceIndex); 4904 } 4905 else 4906 { 4907 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pTexAlloc->pD3DIf; 4908 hr = pD3DIfCubeTex->UnlockRect(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, pData->SubResourceIndex), 4909 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, pData->SubResourceIndex)); 4910 } 4837 4911 Assert(hr == S_OK); 4838 4912 } … … 5229 5303 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5230 5304 5305 if (!pResource->Flags.CubeMap) 5306 { 5231 5307 #ifdef DEBUG 5232 {5233 uint32_t tstW = pResource->pSurfList[0].Width;5234 uint32_t tstH = pResource->pSurfList[0].Height;5235 for (UINT i = 1; i < pResource->SurfCount; ++i)5236 5308 { 5237 tstW /= 2; 5238 tstH /= 2; 5239 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 5240 Assert((pSurf->Width == tstW) || (!tstW && (pSurf->Width==1))); 5241 Assert((pSurf->Height == tstH) || (!tstH && (pSurf->Height==1))); 5309 uint32_t tstW = pResource->pSurfList[0].Width; 5310 uint32_t tstH = pResource->pSurfList[0].Height; 5311 for (UINT i = 1; i < pResource->SurfCount; ++i) 5312 { 5313 tstW /= 2; 5314 tstH /= 2; 5315 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 5316 Assert((pSurf->Width == tstW) || (!tstW && (pSurf->Width==1))); 5317 Assert((pSurf->Height == tstH) || (!tstH && (pSurf->Height==1))); 5318 } 5242 5319 } 5243 }5244 5320 #endif 5245 5321 … … 5247 5323 // bIssueCreateResource = true; 5248 5324 5249 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 5250 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[0]; 5251 IDirect3DTexture9 *pD3DIfTex; 5252 HANDLE hSharedHandle = NULL; 5253 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5254 { 5255 Assert(pSurf->pSysMem); 5256 Assert(pSurf->SysMemPitch); 5257 UINT bpp = vboxWddmCalcBitsPerPixel(pResource->Format); 5258 Assert(bpp); 5259 if (bpp) 5325 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 5326 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[0]; 5327 IDirect3DTexture9 *pD3DIfTex; 5328 HANDLE hSharedHandle = NULL; 5329 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5260 5330 { 5261 pAllocation->D3DWidth = ((pSurf->SysMemPitch << 3) / bpp); 5262 if ((pSurf->SysMemPitch << 3) % bpp) 5331 Assert(pSurf->pSysMem); 5332 Assert(pSurf->SysMemPitch); 5333 UINT bpp = vboxWddmCalcBitsPerPixel(pResource->Format); 5334 Assert(bpp); 5335 if (bpp) 5263 5336 { 5264 Assert(0); 5265 ++pAllocation->D3DWidth; 5337 pAllocation->D3DWidth = ((pSurf->SysMemPitch << 3) / bpp); 5338 if ((pSurf->SysMemPitch << 3) % bpp) 5339 { 5340 Assert(0); 5341 ++pAllocation->D3DWidth; 5342 } 5343 Assert(pAllocation->D3DWidth >= pSurf->Width); 5266 5344 } 5267 Assert(pAllocation->D3DWidth >= pSurf->Width);5268 5345 } 5269 }5270 5346 #if 0 5271 hr = pDevice9If->CreateTexture(pSurf->Width,5272 pAllocation->D3DWidth,5273 pResource->SurfCount,5274 vboxDDI2D3DUsage(pResource->Flags),5275 vboxDDI2D3DFormat(pResource->Format),5276 vboxDDI2D3DPool(pResource->Pool),5277 &pD3DIfTex,5278 NULL /* HANDLE* pSharedHandle */5279 );5347 hr = pDevice9If->CreateTexture(pSurf->Width, 5348 pAllocation->D3DWidth, 5349 pResource->SurfCount, 5350 vboxDDI2D3DUsage(pResource->Flags), 5351 vboxDDI2D3DFormat(pResource->Format), 5352 vboxDDI2D3DPool(pResource->Pool), 5353 &pD3DIfTex, 5354 NULL /* HANDLE* pSharedHandle */ 5355 ); 5280 5356 #else 5281 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If,5282 pAllocation->D3DWidth,5283 pSurf->Height,5284 pResource->SurfCount,5285 vboxDDI2D3DUsage(pResource->Flags),5286 vboxDDI2D3DFormat(pResource->Format),5287 vboxDDI2D3DPool(pResource->Pool),5288 &pD3DIfTex,5289 pResource->Flags.SharedResource ? &hSharedHandle : NULL,5290 pResource->Pool == D3DDDIPOOL_SYSTEMMEM ? pRc->aAllocations[0].pvMem : NULL);5291 #endif 5292 Assert(hr == S_OK);5293 if (hr == S_OK)5294 {5295 Assert(pD3DIfTex);5296 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE;5297 pAllocation->pD3DIf = pD3DIfTex;5298 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle));5299 pAllocation->hSharedHandle = hSharedHandle;5357 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If, 5358 pAllocation->D3DWidth, 5359 pSurf->Height, 5360 pResource->SurfCount, 5361 vboxDDI2D3DUsage(pResource->Flags), 5362 vboxDDI2D3DFormat(pResource->Format), 5363 vboxDDI2D3DPool(pResource->Pool), 5364 &pD3DIfTex, 5365 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5366 pResource->Pool == D3DDDIPOOL_SYSTEMMEM ? pRc->aAllocations[0].pvMem : NULL); 5367 #endif 5368 Assert(hr == S_OK); 5369 if (hr == S_OK) 5370 { 5371 Assert(pD3DIfTex); 5372 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE; 5373 pAllocation->pD3DIf = pD3DIfTex; 5374 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5375 pAllocation->hSharedHandle = hSharedHandle; 5300 5376 #if 0 5301 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5377 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5378 { 5379 for (UINT i = 0; i < pResource->SurfCount; ++i) 5380 { 5381 D3DLOCKED_RECT lockInfo; 5382 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 5383 Assert(pAllocation->pvMem); 5384 hr = pD3DIfTex->LockRect(i, &lockInfo, NULL, D3DLOCK_DISCARD); 5385 Assert(hr == S_OK); 5386 if (hr == S_OK) 5387 { 5388 vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/); 5389 HRESULT tmpHr = pD3DIfTex->UnlockRect(i); 5390 Assert(tmpHr == S_OK); 5391 } 5392 else 5393 { 5394 pD3DIfTex->Release(); 5395 break; 5396 } 5397 } 5398 } 5399 #endif 5400 } 5401 #ifdef DEBUG 5402 else 5302 5403 { 5303 5404 for (UINT i = 0; i < pResource->SurfCount; ++i) 5304 5405 { 5305 D3DLOCKED_RECT lockInfo;5306 5406 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 5307 Assert(pAllocation->pvMem); 5308 hr = pD3DIfTex->LockRect(i, &lockInfo, NULL, D3DLOCK_DISCARD); 5309 Assert(hr == S_OK); 5310 if (hr == S_OK) 5311 { 5312 vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/); 5313 HRESULT tmpHr = pD3DIfTex->UnlockRect(i); 5314 Assert(tmpHr == S_OK); 5315 } 5316 else 5317 { 5318 pD3DIfTex->Release(); 5319 break; 5320 } 5407 Assert(!pAllocation->pvMem); 5321 5408 } 5322 5409 } 5323 5410 #endif 5324 5411 } 5325 #ifdef DEBUG 5326 else 5327 { 5328 for (UINT i = 0; i < pResource->SurfCount; ++i) 5412 else /*pResource->Flags.CubeMap*/ 5413 { 5414 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5415 5416 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 5417 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[0]; 5418 IDirect3DCubeTexture9 *pD3DIfCubeTex; 5419 HANDLE hSharedHandle = NULL; 5420 5421 if ( (pAllocation->SurfDesc.width!=pAllocation->SurfDesc.height) 5422 || (pResource->SurfCount%6!=0)) 5329 5423 { 5330 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 5331 Assert(!pAllocation->pvMem); 5424 Assert(0); 5425 hr = E_INVALIDARG; 5426 } 5427 else 5428 { 5429 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateCubeTexture((IDirect3DDevice9Ex *)pDevice9If, 5430 pAllocation->SurfDesc.width, 5431 VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc), 5432 vboxDDI2D3DUsage(pResource->Flags), 5433 vboxDDI2D3DFormat(pResource->Format), 5434 vboxDDI2D3DPool(pResource->Pool), 5435 &pD3DIfCubeTex, 5436 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5437 pResource->Pool == D3DDDIPOOL_SYSTEMMEM ? pRc->aAllocations[0].pvMem : NULL); 5438 } 5439 5440 Assert(hr == S_OK); 5441 if (hr == S_OK) 5442 { 5443 Assert(pD3DIfCubeTex); 5444 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_CUBE_TEXTURE; 5445 pAllocation->pD3DIf = pD3DIfCubeTex; 5446 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5447 pAllocation->hSharedHandle = hSharedHandle; 5332 5448 } 5333 5449 } 5334 #endif5335 5450 } 5336 5451 else if (pResource->Flags.RenderTarget) … … 6301 6416 break; 6302 6417 } 6418 case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE: 6419 { 6420 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf; 6421 Assert(pD3DIfCubeTex); 6422 hr = pD3DIfCubeTex->LockRect(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc), 6423 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc), pLockedRect, pRect, fLockFlags); 6424 Assert(hr == S_OK); 6425 break; 6426 } 6303 6427 default: 6304 6428 Assert(0); … … 6307 6431 return hr; 6308 6432 } 6433 6309 6434 static HRESULT vboxWddmUnlockRect(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc) 6310 6435 { … … 6326 6451 Assert(pD3DIfTex); 6327 6452 hr = pD3DIfTex->UnlockRect(iAlloc); 6453 Assert(hr == S_OK); 6454 break; 6455 } 6456 case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE: 6457 { 6458 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf; 6459 Assert(pD3DIfCubeTex); 6460 hr = pD3DIfCubeTex->UnlockRect(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc), 6461 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc)); 6328 6462 Assert(hr == S_OK); 6329 6463 break; … … 6509 6643 && (pSrcRc->RcDesc.fFlags.Texture || pSrcRc->RcDesc.fFlags.Value == 0)) 6510 6644 { 6511 IDirect3D Texture9 *pD3DIfSrcTex = (IDirect3DTexture9*)pSrcAlloc->pD3DIf;6512 IDirect3D Texture9 *pD3DIfDstTex = (IDirect3DTexture9*)pDstAlloc->pD3DIf;6645 IDirect3DBaseTexture9 *pD3DIfSrcTex = (IDirect3DBaseTexture9*)pSrcAlloc->pD3DIf; 6646 IDirect3DBaseTexture9 *pD3DIfDstTex = (IDirect3DBaseTexture9*)pDstAlloc->pD3DIf; 6513 6647 Assert(pD3DIfSrcTex); 6514 6648 Assert(pD3DIfDstTex); … … 7424 7558 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 7425 7559 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 7426 IDirect3DTexture9 *pD3DIfTex;7427 7560 HANDLE hSharedHandle = pAllocation->hSharedHandle; 7428 7561 Assert(pAllocation->hSharedHandle); 7429 7562 7430 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If, 7431 pAllocation->SurfDesc.width, 7432 pAllocation->SurfDesc.height, 7433 pRc->cAllocations, 7434 vboxDDI2D3DUsage(pRc->RcDesc.fFlags), 7435 vboxDDI2D3DFormat(pRc->RcDesc.enmFormat), 7436 vboxDDI2D3DPool(pRc->RcDesc.enmPool), 7437 &pD3DIfTex, 7438 &hSharedHandle, 7439 NULL); 7440 Assert(hr == S_OK); 7441 if (hr == S_OK) 7563 if (!pRc->RcDesc.fFlags.CubeMap) 7442 7564 { 7443 Assert(pD3DIfTex); 7444 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE; 7445 pAllocation->pD3DIf = pD3DIfTex; 7446 Assert(pAllocation->hSharedHandle == hSharedHandle); 7447 Assert(pAllocation->hSharedHandle); 7565 IDirect3DTexture9 *pD3DIfTex; 7566 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If, 7567 pAllocation->SurfDesc.width, 7568 pAllocation->SurfDesc.height, 7569 pRc->cAllocations, 7570 vboxDDI2D3DUsage(pRc->RcDesc.fFlags), 7571 vboxDDI2D3DFormat(pRc->RcDesc.enmFormat), 7572 vboxDDI2D3DPool(pRc->RcDesc.enmPool), 7573 &pD3DIfTex, 7574 &hSharedHandle, 7575 NULL); 7576 Assert(hr == S_OK); 7577 if (hr == S_OK) 7578 { 7579 Assert(pD3DIfTex); 7580 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE; 7581 pAllocation->pD3DIf = pD3DIfTex; 7582 Assert(pAllocation->hSharedHandle == hSharedHandle); 7583 Assert(pAllocation->hSharedHandle); 7584 } 7585 } 7586 else 7587 { 7588 IDirect3DCubeTexture9 *pD3DIfCubeTex; 7589 7590 if ( (pAllocation->SurfDesc.width!=pAllocation->SurfDesc.height) 7591 || (pRc->cAllocations%6!=0)) 7592 { 7593 Assert(0); 7594 hr = E_INVALIDARG; 7595 } 7596 7597 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateCubeTexture((IDirect3DDevice9Ex *)pDevice9If, 7598 pAllocation->SurfDesc.width, 7599 VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc), 7600 vboxDDI2D3DUsage(pRc->RcDesc.fFlags), 7601 vboxDDI2D3DFormat(pRc->RcDesc.enmFormat), 7602 vboxDDI2D3DPool(pRc->RcDesc.enmPool), 7603 &pD3DIfCubeTex, 7604 &hSharedHandle, 7605 NULL); 7606 Assert(hr == S_OK); 7607 if (hr == S_OK) 7608 { 7609 Assert(pD3DIfCubeTex); 7610 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_CUBE_TEXTURE; 7611 pAllocation->pD3DIf = pD3DIfCubeTex; 7612 Assert(pAllocation->hSharedHandle == hSharedHandle); 7613 Assert(pAllocation->hSharedHandle); 7614 } 7615 7448 7616 } 7449 7617 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h
r33306 r33836 208 208 VBOXDISP_D3DIFTYPE_SURFACE, 209 209 VBOXDISP_D3DIFTYPE_TEXTURE, 210 VBOXDISP_D3DIFTYPE_CUBE_TEXTURE, 210 211 VBOXDISP_D3DIFTYPE_VERTEXBUFFER, 211 212 VBOXDISP_D3DIFTYPE_INDEXBUFFER -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.cpp
r33540 r33836 39 39 if (pD3D->pfnVBoxWineExD3DDev9CreateTexture) 40 40 { 41 pD3D->pfnVBoxWineExD3DDev9 Flush = (PFNVBOXWINEEXD3DDEV9_FLUSH)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9Flush");42 Assert(pD3D->pfnVBoxWineExD3DDev9 Flush);43 if (pD3D->pfnVBoxWineExD3DDev9 Flush)41 pD3D->pfnVBoxWineExD3DDev9CreateCubeTexture = (PFNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9CreateCubeTexture"); 42 Assert(pD3D->pfnVBoxWineExD3DDev9CreateCubeTexture); 43 if (pD3D->pfnVBoxWineExD3DDev9CreateCubeTexture) 44 44 { 45 pD3D->pfnVBoxWineExD3DDev9 Update = (PFNVBOXWINEEXD3DDEV9_UPDATE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9Update");46 Assert(pD3D->pfnVBoxWineExD3DDev9 Update);47 if (pD3D->pfnVBoxWineExD3DDev9 Update)45 pD3D->pfnVBoxWineExD3DDev9Flush = (PFNVBOXWINEEXD3DDEV9_FLUSH)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9Flush"); 46 Assert(pD3D->pfnVBoxWineExD3DDev9Flush); 47 if (pD3D->pfnVBoxWineExD3DDev9Flush) 48 48 { 49 return S_OK; 49 pD3D->pfnVBoxWineExD3DDev9Update = (PFNVBOXWINEEXD3DDEV9_UPDATE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9Update"); 50 Assert(pD3D->pfnVBoxWineExD3DDev9Update); 51 if (pD3D->pfnVBoxWineExD3DDev9Update) 52 { 53 return S_OK; 54 } 50 55 } 51 56 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DIf.h
r32281 r33836 34 34 35 35 PFNVBOXWINEEXD3DDEV9_CREATETEXTURE pfnVBoxWineExD3DDev9CreateTexture; 36 37 PFNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE pfnVBoxWineExD3DDev9CreateCubeTexture; 36 38 37 39 PFNVBOXWINEEXD3DDEV9_FLUSH pfnVBoxWineExD3DDev9Flush; -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/cubetexture.c
r33656 r33836 401 401 402 402 HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Impl *device, 403 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) 403 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool 404 #ifdef VBOX_WITH_WDDM 405 , HANDLE *shared_handle 406 , void *pvClientMem 407 #endif 408 ) 404 409 { 405 410 HRESULT hr; … … 409 414 410 415 wined3d_mutex_lock(); 416 #ifdef VBOX_WITH_WDDM 417 hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage, 418 wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture, 419 (IUnknown *)texture, &d3d9_cubetexture_wined3d_parent_ops, 420 shared_handle, pvClientMem); 421 #else 411 422 hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage, 412 423 wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture, 413 424 (IUnknown *)texture, &d3d9_cubetexture_wined3d_parent_ops); 425 #endif 414 426 wined3d_mutex_unlock(); 415 427 if (FAILED(hr)) -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9_private.h
r33656 r33836 414 414 415 415 HRESULT cubetexture_init(IDirect3DCubeTexture9Impl *texture, IDirect3DDevice9Impl *device, 416 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN; 416 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool 417 #ifdef VBOX_WITH_WDDM 418 , HANDLE *shared_handle 419 , void *pvClientMem 420 #endif 421 ) DECLSPEC_HIDDEN; 417 422 418 423 /* ----------------- */ -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9wddm.def
r32305 r33836 1 ; File generated automatically from ../../../dlls/d3d9/d3d9.spec; do not edit!2 3 1 LIBRARY VBoxD3D9wddm.dll 4 2 … … 17 15 VBoxWineExD3DDev9Flush 18 16 VBoxWineExD3DDev9CreateTexture 17 VBoxWineExD3DDev9CreateCubeTexture 19 18 VBoxWineExD3DDev9Update -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c
r33656 r33836 809 809 } 810 810 811 VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9CreateCubeTexture(IDirect3DDevice9Ex *iface, 812 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, 813 D3DPOOL pool, IDirect3DCubeTexture9 **texture, HANDLE *shared_handle, 814 void *pvClientMem) /* <- extension arg to pass in the client memory buffer, 815 * applicable ONLY for SYSMEM textures */ 816 { 817 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; 818 IDirect3DCubeTexture9Impl *object; 819 HRESULT hr; 820 821 TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n", 822 iface, edge_length, levels, usage, format, pool, texture, shared_handle); 823 824 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 825 if (!object) 826 { 827 ERR("Failed to allocate cube texture memory.\n"); 828 return D3DERR_OUTOFVIDEOMEMORY; 829 } 830 831 hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool, shared_handle, pvClientMem); 832 if (FAILED(hr)) 833 { 834 WARN("Failed to initialize cube texture, hr %#x.\n", hr); 835 HeapFree(GetProcessHeap(), 0, object); 836 return hr; 837 } 838 839 TRACE("Created cube texture %p.\n", object); 840 *texture = (IDirect3DCubeTexture9 *)object; 841 842 return D3D_OK; 843 } 844 811 845 #endif 812 846 … … 886 920 IDirect3DCubeTexture9 **texture, HANDLE *shared_handle) 887 921 { 922 #ifdef VBOX_WITH_WDDM 923 return VBoxWineExD3DDev9CreateCubeTexture(iface, edge_length, levels, usage, format, 924 pool, texture, shared_handle, NULL); 925 #else 888 926 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; 889 927 IDirect3DCubeTexture9Impl *object; … … 912 950 913 951 return D3D_OK; 952 #endif 914 953 } 915 954 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h
r32622 r33836 7446 7446 IWineD3DCubeTexture **texture, 7447 7447 IUnknown *parent, 7448 const struct wined3d_parent_ops *parent_ops); 7448 const struct wined3d_parent_ops *parent_ops 7449 #ifdef VBOX_WITH_WDDM 7450 , HANDLE *shared_handle 7451 , void *pvClientMem 7452 #endif 7453 ); 7449 7454 7450 7455 HRESULT (STDMETHODCALLTYPE *CreateQuery)( … … 8116 8121 #define IWineD3DDevice_CreateVolumeTexture(This,width,height,depth,levels,usage,format,pool,texture,parent,parent_ops) (This)->lpVtbl->CreateVolumeTexture(This,width,height,depth,levels,usage,format,pool,texture,parent,parent_ops) 8117 8122 #define IWineD3DDevice_CreateVolume(This,width,height,depth,usage,format,pool,volume,parent,parent_ops) (This)->lpVtbl->CreateVolume(This,width,height,depth,usage,format,pool,volume,parent,parent_ops) 8123 #ifdef VBOX_WITH_WDDM 8124 #define IWineD3DDevice_CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pvClientMem) (This)->lpVtbl->CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pvClientMem) 8125 #else 8118 8126 #define IWineD3DDevice_CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops) (This)->lpVtbl->CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops) 8127 #endif 8119 8128 #define IWineD3DDevice_CreateQuery(This,type,query,parent) (This)->lpVtbl->CreateQuery(This,type,query,parent) 8120 8129 #define IWineD3DDevice_CreateSwapChain(This,present_parameters,swapchain,parent,surface_type) (This)->lpVtbl->CreateSwapChain(This,present_parameters,swapchain,parent,surface_type) -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/VBoxWineEx.h
r32281 r33836 28 28 typedef FNVBOXWINEEXD3DDEV9_CREATETEXTURE *PFNVBOXWINEEXD3DDEV9_CREATETEXTURE; 29 29 30 typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE(IDirect3DDevice9Ex *iface, 31 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, 32 D3DPOOL pool, IDirect3DCubeTexture9 **texture, HANDLE *shared_handle, 33 void *pvClientMem); 34 typedef FNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE *PFNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE; 35 30 36 typedef VBOXWINEEX_DECL(HRESULT) FNVBOXWINEEXD3DDEV9_FLUSH(IDirect3DDevice9Ex *iface); 31 37 typedef FNVBOXWINEEXD3DDEV9_FLUSH *PFNVBOXWINEEXD3DDEV9_FLUSH; … … 44 50 * applicable ONLY for SYSMEM textures */ 45 51 52 VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9CreateCubeTexture(IDirect3DDevice9Ex *iface, 53 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, 54 D3DPOOL pool, IDirect3DCubeTexture9 **texture, HANDLE *shared_handle, 55 void *pvClientMem); /* <- extension arg to pass in the client memory buffer, 56 * applicable ONLY for SYSMEM textures */ 57 46 58 VBOXWINEEX_DECL(HRESULT) VBoxWineExD3DDev9Flush(IDirect3DDevice9Ex *iface); /* perform glFlush */ 47 59 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c
r33656 r33836 440 440 HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels, 441 441 IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, 442 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) 442 IUnknown *parent, const struct wined3d_parent_ops *parent_ops 443 #ifdef VBOX_WITH_WDDM 444 , HANDLE *shared_handle 445 , void *pvClientMem 446 #endif 447 ) 443 448 { 444 449 const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; … … 491 496 device, 0, usage, format_desc, pool, parent, parent_ops 492 497 #ifdef VBOX_WITH_WDDM 493 , NULL 494 , NULL 498 , shared_handle, pvClientMem 495 499 #endif 496 500 ); … … 543 547 hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w, 544 548 format, usage, pool, i /* Level */, j, &texture->surfaces[j][i] 545 , NULL, NULL /* <- no need this info here */549 , NULL, pvClientMem 546 550 ); 547 551 #else … … 566 570 texture->baseTexture.internal_preload = cubetexture_internal_preload; 567 571 572 #ifdef VBOX_WITH_WDDM 573 if (VBOXSHRC_IS_SHARED(texture)) 574 { 575 Assert(shared_handle); 576 VBOXSHRC_SET_INITIALIZED(texture); 577 for (i = 0; i < texture->baseTexture.levels; ++i) 578 { 579 for (j = 0; j < 6; ++j) 580 { 581 VBOXSHRC_COPY_SHAREDATA((IWineD3DSurfaceImpl*)texture->surfaces[j][i], texture); 582 } 583 } 584 #ifdef DEBUG 585 for (i = 0; i < texture->baseTexture.levels; ++i) 586 { 587 for (j = 0; j < 6; ++j) 588 { 589 Assert(!((IWineD3DSurfaceImpl*)texture->surfaces[j][i])->texture_name); 590 } 591 } 592 #endif 593 IWineD3DSurface_LoadLocation(texture->surfaces[0][0], SFLAG_INTEXTURE, NULL); 594 if (!VBOXSHRC_IS_SHARED_OPENED(texture)) 595 { 596 Assert(!(*shared_handle)); 597 *shared_handle = VBOXSHRC_GET_SHAREHANDLE(texture); 598 } 599 else 600 { 601 Assert(*shared_handle); 602 Assert(*shared_handle == VBOXSHRC_GET_SHAREHANDLE(texture)); 603 } 604 #ifdef DEBUG 605 for (i = 0; i < texture->baseTexture.levels; ++i) 606 { 607 for (j = 0; j < 6; ++j) 608 { 609 Assert((*shared_handle) == ((IWineD3DSurfaceImpl*)texture->surfaces[j][i])->texture_name); 610 } 611 } 612 #endif 613 } 614 else 615 { 616 Assert(!shared_handle); 617 } 618 #endif 619 568 620 return WINED3D_OK; 569 621 } -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c
r33656 r33836 991 991 static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength, UINT Levels, 992 992 DWORD Usage, WINED3DFORMAT Format, WINED3DPOOL Pool, IWineD3DCubeTexture **ppCubeTexture, 993 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) 993 IUnknown *parent, const struct wined3d_parent_ops *parent_ops 994 #ifdef VBOX_WITH_WDDM 995 , HANDLE *shared_handle 996 , void *pvClientMem 997 #endif 998 ) 994 999 { 995 1000 IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; … … 1005 1010 } 1006 1011 1007 hr = cubetexture_init(object, EdgeLength, Levels, This, Usage, Format, Pool, parent, parent_ops); 1012 hr = cubetexture_init(object, EdgeLength, Levels, This, Usage, Format, Pool, parent, parent_ops 1013 #ifdef VBOX_WITH_WDDM 1014 , shared_handle 1015 , pvClientMem 1016 #endif 1017 ); 1018 1008 1019 if (FAILED(hr)) 1009 1020 { -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h
r33656 r33836 1997 1997 HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels, 1998 1998 IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, 1999 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; 1999 IUnknown *parent, const struct wined3d_parent_ops *parent_ops 2000 #ifdef VBOX_WITH_WDDM 2001 , HANDLE *shared_handle 2002 , void *pvClientMem 2003 #endif 2004 ) DECLSPEC_HIDDEN; 2000 2005 2001 2006 typedef struct _WINED3DVOLUMET_DESC
Note:
See TracChangeset
for help on using the changeset viewer.