Changeset 30042 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- Jun 4, 2010 4:43:47 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r30038 r30042 856 856 } 857 857 858 static D3DFORMAT vbox FormatDDI2D3D(D3DDDIFORMAT format)858 static D3DFORMAT vboxDDI2D3DFormat(D3DDDIFORMAT format) 859 859 { 860 860 /* @todo: check they are all equal */ 861 861 return (D3DFORMAT)format; 862 } 863 864 D3DMULTISAMPLE_TYPE vboxDDI2D3DMultiSampleType(D3DDDIMULTISAMPLE_TYPE enmType) 865 { 866 /* @todo: check they are all equal */ 867 return (D3DMULTISAMPLE_TYPE)enmType; 862 868 } 863 869 … … 1592 1598 if (VBOXDISPMODE_IS_3D(pAdapter)) 1593 1599 { 1594 if (pResource->Flags.RenderTarget) 1595 { 1596 HWND hWnd = NULL; 1597 Assert(pResource->SurfCount); 1598 Assert(!pDevice->pDevice9If); 1599 Assert(!pDevice->hWnd); 1600 hr = VBoxDispWndCreate(pAdapter, pResource->pSurfList[0].Width, pResource->pSurfList[0].Height, &hWnd); 1601 Assert(hr == S_OK); 1602 if (hr == S_OK) 1603 { 1604 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 1605 if (pDevice->fFlags.AllowMultithreading) 1606 fFlags |= D3DCREATE_MULTITHREADED; 1607 1608 IDirect3DDevice9 *pDevice9If = NULL; 1609 D3DPRESENT_PARAMETERS params; 1610 memset(¶ms, 0, sizeof (params)); 1611 // params.BackBufferWidth = 0; 1612 // params.BackBufferHeight = 0; 1613 params.BackBufferFormat = vboxFormatDDI2D3D(pResource->Format); 1600 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pResource->SurfCount); 1601 Assert(pRc); 1602 if (pRc) 1603 { 1604 pRc->hResource = pResource->hResource; 1605 pRc->pDevice = pDevice; 1606 pRc->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC; 1607 vboxResourcePopulateRcDesc(&pRc->RcDesc, pResource); 1608 pRc->cAllocations = pResource->SurfCount; 1609 for (UINT i = 0; i < pResource->SurfCount; ++i) 1610 { 1611 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1612 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 1613 pAllocation->hAllocation = NULL; 1614 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; 1615 pAllocation->pvMem = pSurf->pSysMem; 1616 pAllocation->SurfDesc.pitch = pSurf->SysMemPitch; 1617 pAllocation->SurfDesc.slicePitch = pSurf->SysMemSlicePitch; 1618 pAllocation->SurfDesc.depth = pSurf->Depth; 1619 pAllocation->SurfDesc.width = pSurf->Width; 1620 pAllocation->SurfDesc.height = pSurf->Height; 1621 pAllocation->SurfDesc.format = pResource->Format; 1622 } 1623 1624 if (pResource->Flags.RenderTarget) 1625 { 1626 HWND hWnd = NULL; 1614 1627 Assert(pResource->SurfCount); 1615 params.BackBufferCount = pResource->SurfCount - 1; 1616 params.MultiSampleType = D3DMULTISAMPLE_NONE; 1617 if (pResource->Flags.DiscardRenderTarget) 1618 params.SwapEffect = D3DSWAPEFFECT_DISCARD; 1619 params.hDeviceWindow = hWnd; 1620 /* @todo: it seems there should be a way to detect this correctly since 1621 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */ 1622 params.Windowed = TRUE; 1623 // params.EnableAutoDepthStencil = FALSE; 1624 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN; 1625 // params.Flags; 1626 // params.FullScreen_RefreshRateInHz; 1627 // params.FullScreen_PresentationInterval; 1628 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, fFlags, ¶ms, &pDevice9If); 1628 Assert(!pDevice->pDevice9If); 1629 Assert(!pDevice->hWnd); 1630 hr = VBoxDispWndCreate(pAdapter, pResource->pSurfList[0].Width, pResource->pSurfList[0].Height, &hWnd); 1629 1631 Assert(hr == S_OK); 1630 1632 if (hr == S_OK) 1631 1633 { 1632 pDevice->pDevice9If = pDevice9If; 1633 pDevice->hWnd = hWnd; 1634 } 1635 else 1636 { 1637 VBoxDispWndDestroy(pAdapter, hWnd); 1634 DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; 1635 if (pDevice->fFlags.AllowMultithreading) 1636 fFlags |= D3DCREATE_MULTITHREADED; 1637 1638 IDirect3DDevice9 *pDevice9If = NULL; 1639 D3DPRESENT_PARAMETERS params; 1640 memset(¶ms, 0, sizeof (params)); 1641 // params.BackBufferWidth = 0; 1642 // params.BackBufferHeight = 0; 1643 params.BackBufferFormat = vboxDDI2D3DFormat(pResource->Format); 1644 Assert(pResource->SurfCount); 1645 params.BackBufferCount = pResource->SurfCount - 1; 1646 params.MultiSampleType = vboxDDI2D3DMultiSampleType(pResource->MultisampleType); 1647 if (pResource->Flags.DiscardRenderTarget) 1648 params.SwapEffect = D3DSWAPEFFECT_DISCARD; 1649 params.hDeviceWindow = hWnd; 1650 /* @todo: it seems there should be a way to detect this correctly since 1651 * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */ 1652 params.Windowed = TRUE; 1653 // params.EnableAutoDepthStencil = FALSE; 1654 // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN; 1655 // params.Flags; 1656 // params.FullScreen_RefreshRateInHz; 1657 // params.FullScreen_PresentationInterval; 1658 hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, fFlags, ¶ms, &pDevice9If); 1659 Assert(hr == S_OK); 1660 if (hr == S_OK) 1661 { 1662 pDevice->pDevice9If = pDevice9If; 1663 pDevice->hWnd = hWnd; 1664 } 1665 else 1666 { 1667 VBoxDispWndDestroy(pAdapter, hWnd); 1668 } 1638 1669 } 1639 1670 } 1640 } 1641 else 1642 { 1643 Assert(pDevice->pDevice9If); 1644 } 1645 1646 if (hr == S_OK) 1647 { 1648 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pResource->SurfCount); 1649 Assert(pRc); 1650 if (pRc) 1651 { 1652 pRc->hResource = pResource->hResource; 1653 pRc->pDevice = pDevice; 1654 pRc->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC; 1655 vboxResourcePopulateRcDesc(&pRc->RcDesc, pResource); 1656 pRc->cAllocations = pResource->SurfCount; 1671 else if (pResource->Flags.ZBuffer) 1672 { 1673 Assert(pDevice->pDevice9If); 1657 1674 for (UINT i = 0; i < pResource->SurfCount; ++i) 1658 1675 { 1659 1676 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 1660 1677 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 1661 pAllocation->hAllocation = NULL; 1662 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; 1663 pAllocation->pvMem = pSurf->pSysMem; 1664 pAllocation->SurfDesc.pitch = pSurf->SysMemPitch; 1665 pAllocation->SurfDesc.slicePitch = pSurf->SysMemSlicePitch; 1666 pAllocation->SurfDesc.depth = pSurf->Depth; 1667 pAllocation->SurfDesc.width = pSurf->Width; 1668 pAllocation->SurfDesc.height = pSurf->Height; 1669 pAllocation->SurfDesc.format = pResource->Format; 1678 IDirect3DSurface9 *pD3D9Surf; 1679 hr = pDevice->pDevice9If->CreateDepthStencilSurface(pSurf->Width, 1680 pSurf->Height, 1681 vboxDDI2D3DFormat(pResource->Format), 1682 vboxDDI2D3DMultiSampleType(pResource->MultisampleType), 1683 pResource->MultisampleQuality, 1684 TRUE /* @todo: BOOL Discard */, 1685 &pD3D9Surf, 1686 NULL /*HANDLE* pSharedHandle*/); 1687 Assert(hr == S_OK); 1688 if (hr == S_OK) 1689 { 1690 Assert(pD3D9Surf); 1691 pAllocation->pD3DIf = pD3D9Surf; 1692 } 1693 else 1694 { 1695 for (UINT j = 0; j < i; ++j) 1696 { 1697 pRc->aAllocations[j].pD3DIf->Release(); 1698 } 1699 break; 1700 } 1670 1701 } 1671 1672 pResource->hResource = pRc;1673 // vboxResourceFree(pRc);1674 1702 } 1675 1703 else 1676 1704 { 1677 hr = E_OUTOFMEMORY;1705 Assert(pDevice->pDevice9If); 1678 1706 } 1707 1708 if (hr == S_OK) 1709 pResource->hResource = pRc; 1710 else 1711 vboxResourceFree(pRc); 1679 1712 } 1713 else 1714 { 1715 hr = E_OUTOFMEMORY; 1716 } 1717 1680 1718 } 1681 1719 else … … 1827 1865 HRESULT tmpHr = VBoxDispWndDestroy(pAdapter, pDevice->hWnd); 1828 1866 Assert(tmpHr == S_OK); 1867 } 1868 1869 for (UINT i = 0; i < pRc->cAllocations; ++i) 1870 { 1871 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i]; 1872 if (pAlloc->pD3DIf) 1873 pAlloc->pD3DIf->Release(); 1829 1874 } 1830 1875 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h
r30038 r30042 82 82 VBOXWDDM_ALLOC_TYPE enmType; 83 83 CONST VOID* pvMem; 84 /* object type depends on resource type */ 85 IUnknown *pD3DIf; 84 86 VBOXWDDM_SURFACE_DESC SurfDesc; 85 87 } VBOXWDDMDISP_ALLOCATION, *PVBOXWDDMDISP_ALLOCATION;
Note:
See TracChangeset
for help on using the changeset viewer.