Changeset 35650 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- Jan 20, 2011 2:07:59 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 4 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk
r35501 r35650 98 98 wddm/VBoxScreen.cpp \ 99 99 wddm/VBoxDispMpTst.cpp \ 100 wddm/VBoxDispKmt.cpp \ 101 wddm/VBoxDispDbg.cpp \ 100 102 wddm/VBoxDispD3D.rc \ 101 103 wddm/VBoxDispD3D.def … … 132 134 VBoxCrHgsmi_SOURCES = \ 133 135 wddm/VBoxCrHgsmi.cpp \ 136 wddm/VBoxDispKmt.cpp \ 137 wddm/VBoxDispDbg.cpp \ 134 138 wddm/VBoxUhgsmiKmt.cpp 135 139 VBoxCrHgsmi_SDKS = WINDDKWLH -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxCrHgsmi.cpp
r35127 r35650 230 230 VBOXCRHGSMI_DECL(void) VBoxCrHgsmiLog(char * szString) 231 231 { 232 VBOXDISPKMT_ADAPTER Adapter; 233 HRESULT hr = vboxDispKmtOpenAdapter(&g_VBoxCrHgsmiKmtCallbacks, &Adapter); 234 Assert(hr == S_OK); 235 if (hr == S_OK) 236 { 237 uint32_t cbString = (uint32_t)strlen(szString) + 1; 238 uint32_t cbCmd = RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cbString]); 239 PVBOXDISPIFESCAPE_DBGPRINT pCmd = (PVBOXDISPIFESCAPE_DBGPRINT)RTMemAllocZ(cbCmd); 240 Assert(pCmd); 241 if (pCmd) 242 { 243 pCmd->EscapeHdr.escapeCode = VBOXESC_DBGPRINT; 244 memcpy(pCmd->aStringBuf, szString, cbString); 245 246 D3DKMT_ESCAPE EscapeData = {0}; 247 EscapeData.hAdapter = Adapter.hAdapter; 248 //EscapeData.hDevice = NULL; 249 EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; 250 // EscapeData.Flags.HardwareAccess = 1; 251 EscapeData.pPrivateDriverData = pCmd; 252 EscapeData.PrivateDriverDataSize = cbCmd; 253 //EscapeData.hContext = NULL; 254 255 int Status = g_VBoxCrHgsmiKmtCallbacks.pfnD3DKMTEscape(&EscapeData); 256 Assert(!Status); 257 258 RTMemFree(pCmd); 259 } 260 hr = vboxDispKmtCloseAdapter(&Adapter); 261 Assert(hr == S_OK); 262 } 263 } 264 265 ///* to be used by injection thread and by ogl ICD driver for hgsmi initialization*/ 266 //VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCustomCreate(PVBOXUHGSMI *ppHgsmi) 267 //{ 268 // PVBOXUHGSMI_PRIVATE_KMT pHgsmi = RTMemAllocZ(sizeof (*pHgsmi)); 269 // if (pHgsmi) 270 // { 271 // HRESULT hr = vboxUhgsmiKmtCreate(pHgsmi, FALSE); 272 // Assert(hr == S_OK); 273 // if (hr == S_OK) 274 // { 275 // *ppHgsmi = &pHgsmi->BasePrivate.Base; 276 // return VINF_SUCCESS; 277 // } 278 // RTMemFree(pHgsmi); 279 // return VERR_GENERAL_FAILURE; 280 // } 281 // return VERR_NO_MEMORY; 282 //} 283 // 284 //VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCustomDestroy(PVBOXUHGSMI pHgsmi) 285 //{ 286 // PVBOXUHGSMI_PRIVATE_KMT pHgsmiKmt = VBOXUHGSMIKMT_GET(pHgsmi); 287 // HRESULT hr = vboxUhgsmiKmtDestroy(pHgsmiKmt, FALSE); 288 // Assert(hr == S_OK); 289 // if (hr == S_OK) 290 // { 291 // RTMemFree(pHgsmiKmt); 292 // return VINF_SUCCESS; 293 // } 294 // return VERR_GENERAL_FAILURE; 295 //} 296 232 vboxVDbgPrint(("%s", szString)); 233 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r35319 r35650 70 70 double cps = g_VBoxDispFpsDDI.GetCps(); \ 71 71 double tup = g_VBoxDispFpsDDI.GetTimeProcPercent(); \ 72 VBOXDISPPROFILE_DUMP(( _pDev,"fps: %f, cps: %.1f, host %.1f%%\n", fps, cps, tup)); \72 VBOXDISPPROFILE_DUMP(("fps: %f, cps: %.1f, host %.1f%%\n", fps, cps, tup)); \ 73 73 } \ 74 74 } while (0) … … 104 104 HRESULT vboxDispMpTstStop(); 105 105 #endif 106 107 #ifdef VBOXWDDMDISP_DEBUG_PRINT108 # include <stdio.h>109 #endif110 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))114 106 115 107 #define VBOXDISP_WITH_WINE_BB_WORKAROUND … … 1596 1588 } 1597 1589 1598 /* on success increments the surface ref counter,1599 * i.e. one must call pSurf->Release() once the surface is not needed*/1600 static HRESULT vboxWddmSurfGet(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc, IDirect3DSurface9 **ppSurf)1601 {1602 HRESULT hr = S_OK;1603 Assert(pRc->cAllocations > iAlloc);1604 switch (pRc->aAllocations[0].enmD3DIfType)1605 {1606 case VBOXDISP_D3DIFTYPE_SURFACE:1607 {1608 IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pRc->aAllocations[iAlloc].pD3DIf;1609 Assert(pD3DIfSurf);1610 pD3DIfSurf->AddRef();1611 *ppSurf = pD3DIfSurf;1612 break;1613 }1614 case VBOXDISP_D3DIFTYPE_TEXTURE:1615 {1616 Assert(pRc->cAllocations == 1); /* <- vboxWddmSurfGet is typically used in Blt & ColorFill functions1617 * in this case, if texture is used as a destination,1618 * we should update sub-layers as well which is not done currently1619 * so for now check vboxWddmSurfGet is used for one-level textures */1620 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf;1621 IDirect3DSurface9 *pSurfaceLevel;1622 Assert(pD3DIfTex);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);1639 Assert(hr == S_OK);1640 if (hr == S_OK)1641 {1642 *ppSurf = pSurfaceLevel;1643 }1644 break;1645 }1646 default:1647 Assert(0);1648 hr = E_FAIL;1649 break;1650 }1651 return hr;1652 }1653 1590 1654 1591 /******/ … … 1825 1762 } 1826 1763 1827 DECLINLINE(UINT) vboxWddmSwapchainIdxFb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)1828 {1829 return (pSwapchain->iBB + pSwapchain->cRTs - 1) % pSwapchain->cRTs;1830 }1831 1832 /* if swapchain contains only one surface returns this surface */1833 DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainGetBb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)1834 {1835 if (pSwapchain->cRTs)1836 {1837 Assert(pSwapchain->iBB < pSwapchain->cRTs);1838 return &pSwapchain->aRTs[pSwapchain->iBB];1839 }1840 return NULL;1841 }1842 1843 DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainGetFb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)1844 {1845 if (pSwapchain->cRTs)1846 {1847 UINT iFb = vboxWddmSwapchainIdxFb(pSwapchain);1848 return &pSwapchain->aRTs[iFb];1849 }1850 return NULL;1851 }1852 1853 1764 DECLINLINE(VOID) vboxWddmSwapchainFlip(PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 1854 1765 { … … 1889 1800 Assert(iRt < pSwapchain->cRTs); 1890 1801 return iRt; 1891 }1892 1893 DECLINLINE(PVBOXWDDMDISP_SWAPCHAIN) vboxWddmSwapchainForAlloc(PVBOXWDDMDISP_ALLOCATION pAlloc)1894 {1895 return pAlloc->pSwapchain;1896 1802 } 1897 1803 … … 3413 3319 { 3414 3320 pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf; 3415 #ifdef DEBUG_misha 3416 /* this proved to be the easiest way of detecting blit issues with WinDbg 3417 * this is why I'd keep this test here to be able to switch it on at runtime any time needed */ 3418 static bool bDo = false; 3419 3420 if (bDo) 3421 { 3422 vboxVDbgDoDumpSurfData("SetTexture:\n", pRc, 0 /* alloc index*/, NULL, NULL, "\n"); 3423 } 3424 #endif 3321 3322 VBOXVDBG_DUMP_SETTEXTURE(pRc); 3425 3323 } 3426 3324 else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_CUBE_TEXTURE) 3427 3325 { 3428 3326 pD3DIfTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf; 3327 3328 VBOXVDBG_DUMP_SETTEXTURE(pRc); 3429 3329 } 3430 3330 else … … 3554 3454 HRESULT hr = S_OK; 3555 3455 3556 //#ifdef DEBUG_misha 3557 // uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; 3558 // vboxVDbgDumpSurfData((pDevice, ">>>DrawPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf, 3559 // NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n")); 3560 //#endif 3456 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice9If); 3561 3457 3562 3458 if (!pDevice->cStreamSources) … … 3821 3717 } 3822 3718 3823 //#ifdef DEBUG_misha 3824 // iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; 3825 // vboxVDbgDumpSurfData((pDevice, "<<<DrawPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf, 3826 // NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n")); 3827 //#endif 3719 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice9If); 3828 3720 3829 3721 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 3840 3732 3841 3733 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 3842 //#ifdef DEBUG_misha 3843 // uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; 3844 // vboxVDbgDumpSurfData((pDevice, ">>>DrawIndexedPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf, 3845 // NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n")); 3846 //#endif 3734 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice9If); 3847 3735 3848 3736 #ifdef DEBUG … … 3878 3766 Assert(hr == S_OK); 3879 3767 3880 //#ifdef DEBUG_misha 3881 // iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; 3882 // vboxVDbgDumpSurfData((pDevice, "<<<DrawIndexedPrimitive:\n", pDevice->pRenderTargetRc, iBackBuf, 3883 // NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n")); 3884 //#endif 3885 3768 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice9If); 3886 3769 3887 3770 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); … … 3953 3836 hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount); 3954 3837 #else 3955 //#ifdef DEBUG_misha 3956 // uint32_t iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; 3957 // vboxVDbgDumpSurfData((pDevice, ">>>DrawPrimitive2:\n", pDevice->pRenderTargetRc, iBackBuf, 3958 // NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n")); 3959 //#endif 3838 VBOXVDBG_DUMP_DRAWPRIM_ENTER(pDevice9If); 3960 3839 3961 3840 #ifdef DEBUG … … 4003 3882 #endif 4004 3883 4005 //#ifdef DEBUG_misha 4006 // iBackBuf = (pDevice->iRenderTargetFrontBuf + 1) % pDevice->pRenderTargetRc->cAllocations; 4007 // vboxVDbgDumpSurfData((pDevice, "<<<DrawPrimitive2:\n", pDevice->pRenderTargetRc, iBackBuf, 4008 // NULL, (IDirect3DSurface9*)pDevice->pRenderTargetRc->aAllocations[iBackBuf].pD3DIf, "\n")); 4009 //#endif 3884 VBOXVDBG_DUMP_DRAWPRIM_LEAVE(pDevice9If); 4010 3885 4011 3886 Assert(hr == S_OK); … … 4065 3940 HRESULT hr = S_OK; 4066 3941 4067 #ifdef DEBUG_misha 4068 /* this proved to be the easiest way of detecting blit issues with WinDbg 4069 * this is why I'd keep this test here to be able to switch it on at runtime any time needed */ 4070 static bool bDo = false; 4071 IDirect3DSurface9 *pTstSrcSurfIf = NULL; 4072 IDirect3DSurface9 *pTstDstSurfIf = NULL; 4073 4074 if (bDo) 4075 { 4076 RECT DstRect; 4077 hr = vboxWddmSurfGet(pSrcRc, 0, &pTstSrcSurfIf); 4078 Assert(hr == S_OK); 4079 hr = vboxWddmSurfGet(pDstRc, 0, &pTstDstSurfIf); 4080 Assert(hr == S_OK); 4081 4082 vboxWddmRectMoved(&DstRect, &pData->SrcRect, pData->DstPoint.x, pData->DstPoint.y); 4083 vboxVDbgDoDumpSurfData("TexBlt-pre Src:\n", pSrcRc, 0, &pData->SrcRect, pTstSrcSurfIf, "\n"); 4084 vboxVDbgDoDumpSurfData("TexBlt-pre Dst:\n", pDstRc, 0, &DstRect, pTstDstSurfIf, "\n"); 4085 } 4086 #endif 3942 VBOXVDBG_DUMP_TEXBLT_ENTER(pSrcRc, &pData->SrcRect, pDstRc, &pData->DstPoint); 4087 3943 4088 3944 if (pSrcRc->aAllocations[0].D3DWidth == pDstRc->aAllocations[0].D3DWidth … … 4131 3987 } 4132 3988 4133 #ifdef DEBUG_misha 4134 /* this proved to be the easiest way of detecting blit issues with WinDbg 4135 * this is why I'd keep this test here to be able to switch it on at runtime any time needed */ 4136 4137 if (bDo) 4138 { 4139 RECT DstRect; 4140 vboxWddmRectMoved(&DstRect, &pData->SrcRect, pData->DstPoint.x, pData->DstPoint.y); 4141 vboxVDbgDoDumpSurfData("TexBlt-post Src:\n", pSrcRc, 0, &pData->SrcRect, pTstSrcSurfIf, "\n"); 4142 vboxVDbgDoDumpSurfData("TexBlt-post Dst:\n", pDstRc, 0, &DstRect, pTstDstSurfIf, "\n"); 4143 } 4144 4145 if (pTstDstSurfIf) 4146 pTstDstSurfIf->Release(); 4147 if (pTstSrcSurfIf) 4148 pTstSrcSurfIf->Release(); 4149 #endif 3989 VBOXVDBG_DUMP_TEXBLT_LEAVE(pSrcRc, &pData->SrcRect, pDstRc, &pData->DstPoint); 3990 4150 3991 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); 4151 3992 return hr; … … 5281 5122 } 5282 5123 #endif 5283 5284 // if (pResource->Flags.RenderTarget)5285 // bIssueCreateResource = true;5286 5287 5124 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 5288 5125 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[0]; 5289 5126 IDirect3DTexture9 *pD3DIfTex; 5290 5127 HANDLE hSharedHandle = NULL; 5128 void **pavClientMem = NULL; 5291 5129 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5292 5130 { … … 5306 5144 } 5307 5145 } 5308 #if 0 5309 hr = pDevice9If->CreateTexture(pSurf->Width, 5310 pAllocation->D3DWidth, 5311 pResource->SurfCount, 5312 vboxDDI2D3DUsage(pResource->Flags), 5313 vboxDDI2D3DFormat(pResource->Format), 5314 vboxDDI2D3DPool(pResource->Pool), 5315 &pD3DIfTex, 5316 NULL /* HANDLE* pSharedHandle */ 5317 ); 5318 #else 5319 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If, 5320 pAllocation->D3DWidth, 5321 pSurf->Height, 5322 pResource->SurfCount, 5323 vboxDDI2D3DUsage(pResource->Flags), 5324 vboxDDI2D3DFormat(pResource->Format), 5325 vboxDDI2D3DPool(pResource->Pool), 5326 &pD3DIfTex, 5327 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5328 pResource->Pool == D3DDDIPOOL_SYSTEMMEM ? pRc->aAllocations[0].pvMem : NULL); 5329 #endif 5330 Assert(hr == S_OK); 5331 if (hr == S_OK) 5146 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5332 5147 { 5333 Assert(pD3DIfTex); 5334 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE; 5335 pAllocation->pD3DIf = pD3DIfTex; 5336 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5337 pAllocation->hSharedHandle = hSharedHandle; 5338 #if 0 5339 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5148 pavClientMem = (void**)RTMemAlloc(sizeof (pavClientMem[0]) * pResource->SurfCount); 5149 Assert(pavClientMem); 5150 if (pavClientMem) 5340 5151 { 5341 5152 for (UINT i = 0; i < pResource->SurfCount; ++i) 5342 5153 { 5343 D3DLOCKED_RECT lockInfo; 5344 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 5345 Assert(pAllocation->pvMem); 5346 hr = pD3DIfTex->LockRect(i, &lockInfo, NULL, D3DLOCK_DISCARD); 5347 Assert(hr == S_OK); 5348 if (hr == S_OK) 5349 { 5350 vboxWddmLockUnlockMemSynch(pAllocation, &lockInfo, NULL, true /*bool bToLockInfo*/); 5351 HRESULT tmpHr = pD3DIfTex->UnlockRect(i); 5352 Assert(tmpHr == S_OK); 5353 } 5354 else 5355 { 5356 pD3DIfTex->Release(); 5357 break; 5358 } 5154 pavClientMem[i] = pRc->aAllocations[i].pvMem; 5359 5155 } 5360 5156 } 5361 #endif 5157 else 5158 hr = E_FAIL; 5362 5159 } 5363 #ifdef DEBUG 5364 else 5160 if (hr == S_OK) 5365 5161 { 5366 for (UINT i = 0; i < pResource->SurfCount; ++i) 5162 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateTexture((IDirect3DDevice9Ex *)pDevice9If, 5163 pAllocation->D3DWidth, 5164 pSurf->Height, 5165 pResource->SurfCount, 5166 vboxDDI2D3DUsage(pResource->Flags), 5167 vboxDDI2D3DFormat(pResource->Format), 5168 vboxDDI2D3DPool(pResource->Pool), 5169 &pD3DIfTex, 5170 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5171 pavClientMem); 5172 Assert(hr == S_OK); 5173 if (hr == S_OK) 5367 5174 { 5368 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 5369 Assert(!pAllocation->pvMem); 5175 Assert(pD3DIfTex); 5176 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_TEXTURE; 5177 pAllocation->pD3DIf = pD3DIfTex; 5178 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5179 pAllocation->hSharedHandle = hSharedHandle; 5370 5180 } 5181 5182 if (pavClientMem) 5183 RTMemFree(pavClientMem); 5371 5184 } 5372 #endif5373 5185 } 5374 5186 else /*pResource->Flags.CubeMap*/ 5375 5187 { 5376 5188 IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice); 5377 5378 5189 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; 5379 5190 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[0]; 5380 5191 IDirect3DCubeTexture9 *pD3DIfCubeTex; 5381 5192 HANDLE hSharedHandle = NULL; 5193 void **pavClientMem = NULL; 5382 5194 5383 5195 if ( (pAllocation->SurfDesc.width!=pAllocation->SurfDesc.height) … … 5389 5201 else 5390 5202 { 5391 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateCubeTexture((IDirect3DDevice9Ex *)pDevice9If, 5392 pAllocation->SurfDesc.width, 5393 VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc), 5394 vboxDDI2D3DUsage(pResource->Flags), 5395 vboxDDI2D3DFormat(pResource->Format), 5396 vboxDDI2D3DPool(pResource->Pool), 5397 &pD3DIfCubeTex, 5398 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5399 pResource->Pool == D3DDDIPOOL_SYSTEMMEM ? pRc->aAllocations[0].pvMem : NULL); 5400 } 5401 5402 Assert(hr == S_OK); 5403 if (hr == S_OK) 5404 { 5405 Assert(pD3DIfCubeTex); 5406 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_CUBE_TEXTURE; 5407 pAllocation->pD3DIf = pD3DIfCubeTex; 5408 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5409 pAllocation->hSharedHandle = hSharedHandle; 5203 if (pResource->Pool == D3DDDIPOOL_SYSTEMMEM) 5204 { 5205 pavClientMem = (void**)RTMemAlloc(sizeof (pavClientMem[0]) * pResource->SurfCount); 5206 Assert(pavClientMem); 5207 if (pavClientMem) 5208 { 5209 for (UINT i = 0; i < pResource->SurfCount; ++i) 5210 { 5211 pavClientMem[i] = pRc->aAllocations[i].pvMem; 5212 } 5213 } 5214 else 5215 hr = E_FAIL; 5216 } 5217 5218 if (hr == S_OK) 5219 { 5220 hr = pDevice->pAdapter->D3D.pfnVBoxWineExD3DDev9CreateCubeTexture((IDirect3DDevice9Ex *)pDevice9If, 5221 pAllocation->SurfDesc.width, 5222 VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc), 5223 vboxDDI2D3DUsage(pResource->Flags), 5224 vboxDDI2D3DFormat(pResource->Format), 5225 vboxDDI2D3DPool(pResource->Pool), 5226 &pD3DIfCubeTex, 5227 pResource->Flags.SharedResource ? &hSharedHandle : NULL, 5228 pavClientMem); 5229 Assert(hr == S_OK); 5230 if (hr == S_OK) 5231 { 5232 Assert(pD3DIfCubeTex); 5233 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_CUBE_TEXTURE; 5234 pAllocation->pD3DIf = pD3DIfCubeTex; 5235 Assert(!!(pResource->Flags.SharedResource) == !!(hSharedHandle)); 5236 pAllocation->hSharedHandle = hSharedHandle; 5237 } 5238 5239 if (pavClientMem) 5240 RTMemFree(pavClientMem); 5241 } 5410 5242 } 5411 5243 } … … 5447 5279 if (hr == S_OK) 5448 5280 { 5449 #if 05450 if(pResource->Flags.Primary)5451 {5452 for (UINT i = 0; i < pResource->SurfCount; ++i)5453 {5454 vboxWddmSwapchainFindCreate(pDevice, &pRc->aAllocations[i]);5455 }5456 Assert(bIssueCreateResource);5457 }5458 #endif5459 5281 continue; 5460 5282 } … … 5474 5296 else 5475 5297 { 5476 // PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen];5477 // Assert(pScreen->hWnd);5478 // Assert(pScreen->pDevice9If);5479 5298 hr = E_FAIL; 5480 5299 Assert(0); … … 6471 6290 ) 6472 6291 { 6473 // Assert(pSrcAlloc->SurfDesc.width == pDstAlloc->SurfDesc.width);6474 // Assert(pSrcAlloc->SurfDesc.height == pDstAlloc->SurfDesc.height);6475 // Assert(pSrcAlloc->SurfDesc.format == pDstAlloc->SurfDesc.format);6476 // Assert(pSrcAlloc->SurfDesc.bpp == pDstAlloc->SurfDesc.bpp);6477 // Assert(pSrcAlloc->SurfDesc.pitch == pDstAlloc->SurfDesc.pitch);6478 // Assert(pSrcAlloc->SurfDesc.depth == pDstAlloc->SurfDesc.depth);6479 // Assert(pSrcAlloc->SurfDesc.slicePitch == pDstAlloc->SurfDesc.slicePitch);6480 // Assert(pSrcAlloc->SurfDesc.cbSize == pDstAlloc->SurfDesc.cbSize);6481 // Assert(pData->DstRect.left == 0);6482 // Assert(pData->DstRect.top == 0);6483 // Assert(pData->DstRect.right == pDstAlloc->SurfDesc.width);6484 // Assert(pData->DstRect.bottom == pDstAlloc->SurfDesc.height);6485 // Assert(pData->SrcRect.left == 0);6486 // Assert(pData->SrcRect.top == 0);6487 // Assert(pData->SrcRect.right == pSrcAlloc->SurfDesc.width);6488 // Assert(pData->SrcRect.bottom == pSrcAlloc->SurfDesc.height);6489 6292 # if 0 6490 6293 if (pData->DstRect.left == 0 && pData->DstRect.top == 0 … … 6534 6337 { 6535 6338 Assert(pSrcSurfIf); 6536 #ifdef DEBUG_misha 6537 /* this proved to be the easiest way of detecting blit issues with WinDbg 6538 * this is why I'd keep this test here to be able to switch it on at runtime any time needed */ 6539 static bool bDo = false; 6540 6541 if (bDo) 6542 { 6543 vboxVDbgDoDumpSurfData("Blt-pre Src:\n", pSrcRc, pData->SrcSubResourceIndex, &pData->SrcRect, pSrcSurfIf, "\n"); 6544 vboxVDbgDoDumpSurfData("Blt-pre Dst:\n", pDstRc, pData->DstSubResourceIndex, &pData->DstRect, pDstSurfIf, "\n"); 6545 } 6546 #endif 6339 6340 VBOXVDBG_DUMP_BLT_ENTER(pSrcSurfIf, &pData->SrcRect, pDstSurfIf, &pData->DstRect); 6341 6547 6342 /* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */ 6548 6343 Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001 | 0x00000002))) == 0); … … 6554 6349 Assert(hr == S_OK); 6555 6350 6556 #ifdef DEBUG_misha 6557 /* this proved to be the easiest way of detecting blit issues with WinDbg 6558 * this is why I'd keep this test here to be able to switch it on at runtime any time needed */ 6559 if (bDo) 6560 { 6561 vboxVDbgDoDumpSurfData("Blt-post Src:\n", pSrcRc, pData->SrcSubResourceIndex, &pData->SrcRect, pSrcSurfIf, "\n"); 6562 vboxVDbgDoDumpSurfData("Blt-post Dst:\n", pDstRc, pData->DstSubResourceIndex, &pData->DstRect, pDstSurfIf, "\n"); 6563 } 6564 #endif 6351 VBOXVDBG_DUMP_BLT_LEAVE(pSrcSurfIf, &pData->SrcRect, pDstSurfIf, &pData->DstRect); 6352 6565 6353 pSrcSurfIf->Release(); 6566 6354 } … … 8015 7803 return hr; 8016 7804 } 8017 8018 #ifdef VBOXWDDMDISP_DEBUG_PRINT8019 VOID vboxVDbgDoMpPrint(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString)8020 {8021 uint32_t cbString = (uint32_t)strlen(szString) + 1;8022 uint32_t cbCmd = RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cbString]);8023 PVBOXDISPIFESCAPE_DBGPRINT pCmd = (PVBOXDISPIFESCAPE_DBGPRINT)RTMemAllocZ(cbCmd);8024 Assert(pCmd);8025 if (pCmd)8026 {8027 pCmd->EscapeHdr.escapeCode = VBOXESC_DBGPRINT;8028 memcpy(pCmd->aStringBuf, szString, cbString);8029 8030 D3DDDICB_ESCAPE DdiEscape = {0};8031 DdiEscape.hContext = NULL;8032 DdiEscape.hDevice = NULL;8033 DdiEscape.Flags.Value = 0;8034 DdiEscape.pPrivateDriverData = pCmd;8035 DdiEscape.PrivateDriverDataSize = cbCmd;8036 8037 HRESULT hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);8038 Assert(hr == S_OK);8039 8040 RTMemFree(pCmd);8041 }8042 }8043 VOID vboxVDbgDoMpPrintF(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString, ...)8044 {8045 char szBuffer[4096] = {0};8046 va_list pArgList;8047 va_start(pArgList, szString);8048 _vsnprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), szString, pArgList);8049 va_end(pArgList);8050 8051 if (pDevice)8052 {8053 vboxVDbgDoMpPrint(pDevice, szBuffer);8054 }8055 else8056 {8057 OutputDebugStringA(szBuffer);8058 }8059 }8060 VOID vboxVDbgDoPrint(LPCSTR szString, ...)8061 {8062 char szBuffer[1024] = {0};8063 va_list pArgList;8064 va_start(pArgList, szString);8065 _vsnprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), szString, pArgList);8066 va_end(pArgList);8067 8068 OutputDebugStringA(szBuffer);8069 }8070 #endif8071 8072 #ifdef VBOXWDDMDISP_DEBUG8073 8074 VOID vboxVDbgDoDumpAllocSurfData(const PVBOXWDDMDISP_DEVICE pDevice, const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DSurface9 *pSurf, const RECT *pRect, const char* pSuffix)8075 {8076 if (pPrefix)8077 {8078 vboxVDbgPrint(("%s", pPrefix));8079 }8080 8081 D3DLOCKED_RECT Lr;8082 if (pRect)8083 {8084 Assert(pRect->right > pRect->left);8085 Assert(pRect->bottom > pRect->top);8086 vboxVDbgDoPrintRect("rect: ", pRect, "\n");8087 }8088 8089 HRESULT srcHr = pSurf->LockRect(&Lr, NULL, D3DLOCK_READONLY);8090 Assert(srcHr == S_OK);8091 if (srcHr == S_OK)8092 {8093 UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);8094 // Assert(bpp == pAlloc->SurfDesc.bpp);8095 // Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);8096 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>\n",8097 Lr.pBits, pAlloc->D3DWidth, pAlloc->SurfDesc.height, bpp, Lr.Pitch));8098 if (pRect)8099 {8100 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">rect info</exec>\n",8101 ((uint8_t*)Lr.pBits) + (pRect->top * Lr.Pitch) + ((pRect->left * bpp) >> 3),8102 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, Lr.Pitch));8103 }8104 Assert(0);8105 8106 srcHr = pSurf->UnlockRect();8107 Assert(srcHr == S_OK);8108 }8109 if (pSuffix)8110 {8111 vboxVDbgPrint(("%s\n", pSuffix));8112 }8113 }8114 8115 VOID vboxVDbgDoDumpAllocData(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, const RECT *pRect, const char* pSuffix)8116 {8117 if (pPrefix)8118 {8119 vboxVDbgPrint(("%s", pPrefix));8120 }8121 8122 if (pRect)8123 {8124 Assert(pRect->right > pRect->left);8125 Assert(pRect->bottom > pRect->top);8126 vboxVDbgDoPrintRect("rect: ", pRect, "\n");8127 }8128 8129 Assert(pAlloc->hAllocation);8130 8131 D3DDDICB_LOCK LockData;8132 LockData.hAllocation = pAlloc->hAllocation;8133 LockData.PrivateDriverData = 0;8134 LockData.NumPages = 0;8135 LockData.pPages = NULL;8136 LockData.pData = NULL; /* out */8137 LockData.Flags.Value = 0;8138 LockData.Flags.LockEntire =1;8139 LockData.Flags.ReadOnly = 1;8140 8141 PVBOXWDDMDISP_DEVICE pDevice = pAlloc->pRc->pDevice;8142 8143 HRESULT hr = pDevice->RtCallbacks.pfnLockCb(pDevice->hDevice, &LockData);8144 Assert(hr == S_OK);8145 if (hr == S_OK)8146 {8147 UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);8148 // Assert(bpp == pAlloc->SurfDesc.bpp);8149 // Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);8150 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>\n",8151 LockData.pData, pAlloc->D3DWidth, pAlloc->SurfDesc.height, bpp, pAlloc->SurfDesc.pitch));8152 if (pRect)8153 {8154 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">rect info</exec>\n",8155 ((uint8_t*)LockData.pData) + (pRect->top * pAlloc->SurfDesc.pitch) + ((pRect->left * bpp) >> 3),8156 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, pAlloc->SurfDesc.pitch));8157 }8158 Assert(0);8159 8160 D3DDDICB_UNLOCK DdiUnlock;8161 8162 DdiUnlock.NumAllocations = 1;8163 DdiUnlock.phAllocations = &pAlloc->hAllocation;8164 8165 hr = pDevice->RtCallbacks.pfnUnlockCb(pDevice->hDevice, &DdiUnlock);8166 Assert(hr == S_OK);8167 }8168 if (pSuffix)8169 {8170 vboxVDbgPrint(("%s\n", pSuffix));8171 }8172 }8173 8174 8175 VOID vboxVDbgDoDumpSurfData(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, IDirect3DSurface9 *pSurf, const char* pSuffix)8176 {8177 if (pPrefix)8178 {8179 vboxVDbgPrint(("%s", pPrefix));8180 }8181 8182 Assert(pRc->cAllocations > iAlloc);8183 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[iAlloc];8184 8185 vboxVDbgDoPrintAlloc("allocation info:\n", pRc, iAlloc, "\n");8186 8187 D3DLOCKED_RECT Lr;8188 if (pRect)8189 {8190 Assert(pRect->right > pRect->left);8191 Assert(pRect->bottom > pRect->top);8192 vboxVDbgDoPrintRect("rect: ", pRect, "\n");8193 }8194 8195 BOOL bReleaseSurf = false;8196 if (!pSurf)8197 {8198 HRESULT tmpHr = vboxWddmSurfGet(pRc, iAlloc, &pSurf);8199 Assert(tmpHr == S_OK);8200 bReleaseSurf = TRUE;8201 }8202 HRESULT srcHr = pSurf->LockRect(&Lr, NULL, D3DLOCK_READONLY);8203 Assert(srcHr == S_OK);8204 if (srcHr == S_OK)8205 {8206 UINT bpp = vboxWddmCalcBitsPerPixel(pAlloc->SurfDesc.format);8207 // Assert(bpp == pAlloc->SurfDesc.bpp);8208 // Assert(pAlloc->SurfDesc.pitch == Lr.Pitch);8209 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>\n",8210 Lr.pBits, pAlloc->D3DWidth, pAlloc->SurfDesc.height, bpp, Lr.Pitch));8211 if (pRect)8212 {8213 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">rect info</exec>\n",8214 ((uint8_t*)Lr.pBits) + (pRect->top * Lr.Pitch) + ((pRect->left * bpp) >> 3),8215 pRect->right - pRect->left, pRect->bottom - pRect->top, bpp, Lr.Pitch));8216 }8217 Assert(0);8218 8219 srcHr = pSurf->UnlockRect();8220 Assert(srcHr == S_OK);8221 }8222 if (pSuffix)8223 {8224 vboxVDbgPrint(("%s\n", pSuffix));8225 }8226 8227 if (bReleaseSurf)8228 pSurf->Release();8229 }8230 8231 VOID vboxVDbgDoDumpSurfDataBySurf(IDirect3DSurface9 *pSurf)8232 {8233 D3DSURFACE_DESC Desc;8234 HRESULT hr = pSurf->GetDesc(&Desc);8235 Assert(hr == S_OK);8236 if (hr == S_OK)8237 {8238 D3DLOCKED_RECT Lr;8239 hr = pSurf->LockRect(&Lr, NULL, D3DLOCK_READONLY);8240 Assert(hr == S_OK);8241 if (hr == S_OK)8242 {8243 UINT bpp = vboxWddmCalcBitsPerPixel((D3DDDIFORMAT)Desc.Format);8244 vboxVDbgPrint(("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">surface info</exec>\n",8245 Lr.pBits, Desc.Width, Desc.Height, bpp, Lr.Pitch));8246 8247 Assert(0);8248 8249 hr = pSurf->UnlockRect();8250 Assert(hr == S_OK);8251 }8252 }8253 }8254 8255 void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix)8256 {8257 Assert(pRc->cAllocations > iAlloc);8258 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[iAlloc];8259 BOOL bPrimary = pRc->RcDesc.fFlags.Primary;8260 BOOL bFrontBuf = FALSE;8261 if (bPrimary)8262 {8263 PVBOXWDDMDISP_SWAPCHAIN pSwapchain = vboxWddmSwapchainForAlloc(pAlloc);8264 Assert(pSwapchain);8265 bFrontBuf = (vboxWddmSwapchainGetFb(pSwapchain)->pAlloc == pAlloc);8266 }8267 vboxVDbgPrint(("%s D3DWidth(%d), width(%d), height(%d), format(%d), usage(%s), %s", pPrefix,8268 pAlloc->D3DWidth, pAlloc->SurfDesc.width, pAlloc->SurfDesc.height, pAlloc->SurfDesc.format,8269 bPrimary ?8270 (bFrontBuf ? "Front Buffer" : "Back Buffer")8271 : "?Everage? Alloc",8272 pSuffix));8273 }8274 8275 void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix)8276 {8277 vboxVDbgPrint(("%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix));8278 }8279 #endif8280 8281 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER8282 8283 static PVOID g_VBoxWDbgVEHandler = NULL;8284 LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)8285 {8286 PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;8287 PCONTEXT pContextRecord = pExceptionInfo->ContextRecord;8288 switch (pExceptionRecord->ExceptionCode)8289 {8290 case 0x40010006: /* <- OutputDebugString exception, ignore */8291 case 0xe06d7363: /* <- ms compiler - generated exception related to C++ exception */8292 case 0x000006d9: /* <- RPC exception, ignore */8293 break;8294 default:8295 AssertRelease(0);8296 break;8297 }8298 return EXCEPTION_CONTINUE_SEARCH;8299 }8300 8301 void vboxVDbgVEHandlerRegister()8302 {8303 Assert(!g_VBoxWDbgVEHandler);8304 g_VBoxWDbgVEHandler = AddVectoredExceptionHandler(1,vboxVDbgVectoredHandler);8305 Assert(g_VBoxWDbgVEHandler);8306 }8307 8308 void vboxVDbgVEHandlerUnregister()8309 {8310 Assert(g_VBoxWDbgVEHandler);8311 ULONG uResult = RemoveVectoredExceptionHandler(g_VBoxWDbgVEHandler);8312 Assert(uResult);8313 g_VBoxWDbgVEHandler = NULL;8314 }8315 8316 #endif8317 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h
r33836 r35650 268 268 } VBOXWDDMDISP_OVERLAY, *PVBOXWDDMDISP_OVERLAY; 269 269 270 #define VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc) (((pRc)->cAllocations)/6) 271 #define VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, idx) ((D3DCUBEMAP_FACES)(D3DCUBEMAP_FACE_POSITIVE_X+(idx)%VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc))) 272 #define VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, idx) ((idx)%VBOXDISP_CUBEMAP_LEVELS_COUNT(pRc)) 273 270 274 #ifdef VBOX_WITH_CRHGSMI 271 275 HRESULT vboxUhgsmiGlobalSetCurrent(); 272 276 HRESULT vboxUhgsmiGlobalClearCurrent(); 273 277 #endif 278 279 DECLINLINE(PVBOXWDDMDISP_SWAPCHAIN) vboxWddmSwapchainForAlloc(PVBOXWDDMDISP_ALLOCATION pAlloc) 280 { 281 return pAlloc->pSwapchain; 282 } 283 284 DECLINLINE(UINT) vboxWddmSwapchainIdxFb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 285 { 286 return (pSwapchain->iBB + pSwapchain->cRTs - 1) % pSwapchain->cRTs; 287 } 288 289 /* if swapchain contains only one surface returns this surface */ 290 DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainGetBb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 291 { 292 if (pSwapchain->cRTs) 293 { 294 Assert(pSwapchain->iBB < pSwapchain->cRTs); 295 return &pSwapchain->aRTs[pSwapchain->iBB]; 296 } 297 return NULL; 298 } 299 300 DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainGetFb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain) 301 { 302 if (pSwapchain->cRTs) 303 { 304 UINT iFb = vboxWddmSwapchainIdxFb(pSwapchain); 305 return &pSwapchain->aRTs[iFb]; 306 } 307 return NULL; 308 } 309 310 /* on success increments the surface ref counter, 311 * i.e. one must call pSurf->Release() once the surface is not needed*/ 312 DECLINLINE(HRESULT) vboxWddmSurfGet(PVBOXWDDMDISP_RESOURCE pRc, UINT iAlloc, IDirect3DSurface9 **ppSurf) 313 { 314 HRESULT hr = S_OK; 315 Assert(pRc->cAllocations > iAlloc); 316 switch (pRc->aAllocations[0].enmD3DIfType) 317 { 318 case VBOXDISP_D3DIFTYPE_SURFACE: 319 { 320 IDirect3DSurface9 *pD3DIfSurf = (IDirect3DSurface9*)pRc->aAllocations[iAlloc].pD3DIf; 321 Assert(pD3DIfSurf); 322 pD3DIfSurf->AddRef(); 323 *ppSurf = pD3DIfSurf; 324 break; 325 } 326 case VBOXDISP_D3DIFTYPE_TEXTURE: 327 { 328 Assert(pRc->cAllocations == 1); /* <- vboxWddmSurfGet is typically used in Blt & ColorFill functions 329 * in this case, if texture is used as a destination, 330 * we should update sub-layers as well which is not done currently 331 * so for now check vboxWddmSurfGet is used for one-level textures */ 332 IDirect3DTexture9 *pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf; 333 IDirect3DSurface9 *pSurfaceLevel; 334 Assert(pD3DIfTex); 335 hr = pD3DIfTex->GetSurfaceLevel(iAlloc, &pSurfaceLevel); 336 Assert(hr == S_OK); 337 if (hr == S_OK) 338 { 339 *ppSurf = pSurfaceLevel; 340 } 341 break; 342 } 343 case VBOXDISP_D3DIFTYPE_CUBE_TEXTURE: 344 { 345 Assert(0); 346 IDirect3DCubeTexture9 *pD3DIfCubeTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf; 347 IDirect3DSurface9 *pSurfaceLevel; 348 Assert(pD3DIfCubeTex); 349 hr = pD3DIfCubeTex->GetCubeMapSurface(VBOXDISP_CUBEMAP_INDEX_TO_FACE(pRc, iAlloc), 350 VBOXDISP_CUBEMAP_INDEX_TO_LEVEL(pRc, iAlloc), &pSurfaceLevel); 351 Assert(hr == S_OK); 352 if (hr == S_OK) 353 { 354 *ppSurf = pSurfaceLevel; 355 } 356 break; 357 } 358 default: 359 Assert(0); 360 hr = E_FAIL; 361 break; 362 } 363 return hr; 364 } 274 365 275 366 #define VBOXDISPMODE_IS_3D(_p) (!!((_p)->pD3D9If)) -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h
r34848 r35650 30 30 #include <VBox/VBoxGuestLib.h> 31 31 32 #include "VBoxDispDbg.h" 32 33 #include "VBoxDispD3DIf.h" 33 34 #include "../../Miniport/wddm/VBoxVideoIf.h" 34 35 #include "VBoxDispCm.h" 36 #include "VBoxDispKmt.h" 35 37 #ifdef VBOX_WITH_CRHGSMI 36 38 #include "VBoxUhgsmiBase.h" … … 40 42 #include "VBoxDispD3D.h" 41 43 42 #ifdef DEBUG43 # define VBOXWDDMDISP_DEBUG44 # define VBOXWDDMDISP_DEBUG_FLOW45 # define VBOXWDDMDISP_DEBUG_DUMPSURFDATA46 # ifdef DEBUG_misha47 //# define VBOXWDDMDISP_DEBUG_VEHANDLER48 # endif49 #endif50 51 #if defined(VBOXWDDMDISP_DEBUG) || defined(VBOX_WDDMDISP_WITH_PROFILE) || defined(VBOXWDDM_TEST_UHGSMI)52 # define VBOXWDDMDISP_DEBUG_PRINT53 #endif54 55 #if 056 # ifdef Assert57 # undef Assert58 # define Assert(_a) do{}while(0)59 # endif60 # ifdef AssertBreakpoint61 # undef AssertBreakpoint62 # define AssertBreakpoint() do{}while(0)63 # endif64 # ifdef AssertFailed65 # undef AssertFailed66 # define AssertFailed() do{}while(0)67 # endif68 #endif69 70 #ifdef VBOXWDDMDISP_DEBUG_PRINT71 VOID vboxVDbgDoMpPrintF(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString, ...);72 VOID vboxVDbgDoMpPrint(const PVBOXWDDMDISP_DEVICE pDevice, LPCSTR szString);73 VOID vboxVDbgDoPrint(LPCSTR szString, ...);74 #endif75 76 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER77 void vboxVDbgVEHandlerRegister();78 void vboxVDbgVEHandlerUnregister();79 #endif80 81 #define vboxVDbgPrint Log82 #define vboxVDbgPrintF LogFlow83 #define vboxVDbgPrintR LogRel84 85 #ifdef VBOXWDDMDISP_DEBUG86 VOID vboxVDbgDoDumpAllocData(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, const RECT *pRect, const char* pSuffix);87 VOID vboxVDbgDoDumpAllocSurfData(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DSurface9 *pSurf, const RECT *pRect, const char* pSuffix);88 VOID vboxVDbgDoDumpSurfData(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, IDirect3DSurface9 *pSurf, const char* pSuffix);89 void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix);90 void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix);91 #endif92 93 #if 094 #ifdef VBOXWDDMDISP_DEBUG95 extern bool g_VDbgTstDumpEnable;96 extern bool g_VDbgTstDumpOnSys2VidSameSizeEnable;97 98 VOID vboxVDbgDoDumpAllocData(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, const RECT *pRect, const char* pSuffix);99 VOID vboxVDbgDoDumpAllocSurfData(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DSurface9 *pSurf, const RECT *pRect, const char* pSuffix);100 VOID vboxVDbgDoDumpSurfData(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, IDirect3DSurface9 *pSurf, const char* pSuffix);101 void vboxVDbgDoMpPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix);102 void vboxVDbgDoMpPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix);103 104 #define vboxVDbgBreak() AssertBreakpoint()105 #define vboxVDbgPrint(_m) \106 do { \107 vboxVDbgDoPrint _m ; \108 } while (0)109 #define vboxVDbgPrintR vboxVDbgPrint110 #define vboxVDbgMpPrint(_m) \111 do { \112 vboxVDbgDoMpPrint _m ; \113 } while (0)114 #define vboxVDbgMpPrintF(_m) \115 do { \116 vboxVDbgDoMpPrintF _m ; \117 } while (0)118 #define vboxVDbgMpPrintRect(_m) \119 do { \120 vboxVDbgDoMpPrintRect _m ; \121 } while (0)122 #define vboxVDbgMpPrintAlloc(_m) \123 do { \124 vboxVDbgDoMpPrintAlloc _m ; \125 } while (0)126 #ifdef VBOXWDDMDISP_DEBUG_DUMPSURFDATA127 #define vboxVDbgDumpSurfData(_m) \128 do { \129 vboxVDbgDoDumpSurfData _m ; \130 } while (0)131 #define vboxVDbgDumpAllocSurfData(_m) \132 do { \133 vboxVDbgDoDumpAllocSurfData _m ; \134 } while (0)135 #define vboxVDbgDumpAllocData(_m) \136 do { \137 vboxVDbgDoDumpAllocData _m ; \138 } while (0)139 #else140 #define vboxVDbgDumpSurfData(_m) do {} while (0)141 #endif142 #ifdef VBOXWDDMDISP_DEBUG_FLOW143 # define vboxVDbgPrintF vboxVDbgPrint144 #else145 # define vboxVDbgPrintF(_m) do {} while (0)146 #endif147 #else148 #define vboxVDbgMpPrint(_m) do {} while (0)149 #define vboxVDbgMpPrintF(_m) do {} while (0)150 #define vboxVDbgMpPrintRect(_m) do {} while (0)151 #define vboxVDbgMpPrintAlloc(_m) do {} while (0)152 #define vboxVDbgDumpSurfData(_m) do {} while (0)153 #define vboxVDbgDumpAllocSurfData(_m) do {} while (0)154 #define vboxVDbgDumpAllocData(_m) do {} while (0)155 #define vboxVDbgBreak() do {} while (0)156 #define vboxVDbgPrint(_m) do {} while (0)157 #define vboxVDbgPrintR vboxVDbgPrint158 #define vboxVDbgPrintF vboxVDbgPrint159 #endif160 #endif161 44 162 45 # ifdef VBOXWDDMDISP -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispProfile.h
r32962 r35650 24 24 #define VBOXDISPPROFILE_GET_TIME_MILLI() RTTimeMilliTS() 25 25 #define VBOXDISPPROFILE_DUMP(_m) do {\ 26 vboxVDbgDoMpPrintF _m; \26 LogRel (_m); \ 27 27 } while (0) 28 28 … … 59 59 // m_pName, m_cCalls, 60 60 // m_cTime, m_cTime/1000, m_cTime/1000000)); 61 VBOXDISPPROFILE_DUMP(( pDevice,"%s\t%d\t%I64u\t%I64u\t%I64u\n",61 VBOXDISPPROFILE_DUMP(("%s\t%d\t%I64u\t%I64u\t%I64u\n", 62 62 m_pName, m_cCalls, 63 63 m_cTime, m_cTime/1000, m_cTime/1000000)); … … 99 99 void dump(const PVBOXWDDMDISP_DEVICE pDevice) 100 100 { 101 VBOXDISPPROFILE_DUMP(( pDevice,">>>> Start of VBox Disp Dump '%s': num entries(%d) >>>>>\n", m_pName, m_cEntries));102 VBOXDISPPROFILE_DUMP(( pDevice,"Name\tCalls\tNanos\tMicros\tMillis\n"));101 VBOXDISPPROFILE_DUMP((">>>> Start of VBox Disp Dump '%s': num entries(%d) >>>>>\n", m_pName, m_cEntries)); 102 VBOXDISPPROFILE_DUMP(("Name\tCalls\tNanos\tMicros\tMillis\n")); 103 103 for (uint32_t i = 0; i < m_cEntries; ++i) 104 104 { 105 105 m_Entries[i].dump(pDevice); 106 106 } 107 VBOXDISPPROFILE_DUMP(( pDevice,"<<<< Endi of VBox Disp Dump '%s' <<<<<\n", m_pName));107 VBOXDISPPROFILE_DUMP(("<<<< Endi of VBox Disp Dump '%s' <<<<<\n", m_pName)); 108 108 } 109 109 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiKmt.cpp
r35319 r35650 481 481 return hr; 482 482 } 483 484 HRESULT vboxDispKmtCallbacksInit(PVBOXDISPKMT_CALLBACKS pCallbacks)485 {486 HRESULT hr = S_OK;487 488 memset(pCallbacks, 0, sizeof (*pCallbacks));489 490 pCallbacks->hGdi32 = LoadLibraryW(L"gdi32.dll");491 if (pCallbacks->hGdi32 != NULL)492 {493 bool bSupported = true;494 pCallbacks->pfnD3DKMTOpenAdapterFromHdc = (PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress(pCallbacks->hGdi32, "D3DKMTOpenAdapterFromHdc");495 Log((__FUNCTION__"pfnD3DKMTOpenAdapterFromHdc = %p\n", pCallbacks->pfnD3DKMTOpenAdapterFromHdc));496 bSupported &= !!(pCallbacks->pfnD3DKMTOpenAdapterFromHdc);497 498 pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName = (PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME)GetProcAddress(pCallbacks->hGdi32, "D3DKMTOpenAdapterFromGdiDisplayName");499 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName = %p\n", pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName));500 bSupported &= !!(pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName);501 502 pCallbacks->pfnD3DKMTCloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCloseAdapter");503 Log((__FUNCTION__": pfnD3DKMTCloseAdapter = %p\n", pCallbacks->pfnD3DKMTCloseAdapter));504 bSupported &= !!(pCallbacks->pfnD3DKMTCloseAdapter);505 506 pCallbacks->pfnD3DKMTEscape = (PFND3DKMT_ESCAPE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTEscape");507 Log((__FUNCTION__": pfnD3DKMTEscape = %p\n", pCallbacks->pfnD3DKMTEscape));508 bSupported &= !!(pCallbacks->pfnD3DKMTEscape);509 510 pCallbacks->pfnD3DKMTCreateDevice = (PFND3DKMT_CREATEDEVICE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateDevice");511 Log((__FUNCTION__": pfnD3DKMTCreateDevice = %p\n", pCallbacks->pfnD3DKMTCreateDevice));512 bSupported &= !!(pCallbacks->pfnD3DKMTCreateDevice);513 514 pCallbacks->pfnD3DKMTDestroyDevice = (PFND3DKMT_DESTROYDEVICE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyDevice");515 Log((__FUNCTION__": pfnD3DKMTDestroyDevice = %p\n", pCallbacks->pfnD3DKMTDestroyDevice));516 bSupported &= !!(pCallbacks->pfnD3DKMTDestroyDevice);517 518 pCallbacks->pfnD3DKMTCreateContext = (PFND3DKMT_CREATECONTEXT)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateContext");519 Log((__FUNCTION__": pfnD3DKMTCreateContext = %p\n", pCallbacks->pfnD3DKMTCreateContext));520 bSupported &= !!(pCallbacks->pfnD3DKMTCreateContext);521 522 pCallbacks->pfnD3DKMTDestroyContext = (PFND3DKMT_DESTROYCONTEXT)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyContext");523 Log((__FUNCTION__": pfnD3DKMTDestroyContext = %p\n", pCallbacks->pfnD3DKMTDestroyContext));524 bSupported &= !!(pCallbacks->pfnD3DKMTDestroyContext);525 526 pCallbacks->pfnD3DKMTRender = (PFND3DKMT_RENDER)GetProcAddress(pCallbacks->hGdi32, "D3DKMTRender");527 Log((__FUNCTION__": pfnD3DKMTRender = %p\n", pCallbacks->pfnD3DKMTRender));528 bSupported &= !!(pCallbacks->pfnD3DKMTRender);529 530 pCallbacks->pfnD3DKMTCreateAllocation = (PFND3DKMT_CREATEALLOCATION)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateAllocation");531 Log((__FUNCTION__": pfnD3DKMTCreateAllocation = %p\n", pCallbacks->pfnD3DKMTCreateAllocation));532 bSupported &= !!(pCallbacks->pfnD3DKMTCreateAllocation);533 534 pCallbacks->pfnD3DKMTDestroyAllocation = (PFND3DKMT_DESTROYALLOCATION)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyAllocation");535 Log((__FUNCTION__": pfnD3DKMTDestroyAllocation = %p\n", pCallbacks->pfnD3DKMTDestroyAllocation));536 bSupported &= !!(pCallbacks->pfnD3DKMTDestroyAllocation);537 538 pCallbacks->pfnD3DKMTLock = (PFND3DKMT_LOCK)GetProcAddress(pCallbacks->hGdi32, "D3DKMTLock");539 Log((__FUNCTION__": pfnD3DKMTLock = %p\n", pCallbacks->pfnD3DKMTLock));540 bSupported &= !!(pCallbacks->pfnD3DKMTLock);541 542 pCallbacks->pfnD3DKMTUnlock = (PFND3DKMT_UNLOCK)GetProcAddress(pCallbacks->hGdi32, "D3DKMTUnlock");543 Log((__FUNCTION__": pfnD3DKMTUnlock = %p\n", pCallbacks->pfnD3DKMTUnlock));544 bSupported &= !!(pCallbacks->pfnD3DKMTUnlock);545 546 /*Assert(bSupported);*/547 if (bSupported)548 {549 return S_OK;550 }551 else552 {553 Log((__FUNCTION__": one of pfnD3DKMT function pointers failed to initialize\n"));554 hr = E_NOINTERFACE;555 }556 557 FreeLibrary(pCallbacks->hGdi32);558 }559 else560 {561 DWORD winEr = GetLastError();562 hr = HRESULT_FROM_WIN32(winEr);563 Assert(0);564 Assert(hr != S_OK);565 Assert(hr != S_FALSE);566 if (hr == S_OK || hr == S_FALSE)567 hr = E_FAIL;568 }569 570 return hr;571 }572 573 HRESULT vboxDispKmtCallbacksTerm(PVBOXDISPKMT_CALLBACKS pCallbacks)574 {575 FreeLibrary(pCallbacks->hGdi32);576 return S_OK;577 }578 579 HRESULT vboxDispKmtAdpHdcCreate(HDC *phDc)580 {581 HRESULT hr = E_FAIL;582 DISPLAY_DEVICE DDev;583 memset(&DDev, 0, sizeof (DDev));584 DDev.cb = sizeof (DDev);585 586 *phDc = NULL;587 588 for (int i = 0; ; ++i)589 {590 if (EnumDisplayDevices(NULL, /* LPCTSTR lpDevice */ i, /* DWORD iDevNum */591 &DDev, 0 /* DWORD dwFlags*/))592 {593 if (DDev.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)594 {595 HDC hDc = CreateDC(NULL, DDev.DeviceName, NULL, NULL);596 if (hDc)597 {598 *phDc = hDc;599 return S_OK;600 }601 else602 {603 DWORD winEr = GetLastError();604 Assert(0);605 hr = HRESULT_FROM_WIN32(winEr);606 Assert(FAILED(hr));607 break;608 }609 }610 }611 else612 {613 DWORD winEr = GetLastError();614 #ifdef DEBUG_misha615 Assert(0);616 #endif617 Log((__FUNCTION__": EnumDisplayDevices failed, winEr (%d)\n", winEr));618 hr = HRESULT_FROM_WIN32(winEr);619 Assert(FAILED(hr));620 break;621 }622 }623 624 return hr;625 }626 627 HRESULT vboxDispKmtOpenAdapter(PVBOXDISPKMT_CALLBACKS pCallbacks, PVBOXDISPKMT_ADAPTER pAdapter)628 {629 D3DKMT_OPENADAPTERFROMHDC OpenAdapterData = {0};630 HRESULT hr = vboxDispKmtAdpHdcCreate(&OpenAdapterData.hDc);631 if (hr == S_OK)632 {633 Assert(OpenAdapterData.hDc);634 NTSTATUS Status = pCallbacks->pfnD3DKMTOpenAdapterFromHdc(&OpenAdapterData);635 #ifdef DEBUG_misha636 /* may fail with xpdm driver */637 Assert(!Status);638 #endif639 if (!Status)640 {641 pAdapter->hAdapter = OpenAdapterData.hAdapter;642 pAdapter->hDc = OpenAdapterData.hDc;643 pAdapter->pCallbacks = pCallbacks;644 return S_OK;645 }646 else647 {648 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName failed, Status (0x%x)\n", Status));649 hr = E_FAIL;650 }651 652 DeleteDC(OpenAdapterData.hDc);653 }654 655 return hr;656 }657 658 HRESULT vboxDispKmtCloseAdapter(PVBOXDISPKMT_ADAPTER pAdapter)659 {660 D3DKMT_CLOSEADAPTER ClosaAdapterData = {0};661 ClosaAdapterData.hAdapter = pAdapter->hAdapter;662 NTSTATUS Status = pAdapter->pCallbacks->pfnD3DKMTCloseAdapter(&ClosaAdapterData);663 Assert(!Status);664 if (!Status)665 {666 DeleteDC(pAdapter->hDc);667 return S_OK;668 }669 670 Log((__FUNCTION__": pfnD3DKMTCloseAdapter failed, Status (0x%x)\n", Status));671 672 return E_FAIL;673 }674 675 HRESULT vboxDispKmtCreateDevice(PVBOXDISPKMT_ADAPTER pAdapter, PVBOXDISPKMT_DEVICE pDevice)676 {677 D3DKMT_CREATEDEVICE CreateDeviceData = {0};678 CreateDeviceData.hAdapter = pAdapter->hAdapter;679 NTSTATUS Status = pAdapter->pCallbacks->pfnD3DKMTCreateDevice(&CreateDeviceData);680 Assert(!Status);681 if (!Status)682 {683 pDevice->pAdapter = pAdapter;684 pDevice->hDevice = CreateDeviceData.hDevice;685 pDevice->pCommandBuffer = CreateDeviceData.pCommandBuffer;686 pDevice->CommandBufferSize = CreateDeviceData.CommandBufferSize;687 pDevice->pAllocationList = CreateDeviceData.pAllocationList;688 pDevice->AllocationListSize = CreateDeviceData.AllocationListSize;689 pDevice->pPatchLocationList = CreateDeviceData.pPatchLocationList;690 pDevice->PatchLocationListSize = CreateDeviceData.PatchLocationListSize;691 692 return S_OK;693 }694 695 return E_FAIL;696 }697 698 HRESULT vboxDispKmtDestroyDevice(PVBOXDISPKMT_DEVICE pDevice)699 {700 D3DKMT_DESTROYDEVICE DestroyDeviceData = {0};701 DestroyDeviceData.hDevice = pDevice->hDevice;702 NTSTATUS Status = pDevice->pAdapter->pCallbacks->pfnD3DKMTDestroyDevice(&DestroyDeviceData);703 Assert(!Status);704 if (!Status)705 {706 return S_OK;707 }708 return E_FAIL;709 }710 711 HRESULT vboxDispKmtCreateContext(PVBOXDISPKMT_DEVICE pDevice, PVBOXDISPKMT_CONTEXT pContext,712 VBOXWDDM_CONTEXT_TYPE enmType, HANDLE hEvent, uint64_t u64UmInfo)713 {714 VBOXWDDM_CREATECONTEXT_INFO Info = {0};715 Info.u32IfVersion = 9;716 Info.enmType = enmType;717 Info.hUmEvent = (uint64_t)hEvent;718 Info.u64UmInfo = u64UmInfo;719 D3DKMT_CREATECONTEXT ContextData = {0};720 ContextData.hDevice = pDevice->hDevice;721 ContextData.NodeOrdinal = 0;722 ContextData.EngineAffinity = 0;723 ContextData.pPrivateDriverData = &Info;724 ContextData.PrivateDriverDataSize = sizeof (Info);725 ContextData.ClientHint = enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL ? D3DKMT_CLIENTHINT_OPENGL : D3DKMT_CLIENTHINT_DX9;726 NTSTATUS Status = pDevice->pAdapter->pCallbacks->pfnD3DKMTCreateContext(&ContextData);727 Assert(!Status);728 if (!Status)729 {730 pContext->pDevice = pDevice;731 pContext->hContext = ContextData.hContext;732 pContext->pCommandBuffer = ContextData.pCommandBuffer;733 pContext->CommandBufferSize = ContextData.CommandBufferSize;734 pContext->pAllocationList = ContextData.pAllocationList;735 pContext->AllocationListSize = ContextData.AllocationListSize;736 pContext->pPatchLocationList = ContextData.pPatchLocationList;737 pContext->PatchLocationListSize = ContextData.PatchLocationListSize;738 return S_OK;739 }740 return E_FAIL;741 }742 743 HRESULT vboxDispKmtDestroyContext(PVBOXDISPKMT_CONTEXT pContext)744 {745 D3DKMT_DESTROYCONTEXT DestroyContextData = {0};746 DestroyContextData.hContext = pContext->hContext;747 NTSTATUS Status = pContext->pDevice->pAdapter->pCallbacks->pfnD3DKMTDestroyContext(&DestroyContextData);748 Assert(!Status);749 if (!Status)750 return S_OK;751 return E_FAIL;752 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiKmt.h
r34345 r35650 19 19 #include "VBoxDispD3DCmn.h" 20 20 21 #include <D3dkmthk.h>22 23 typedef struct VBOXDISPKMT_CALLBACKS24 {25 HMODULE hGdi32;26 /* open adapter */27 PFND3DKMT_OPENADAPTERFROMHDC pfnD3DKMTOpenAdapterFromHdc;28 PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME pfnD3DKMTOpenAdapterFromGdiDisplayName;29 /* close adapter */30 PFND3DKMT_CLOSEADAPTER pfnD3DKMTCloseAdapter;31 /* escape */32 PFND3DKMT_ESCAPE pfnD3DKMTEscape;33 34 PFND3DKMT_CREATEDEVICE pfnD3DKMTCreateDevice;35 PFND3DKMT_DESTROYDEVICE pfnD3DKMTDestroyDevice;36 PFND3DKMT_CREATECONTEXT pfnD3DKMTCreateContext;37 PFND3DKMT_DESTROYCONTEXT pfnD3DKMTDestroyContext;38 39 PFND3DKMT_RENDER pfnD3DKMTRender;40 41 PFND3DKMT_CREATEALLOCATION pfnD3DKMTCreateAllocation;42 PFND3DKMT_DESTROYALLOCATION pfnD3DKMTDestroyAllocation;43 44 PFND3DKMT_LOCK pfnD3DKMTLock;45 PFND3DKMT_UNLOCK pfnD3DKMTUnlock;46 } VBOXDISPKMT_CALLBACKS, *PVBOXDISPKMT_CALLBACKS;47 48 HRESULT vboxDispKmtCallbacksInit(PVBOXDISPKMT_CALLBACKS pCallbacks);49 HRESULT vboxDispKmtCallbacksTerm(PVBOXDISPKMT_CALLBACKS pCallbacks);50 51 typedef struct VBOXDISPKMT_ADAPTER52 {53 D3DKMT_HANDLE hAdapter;54 HDC hDc;55 PVBOXDISPKMT_CALLBACKS pCallbacks;56 }VBOXDISPKMT_ADAPTER, *PVBOXDISPKMT_ADAPTER;57 58 typedef struct VBOXDISPKMT_DEVICE59 {60 struct VBOXDISPKMT_ADAPTER *pAdapter;61 D3DKMT_HANDLE hDevice;62 VOID *pCommandBuffer;63 UINT CommandBufferSize;64 D3DDDI_ALLOCATIONLIST *pAllocationList;65 UINT AllocationListSize;66 D3DDDI_PATCHLOCATIONLIST *pPatchLocationList;67 UINT PatchLocationListSize;68 }VBOXDISPKMT_DEVICE, *PVBOXDISPKMT_DEVICE;69 70 typedef struct VBOXDISPKMT_CONTEXT71 {72 struct VBOXDISPKMT_DEVICE *pDevice;73 D3DKMT_HANDLE hContext;74 VOID *pCommandBuffer;75 UINT CommandBufferSize;76 D3DDDI_ALLOCATIONLIST *pAllocationList;77 UINT AllocationListSize;78 D3DDDI_PATCHLOCATIONLIST *pPatchLocationList;79 UINT PatchLocationListSize;80 } VBOXDISPKMT_CONTEXT, *PVBOXDISPKMT_CONTEXT;81 21 82 22 typedef struct VBOXUHGSMI_PRIVATE_KMT … … 92 32 #define VBOXUHGSMIKMT_GET(_p) VBOXUHGSMIKMT_GET_PRIVATE(_p, VBOXUHGSMI_PRIVATE_KMT) 93 33 94 HRESULT vboxDispKmtOpenAdapter(PVBOXDISPKMT_CALLBACKS pCallbacks, PVBOXDISPKMT_ADAPTER pAdapter);95 HRESULT vboxDispKmtCloseAdapter(PVBOXDISPKMT_ADAPTER pAdapter);96 HRESULT vboxDispKmtCreateDevice(PVBOXDISPKMT_ADAPTER pAdapter, PVBOXDISPKMT_DEVICE pDevice);97 HRESULT vboxDispKmtDestroyDevice(PVBOXDISPKMT_DEVICE pDevice);98 HRESULT vboxDispKmtCreateContext(PVBOXDISPKMT_DEVICE pDevice, PVBOXDISPKMT_CONTEXT pContext,99 VBOXWDDM_CONTEXT_TYPE enmType, HANDLE hEvent, uint64_t u64UmInfo);100 HRESULT vboxDispKmtDestroyContext(PVBOXDISPKMT_CONTEXT pContext);101 102 34 HRESULT vboxUhgsmiKmtCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D); 103 35 HRESULT vboxUhgsmiKmtDestroy(PVBOXUHGSMI_PRIVATE_KMT pHgsmi); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/cubetexture.c
r33836 r35650 404 404 #ifdef VBOX_WITH_WDDM 405 405 , HANDLE *shared_handle 406 , void * pvClientMem406 , void **pavClientMem 407 407 #endif 408 408 ) … … 418 418 wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture, 419 419 (IUnknown *)texture, &d3d9_cubetexture_wined3d_parent_ops, 420 shared_handle, p vClientMem);420 shared_handle, pavClientMem); 421 421 #else 422 422 hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage, -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/d3d9_private.h
r33836 r35650 417 417 #ifdef VBOX_WITH_WDDM 418 418 , HANDLE *shared_handle 419 , void * pvClientMem419 , void **pavClientMem 420 420 #endif 421 421 ) DECLSPEC_HIDDEN; … … 445 445 #ifdef VBOX_WITH_WDDM 446 446 , HANDLE *shared_handle 447 , void * pvClientMem447 , void **pavClientMem 448 448 #endif 449 449 ) DECLSPEC_HIDDEN; -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/device.c
r33836 r35650 768 768 UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, 769 769 D3DPOOL pool, IDirect3DTexture9 **texture, HANDLE *shared_handle, 770 void * pvClientMem) /* <- extension arg to pass in the client memory buffer,770 void **pavClientMem) /* <- extension arg to pass in the client memory buffer, 771 771 * applicable ONLY for SYSMEM textures */ 772 772 { … … 787 787 hr = texture_init(object, This, width, height, levels, usage, format, pool 788 788 , shared_handle 789 , p vClientMem789 , pavClientMem 790 790 ); 791 791 if (FAILED(hr)) … … 812 812 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, 813 813 D3DPOOL pool, IDirect3DCubeTexture9 **texture, HANDLE *shared_handle, 814 void * pvClientMem) /* <- extension arg to pass in the client memory buffer,814 void **pavClientMem) /* <- extension arg to pass in the client memory buffer, 815 815 * applicable ONLY for SYSMEM textures */ 816 816 { … … 829 829 } 830 830 831 hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool, shared_handle, p vClientMem);831 hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool, shared_handle, pavClientMem); 832 832 if (FAILED(hr)) 833 833 { -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/texture.c
r33656 r35650 401 401 #ifdef VBOX_WITH_WDDM 402 402 , HANDLE *shared_handle 403 , void * pvClientMem403 , void **pavClientMem 404 404 #endif 405 405 ) … … 416 416 &texture->wineD3DTexture, (IUnknown *)texture, &d3d9_texture_wined3d_parent_ops 417 417 , shared_handle 418 , p vClientMem);418 , pavClientMem); 419 419 #else 420 420 hr = IWineD3DDevice_CreateTexture(device->WineD3DDevice, width, height, levels, -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/wined3d.h
r33836 r35650 7408 7408 #ifdef VBOX_WITH_WDDM 7409 7409 , HANDLE *shared_handle 7410 , void * pvClientMem7410 , void **pavClientMem 7411 7411 #endif 7412 7412 ); … … 7449 7449 #ifdef VBOX_WITH_WDDM 7450 7450 , HANDLE *shared_handle 7451 , void * pvClientMem7451 , void **pavClientMem 7452 7452 #endif 7453 7453 ); … … 8115 8115 #define IWineD3DDevice_CreateRendertargetView(This,resource,parent,rendertarget_view) (This)->lpVtbl->CreateRendertargetView(This,resource,parent,rendertarget_view) 8116 8116 #ifdef VBOX_WITH_WDDM 8117 #define IWineD3DDevice_CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,p vClientMem) (This)->lpVtbl->CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pvClientMem)8117 #define IWineD3DDevice_CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) (This)->lpVtbl->CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) 8118 8118 #else 8119 8119 #define IWineD3DDevice_CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops) (This)->lpVtbl->CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops) … … 8122 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 8123 #ifdef VBOX_WITH_WDDM 8124 #define IWineD3DDevice_CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,p vClientMem) (This)->lpVtbl->CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pvClientMem)8124 #define IWineD3DDevice_CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) (This)->lpVtbl->CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) 8125 8125 #else 8126 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) -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/VBoxWineEx.h
r33836 r35650 25 25 UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, 26 26 D3DPOOL pool, IDirect3DTexture9 **texture, HANDLE *shared_handle, 27 void * pvClientMem);27 void **pavClientMem); 28 28 typedef FNVBOXWINEEXD3DDEV9_CREATETEXTURE *PFNVBOXWINEEXD3DDEV9_CREATETEXTURE; 29 29 … … 31 31 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, 32 32 D3DPOOL pool, IDirect3DCubeTexture9 **texture, HANDLE *shared_handle, 33 void * pvClientMem);33 void **pavClientMem); 34 34 typedef FNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE *PFNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE; 35 35 … … 47 47 UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, 48 48 D3DPOOL pool, IDirect3DTexture9 **texture, HANDLE *shared_handle, 49 void * pvClientMem); /* <- extension arg to pass in the client memory buffer,49 void **pavClientMem); /* <- extension arg to pass in the client memory buffer, 50 50 * applicable ONLY for SYSMEM textures */ 51 51 … … 53 53 UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, 54 54 D3DPOOL pool, IDirect3DCubeTexture9 **texture, HANDLE *shared_handle, 55 void * pvClientMem); /* <- extension arg to pass in the client memory buffer,55 void **pavClientMem); /* <- extension arg to pass in the client memory buffer, 56 56 * applicable ONLY for SYSMEM textures */ 57 57 -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/vbox/libWineStub/include/wine/wined3d.h
r35332 r35650 7410 7410 #ifdef VBOX_WITH_WDDM 7411 7411 , HANDLE *shared_handle 7412 , void * pvClientMem7412 , void **pavClientMem 7413 7413 #endif 7414 7414 ); … … 7451 7451 #ifdef VBOX_WITH_WDDM 7452 7452 , HANDLE *shared_handle 7453 , void * pvClientMem7453 , void **pavClientMem 7454 7454 #endif 7455 7455 ); … … 8117 8117 #define IWineD3DDevice_CreateRendertargetView(This,resource,parent,rendertarget_view) (This)->lpVtbl->CreateRendertargetView(This,resource,parent,rendertarget_view) 8118 8118 #ifdef VBOX_WITH_WDDM 8119 #define IWineD3DDevice_CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,p vClientMem) (This)->lpVtbl->CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pvClientMem)8119 #define IWineD3DDevice_CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) (This)->lpVtbl->CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) 8120 8120 #else 8121 8121 #define IWineD3DDevice_CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops) (This)->lpVtbl->CreateTexture(This,width,height,levels,usage,format,pool,texture,parent,parent_ops) … … 8124 8124 #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) 8125 8125 #ifdef VBOX_WITH_WDDM 8126 #define IWineD3DDevice_CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,p vClientMem) (This)->lpVtbl->CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pvClientMem)8126 #define IWineD3DDevice_CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) (This)->lpVtbl->CreateCubeTexture(This,edge_length,levels,usage,format,pool,texture,parent,parent_ops,shared_handle,pavClientMem) 8127 8127 #else 8128 8128 #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) -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c
r33732 r35650 42 42 #ifdef VBOX_WITH_WDDM 43 43 , HANDLE *shared_handle 44 , void * pvClientMem44 , void **pavClientMem 45 45 #endif 46 46 ) … … 57 57 size, usage, format_desc, pool, parent, parent_ops 58 58 #ifdef VBOX_WITH_WDDM 59 , shared_handle, p vClientMem59 , shared_handle, pavClientMem ? pavClientMem[0] : NULL /* <- @todo: should be always NULL ? */ 60 60 #endif 61 61 ); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c
r33836 r35650 443 443 #ifdef VBOX_WITH_WDDM 444 444 , HANDLE *shared_handle 445 , void * pvClientMem445 , void **pavClientMem 446 446 #endif 447 447 ) … … 496 496 device, 0, usage, format_desc, pool, parent, parent_ops 497 497 #ifdef VBOX_WITH_WDDM 498 , shared_handle, p vClientMem498 , shared_handle, pavClientMem 499 499 #endif 500 500 ); … … 547 547 hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w, 548 548 format, usage, pool, i /* Level */, j, &texture->surfaces[j][i] 549 , NULL, p vClientMem549 , NULL, pavClientMem ? pavClientMem[i * 6 + j] : NULL 550 550 ); 551 551 #else -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c
r34304 r35650 881 881 #ifdef VBOX_WITH_WDDM 882 882 , HANDLE *shared_handle 883 , void * pvClientMem883 , void **pavClientMem 884 884 #endif 885 885 ) … … 904 904 #ifdef VBOX_WITH_WDDM 905 905 , shared_handle 906 , p vClientMem906 , pavClientMem 907 907 #endif 908 908 ); … … 994 994 #ifdef VBOX_WITH_WDDM 995 995 , HANDLE *shared_handle 996 , void * pvClientMem996 , void **pavClientMem 997 997 #endif 998 998 ) … … 1013 1013 #ifdef VBOX_WITH_WDDM 1014 1014 , shared_handle 1015 , p vClientMem1015 , pavClientMem 1016 1016 #endif 1017 1017 ); -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c
r33656 r35650 444 444 #ifdef VBOX_WITH_WDDM 445 445 , HANDLE *shared_handle 446 , void * pvClientMem446 , void **pavClientMem 447 447 #endif 448 448 ) … … 515 515 device, 0, usage, format_desc, pool, parent, parent_ops 516 516 #ifdef VBOX_WITH_WDDM 517 , shared_handle, p vClientMem517 , shared_handle, pavClientMem 518 518 #endif 519 519 ); … … 593 593 * this is done this way because the surface does not have its parent (texture) setup properly 594 594 * thus we can not initialize texture at this stage */ 595 , p vClientMem);595 , pavClientMem ? pavClientMem[i] : NULL); 596 596 597 597 #else -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h
r34987 r35650 1952 1952 #ifdef VBOX_WITH_WDDM 1953 1953 , HANDLE *shared_handle 1954 , void * pvClientMem1954 , void **pavClientMem 1955 1955 #endif 1956 1956 ) DECLSPEC_HIDDEN; … … 1983 1983 #ifdef VBOX_WITH_WDDM 1984 1984 , HANDLE *shared_handle 1985 , void * pvClientMem1985 , void **pavClientMem 1986 1986 #endif 1987 1987 ) DECLSPEC_HIDDEN; … … 2006 2006 #ifdef VBOX_WITH_WDDM 2007 2007 , HANDLE *shared_handle 2008 , void * pvClientMem2008 , void **pavClientMem 2009 2009 #endif 2010 2010 ) DECLSPEC_HIDDEN;
Note:
See TracChangeset
for help on using the changeset viewer.