Changeset 30986 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
- Timestamp:
- Jul 22, 2010 12:48:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r30978 r30986 1403 1403 } 1404 1404 1405 static HRESULT vboxWddmGetD3D9Caps(PVBOXWDDMDISP_ADAPTER pAdapter, D3DCAPS9 *pCaps) 1406 { 1407 HRESULT hr = pAdapter->pD3D9If->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pCaps); 1408 Assert(hr == S_OK); 1409 if (hr == S_OK) 1410 { 1411 pCaps->Caps2 |= D3DCAPS2_CANSHARERESOURCE | 0x00080000 /*D3DCAPS2_CANRENDERWINDOWED*/; 1412 pCaps->DevCaps |= D3DDEVCAPS_FLOATTLVERTEX /* <- must be set according to the docs */ 1413 /*| D3DDEVCAPS_HWVERTEXBUFFER | D3DDEVCAPS_HWINDEXBUFFER | D3DDEVCAPS_SUBVOLUMELOCK */; 1414 pCaps->PrimitiveMiscCaps |= D3DPMISCCAPS_INDEPENDENTWRITEMASKS 1415 | D3DPMISCCAPS_FOGINFVF 1416 | D3DPMISCCAPS_SEPARATEALPHABLEND | D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS; 1417 pCaps->RasterCaps |= D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ZBIAS | D3DPRASTERCAPS_COLORPERSPECTIVE /* keep */; 1418 pCaps->TextureCaps |= D3DPTEXTURECAPS_TRANSPARENCY | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE; 1419 pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE; 1420 pCaps->VolumeTextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE; 1421 pCaps->GuardBandLeft = -8192.; 1422 pCaps->GuardBandTop = -8192.; 1423 pCaps->GuardBandRight = 8192.; 1424 pCaps->GuardBandBottom = 8192.; 1425 pCaps->StencilCaps |= D3DSTENCILCAPS_TWOSIDED; 1426 pCaps->DeclTypes |= D3DDTCAPS_FLOAT16_2 | D3DDTCAPS_FLOAT16_4; 1427 pCaps->VS20Caps.DynamicFlowControlDepth = 24; 1428 pCaps->VS20Caps.NumTemps = D3DVS20_MAX_NUMTEMPS; 1429 pCaps->PS20Caps.DynamicFlowControlDepth = 24; 1430 pCaps->PS20Caps.NumTemps = D3DVS20_MAX_NUMTEMPS; 1431 pCaps->VertexTextureFilterCaps |= D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MAGFPOINT; 1432 #if 1 /* workaround for wine not returning InstructionSlots correctly for shaders v3.0 */ 1433 if ((pCaps->VertexShaderVersion & 0xff00) == 0x0300) 1434 { 1435 pCaps->MaxVertexShader30InstructionSlots = RT_MIN(32768, pCaps->MaxVertexShader30InstructionSlots); 1436 pCaps->MaxPixelShader30InstructionSlots = RT_MIN(32768, pCaps->MaxPixelShader30InstructionSlots); 1437 } 1438 #endif 1439 #ifdef DEBUG 1440 if ((pCaps->VertexShaderVersion & 0xff00) == 0x0300) 1441 { 1442 Assert(pCaps->MaxVertexShader30InstructionSlots >= 512); 1443 Assert(pCaps->MaxVertexShader30InstructionSlots <= 32768); 1444 Assert(pCaps->MaxPixelShader30InstructionSlots >= 512); 1445 Assert(pCaps->MaxPixelShader30InstructionSlots <= 32768); 1446 } 1447 else if ((pCaps->VertexShaderVersion & 0xff00) == 0x0200) 1448 { 1449 Assert(pCaps->MaxVertexShader30InstructionSlots == 0); 1450 Assert(pCaps->MaxPixelShader30InstructionSlots == 0); 1451 } 1452 else 1453 { 1454 Assert(0); 1455 } 1456 #endif 1457 } 1458 1459 return hr; 1460 } 1461 1405 1462 static HRESULT APIENTRY vboxWddmDispGetCaps (HANDLE hAdapter, CONST D3DDDIARG_GETCAPS* pData) 1406 1463 { … … 1591 1648 case D3DDDICAPS_GETD3D9CAPS: 1592 1649 { 1593 Assert(pData->DataSize >= sizeof (D3DCAPS9));1650 Assert(pData->DataSize == sizeof (D3DCAPS9)); 1594 1651 // Assert(0); 1595 1652 if (pData->DataSize >= sizeof (D3DCAPS9)) … … 1599 1656 { 1600 1657 D3DCAPS9* pCaps = (D3DCAPS9*)pData->pData; 1601 hr = pAdapter->pD3D9If->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pCaps); 1658 hr = vboxWddmGetD3D9Caps(pAdapter, pCaps); 1659 Assert(hr == S_OK); 1660 if (hr == S_OK) 1661 break; 1662 1663 vboxVDbgPrintR((__FUNCTION__": GetDeviceCaps Failed hr(%d)\n", hr)); 1664 /* let's fall back to the 3D disabled case */ 1665 hr = S_OK; 1666 } 1667 1668 memset(pData->pData, 0, sizeof (D3DCAPS9)); 1669 } 1670 else 1671 hr = E_INVALIDARG; 1672 break; 1673 } 1674 case D3DDDICAPS_GETD3D8CAPS: 1675 { 1676 Assert(pData->DataSize == RT_OFFSETOF(D3DCAPS9, DevCaps2)); 1677 if (pData->DataSize == RT_OFFSETOF(D3DCAPS9, DevCaps2)) 1678 { 1679 Assert(VBOXDISPMODE_IS_3D(pAdapter)); 1680 if (VBOXDISPMODE_IS_3D(pAdapter)) 1681 { 1682 D3DCAPS9 Caps9; 1683 hr = vboxWddmGetD3D9Caps(pAdapter, &Caps9); 1602 1684 Assert(hr == S_OK); 1603 1685 if (hr == S_OK) 1604 1686 { 1605 pCaps->Caps2 |= D3DCAPS2_CANSHARERESOURCE | 0x00080000 /*D3DCAPS2_CANRENDERWINDOWED*/; 1606 pCaps->DevCaps |= D3DDEVCAPS_FLOATTLVERTEX /* <- must be set according to the docs */ 1607 /*| D3DDEVCAPS_HWVERTEXBUFFER | D3DDEVCAPS_HWINDEXBUFFER | D3DDEVCAPS_SUBVOLUMELOCK */; 1608 pCaps->PrimitiveMiscCaps |= D3DPMISCCAPS_INDEPENDENTWRITEMASKS 1609 | D3DPMISCCAPS_FOGINFVF 1610 | D3DPMISCCAPS_SEPARATEALPHABLEND | D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS; 1611 pCaps->RasterCaps |= D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ZBIAS | D3DPRASTERCAPS_COLORPERSPECTIVE /* keep */; 1612 pCaps->TextureCaps |= D3DPTEXTURECAPS_TRANSPARENCY | D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE; 1613 pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE; 1614 pCaps->VolumeTextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE; 1615 pCaps->GuardBandLeft = -8192.; 1616 pCaps->GuardBandTop = -8192.; 1617 pCaps->GuardBandRight = 8192.; 1618 pCaps->GuardBandBottom = 8192.; 1619 pCaps->StencilCaps |= D3DSTENCILCAPS_TWOSIDED; 1620 pCaps->DeclTypes |= D3DDTCAPS_FLOAT16_2 | D3DDTCAPS_FLOAT16_4; 1621 pCaps->VS20Caps.DynamicFlowControlDepth = 24; 1622 pCaps->VS20Caps.NumTemps = D3DVS20_MAX_NUMTEMPS; 1623 pCaps->PS20Caps.DynamicFlowControlDepth = 24; 1624 pCaps->PS20Caps.NumTemps = D3DVS20_MAX_NUMTEMPS; 1625 pCaps->VertexTextureFilterCaps |= D3DPTFILTERCAPS_MINFPOINT | D3DPTFILTERCAPS_MAGFPOINT; 1626 #if 1 /* workaround for wine not returning InstructionSlots correctly for shaders v3.0 */ 1627 if ((pCaps->VertexShaderVersion & 0xff00) == 0x0300) 1628 { 1629 pCaps->MaxVertexShader30InstructionSlots = RT_MIN(32768, pCaps->MaxVertexShader30InstructionSlots); 1630 pCaps->MaxPixelShader30InstructionSlots = RT_MIN(32768, pCaps->MaxPixelShader30InstructionSlots); 1631 } 1632 #endif 1633 #ifdef DEBUG 1634 if ((pCaps->VertexShaderVersion & 0xff00) == 0x0300) 1635 { 1636 Assert(pCaps->MaxVertexShader30InstructionSlots >= 512); 1637 Assert(pCaps->MaxVertexShader30InstructionSlots <= 32768); 1638 Assert(pCaps->MaxPixelShader30InstructionSlots >= 512); 1639 Assert(pCaps->MaxPixelShader30InstructionSlots <= 32768); 1640 } 1641 else if ((pCaps->VertexShaderVersion & 0xff00) == 0x0200) 1642 { 1643 Assert(pCaps->MaxVertexShader30InstructionSlots == 0); 1644 Assert(pCaps->MaxPixelShader30InstructionSlots == 0); 1645 } 1646 else 1647 { 1648 Assert(0); 1649 } 1650 #endif 1687 memcpy(pData->pData, &Caps9, RT_OFFSETOF(D3DCAPS9, DevCaps2)); 1651 1688 break; 1652 1689 } 1653 1690 1654 vboxVDbgPrintR((__FUNCTION__": GetDeviceCaps hr(%d)\n", hr));1691 vboxVDbgPrintR((__FUNCTION__": GetDeviceCaps Failed hr(%d)\n", hr)); 1655 1692 /* let's fall back to the 3D disabled case */ 1656 1693 hr = S_OK; 1657 1694 } 1658 1695 1659 memset(pData->pData, 0, sizeof (D3DCAPS9));1660 1696 } 1661 1697 else … … 1676 1712 case D3DDDICAPS_GETD3D5CAPS: 1677 1713 case D3DDDICAPS_GETD3D6CAPS: 1678 case D3DDDICAPS_GETD3D8CAPS:1679 1714 case D3DDDICAPS_GETDECODEGUIDS: 1680 1715 case D3DDDICAPS_GETDECODERTFORMATCOUNT: … … 2558 2593 static HRESULT APIENTRY vboxWddmDDevGetInfo(HANDLE hDevice, UINT DevInfoID, VOID* pDevInfoStruct, UINT DevInfoSize) 2559 2594 { 2560 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 2561 Assert(0); 2562 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 2563 return E_NOTIMPL; 2595 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 2596 HRESULT hr = S_OK; 2597 switch (DevInfoID) 2598 { 2599 case D3DDDIDEVINFOID_VCACHE: 2600 { 2601 Assert(DevInfoSize == sizeof (D3DDDIDEVINFO_VCACHE)); 2602 if (DevInfoSize == sizeof (D3DDDIDEVINFO_VCACHE)) 2603 { 2604 D3DDDIDEVINFO_VCACHE *pVCache = (D3DDDIDEVINFO_VCACHE*)pDevInfoStruct; 2605 pVCache->Pattern = MAKEFOURCC('C', 'A', 'C', 'H'); 2606 pVCache->OptMethod = 0 /* D3DXMESHOPT_STRIPREORDER */; 2607 pVCache->CacheSize = 0; 2608 pVCache->MagicNumber = 0; 2609 } 2610 else 2611 hr = E_INVALIDARG; 2612 break; 2613 } 2614 default: 2615 Assert(0); 2616 hr = E_NOTIMPL; 2617 } 2618 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); 2619 return hr; 2564 2620 } 2565 2621 … … 3944 4000 IDirect3DVertexDeclaration9 *pDecl; 3945 4001 static D3DVERTEXELEMENT9 DeclEnd = D3DDECL_END(); 3946 Assert(!memcmp(&DeclEnd, &pVertexElements[pData->NumVertexElements], sizeof (DeclEnd))); 3947 HRESULT hr = pDevice->pDevice9If->CreateVertexDeclaration( 3948 (CONST D3DVERTEXELEMENT9*)pVertexElements, 3949 &pDecl 3950 ); 3951 Assert(hr == S_OK); 4002 D3DVERTEXELEMENT9* pVe; 4003 HRESULT hr = S_OK; 4004 bool bFreeVe = false; 4005 if(memcmp(&DeclEnd, &pVertexElements[pData->NumVertexElements], sizeof (DeclEnd))) 4006 { 4007 pVe = (D3DVERTEXELEMENT9*)RTMemAlloc(sizeof (D3DVERTEXELEMENT9) * (pData->NumVertexElements + 1)); 4008 if (pVe) 4009 { 4010 memcpy(pVe, pVertexElements, sizeof (D3DVERTEXELEMENT9) * pData->NumVertexElements); 4011 pVe[pData->NumVertexElements] = DeclEnd; 4012 bFreeVe = true; 4013 } 4014 else 4015 hr = E_OUTOFMEMORY; 4016 } 4017 else 4018 pVe = (D3DVERTEXELEMENT9*)pVertexElements; 4019 3952 4020 if (hr == S_OK) 3953 4021 { 3954 Assert(pDecl); 3955 pData->ShaderHandle = pDecl; 3956 } 4022 hr = pDevice->pDevice9If->CreateVertexDeclaration( 4023 pVe, 4024 &pDecl 4025 ); 4026 Assert(hr == S_OK); 4027 if (hr == S_OK) 4028 { 4029 Assert(pDecl); 4030 pData->ShaderHandle = pDecl; 4031 } 4032 } 4033 4034 if (bFreeVe) 4035 RTMemFree((void*)pVe); 4036 3957 4037 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr)); 3958 4038 return hr;
Note:
See TracChangeset
for help on using the changeset viewer.