Changeset 29883 in vbox for trunk/src/VBox/Additions/WINNT/Graphics
- Timestamp:
- May 30, 2010 7:27:02 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r29798 r29883 857 857 } 858 858 859 static PVBOXWDDMDISP_RESOURCE vboxResourceAlloc(UINT cAllocs) 860 { 861 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs])); 862 Assert(pRc); 863 if (pRc) 864 { 865 pRc->cAllocations = cAllocs; 866 return pRc; 867 } 868 return NULL; 869 } 870 871 static void vboxResourceFree(PVBOXWDDMDISP_RESOURCE pRc) 872 { 873 RTMemFree(pRc); 874 } 875 859 876 /** 860 877 * DLL entry point. … … 1396 1413 static HRESULT APIENTRY vboxWddmDDevLock(HANDLE hDevice, D3DDDIARG_LOCK* pData) 1397 1414 { 1398 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1399 AssertBreakpoint(); 1400 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1401 return E_FAIL; 1415 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1416 AssertBreakpoint(); 1417 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1418 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hResource; 1419 Assert(pData->SubResourceIndex < pRc->cAllocations); 1420 if (pData->SubResourceIndex >= pRc->cAllocations) 1421 return E_INVALIDARG; 1422 1423 PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[pData->SubResourceIndex]; 1424 D3DDDICB_LOCK LockData; 1425 LockData.hAllocation = pAlloc->hAllocation; 1426 LockData.PrivateDriverData = 0; 1427 LockData.NumPages = 0; 1428 LockData.pPages = NULL; 1429 LockData.pData = NULL; /* out */ 1430 LockData.Flags.Value = 0; 1431 LockData.Flags.Discard = pData->Flags.Discard; 1432 LockData.Flags.DonotWait = pData->Flags.DoNotWait; 1433 1434 1435 HRESULT hr = pDevice->RtCallbacks.pfnLockCb(hDevice, &LockData); 1436 Assert(hr == S_OK || (hr == D3DERR_WASSTILLDRAWING && pData->Flags.DoNotWait)); 1437 if (hr == S_OK) 1438 { 1439 uintptr_t offset; 1440 if (pData->Flags.AreaValid) 1441 { 1442 offset = pAlloc->SurfDesc.pitch * pData->Area.top + 1443 ((pAlloc->SurfDesc.bpp * pData->Area.left) >> 3); 1444 } 1445 else if (pData->Flags.RangeValid) 1446 { 1447 offset = pData->Range.Offset; 1448 } 1449 else if (pData->Flags.BoxValid) 1450 { 1451 vboxVDbgPrintF((__FUNCTION__": Implement Box area")); 1452 AssertBreakpoint(); 1453 } 1454 else 1455 { 1456 AssertBreakpoint(); 1457 } 1458 1459 if (pData->Flags.Discard) 1460 { 1461 /* check if the surface was renamed */ 1462 if (LockData.hAllocation) 1463 pAlloc->hAllocation = LockData.hAllocation; 1464 } 1465 1466 pData->pSurfData = ((uint8_t*)LockData.pData) + offset; 1467 pData->Pitch = pAlloc->SurfDesc.pitch; 1468 pData->SlicePitch = pAlloc->SurfDesc.slicePitch; 1469 } 1470 1471 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1472 return hr; 1402 1473 } 1403 1474 static HRESULT APIENTRY vboxWddmDDevUnlock(HANDLE hDevice, CONST D3DDDIARG_UNLOCK* pData) 1404 1475 { 1405 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1406 AssertBreakpoint(); 1407 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1408 return E_FAIL; 1476 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1477 AssertBreakpoint(); 1478 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1479 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hResource; 1480 HRESULT hr = S_OK; 1481 1482 Assert(pData->SubResourceIndex < pRc->cAllocations); 1483 if (pData->SubResourceIndex >= pRc->cAllocations) 1484 return E_INVALIDARG; 1485 1486 struct 1487 { 1488 D3DDDICB_UNLOCK Unlock; 1489 D3DKMT_HANDLE hAllocation; 1490 } UnlockData; 1491 1492 UnlockData.Unlock.NumAllocations = 1; 1493 UnlockData.Unlock.phAllocations = &UnlockData.hAllocation; 1494 UnlockData.hAllocation = pRc->aAllocations[pData->SubResourceIndex].hAllocation; 1495 1496 hr = pDevice->RtCallbacks.pfnUnlockCb(hDevice, &UnlockData.Unlock); 1497 Assert(hr == S_OK); 1498 1499 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1500 return hr; 1409 1501 } 1410 1502 static HRESULT APIENTRY vboxWddmDDevLockAsync(HANDLE hDevice, D3DDDIARG_LOCKASYNC* pData) … … 1429 1521 return E_FAIL; 1430 1522 } 1523 1431 1524 static HRESULT APIENTRY vboxWddmDDevCreateResource(HANDLE hDevice, D3DDDIARG_CREATERESOURCE* pResource) 1432 1525 { 1433 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1434 AssertBreakpoint(); 1435 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1436 return E_FAIL; 1437 } 1526 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1527 HRESULT hr = S_OK; 1528 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1529 Assert(pDevice); 1530 Assert(pResource); 1531 1532 /* allocate buffer for D3DDDICB_ALLOCATE + D3DDDI_ALLOCATIONINFO * numAllocs + PVBOXWDDM_RCINFO with aAllocInfos[numAllocs] */ 1533 uint32_t cbBuf = sizeof (D3DDDICB_ALLOCATE); 1534 uint32_t offDdiAllocInfos = (cbBuf + 7) & ~3; 1535 uint32_t cbDdiAllocInfos = sizeof (D3DDDI_ALLOCATIONINFO) * pResource->SurfCount; 1536 cbBuf = offDdiAllocInfos + cbDdiAllocInfos; 1537 uint32_t offRcInfo = (cbBuf + 7) & ~3; 1538 uint32_t cbRcInfo = sizeof (VBOXWDDM_RCINFO); 1539 cbBuf = offRcInfo + cbRcInfo; 1540 uint32_t offAllocInfos = (cbBuf + 7) & ~3; 1541 uint32_t cbAllocInfos = sizeof (VBOXWDDM_ALLOCINFO) * pResource->SurfCount; 1542 cbBuf = offAllocInfos + cbAllocInfos; 1543 uint8_t *pvBuf = (uint8_t*)RTMemAllocZ(cbBuf); 1544 if (pvBuf) 1545 { 1546 D3DDDICB_ALLOCATE *pAllocate = (D3DDDICB_ALLOCATE*)pvBuf; 1547 D3DDDI_ALLOCATIONINFO* pDdiAllocInfos = (D3DDDI_ALLOCATIONINFO*)(pvBuf + offDdiAllocInfos); 1548 PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)(pvBuf + offRcInfo); 1549 PVBOXWDDM_ALLOCINFO pAllocInfos = (PVBOXWDDM_ALLOCINFO)(pvBuf + offAllocInfos); 1550 pAllocate->pPrivateDriverData = pRcInfo; 1551 pAllocate->PrivateDriverDataSize = cbRcInfo; 1552 pAllocate->hResource = pResource->hResource; 1553 pAllocate->hKMResource = NULL; 1554 pAllocate->NumAllocations = pResource->SurfCount; 1555 pAllocate->pAllocationInfo = pDdiAllocInfos; 1556 1557 pRcInfo->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC; 1558 pRcInfo->RcDesc.fFlags = pResource->Flags; 1559 pRcInfo->RcDesc.enmFormat = pResource->Format; 1560 pRcInfo->RcDesc.enmPool = pResource->Pool; 1561 pRcInfo->RcDesc.enmMultisampleType = pResource->MultisampleType; 1562 pRcInfo->RcDesc.MultisampleQuality = pResource->MultisampleQuality; 1563 pRcInfo->RcDesc.MipLevels = pResource->MipLevels; 1564 pRcInfo->RcDesc.Fvf = pResource->Fvf; 1565 pRcInfo->RcDesc.VidPnSourceId = pResource->VidPnSourceId; 1566 pRcInfo->RcDesc.RefreshRate = pResource->RefreshRate; 1567 pRcInfo->RcDesc.enmRotation = pResource->Rotation; 1568 pRcInfo->cAllocInfos = pResource->SurfCount; 1569 1570 for (UINT i = 0; i < pResource->SurfCount; ++i) 1571 { 1572 PVBOXWDDM_ALLOCINFO pAllocInfo = &pAllocInfos[i]; 1573 D3DDDI_ALLOCATIONINFO* pDdiAllocInfo = &pDdiAllocInfos[i]; 1574 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 1575 pDdiAllocInfo->hAllocation = NULL; 1576 pDdiAllocInfo->pSystemMem = pSurf->pSysMem; 1577 Assert((!!(pSurf->pSysMem)) == (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)); 1578 pDdiAllocInfo->pPrivateDriverData = pAllocInfo; 1579 pDdiAllocInfo->PrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 1580 pDdiAllocInfo->VidPnSourceId = pResource->VidPnSourceId; 1581 pDdiAllocInfo->Flags.Value = 0; 1582 if (pResource->Flags.Primary) 1583 pDdiAllocInfo->Flags.Primary = 1; 1584 1585 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; 1586 pAllocInfo->SurfDesc.width = pSurf->Width; 1587 pAllocInfo->SurfDesc.height = pSurf->Height; 1588 pAllocInfo->SurfDesc.format = pResource->Format; 1589 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pResource->Format); 1590 1591 if (pSurf->SysMemPitch) 1592 { 1593 pAllocInfo->SurfDesc.pitch = pSurf->SysMemPitch; 1594 #ifdef DEBUG 1595 UINT tst = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp); 1596 Assert(tst == pSurf->SysMemPitch); 1597 #endif 1598 } 1599 else 1600 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp); 1601 1602 pAllocInfo->SurfDesc.depth = pSurf->Depth; 1603 pAllocInfo->SurfDesc.slicePitch = pSurf->SysMemSlicePitch; 1604 pAllocInfo->SurfDesc.VidPnSourceId = pResource->VidPnSourceId; 1605 pAllocInfo->SurfDesc.RefreshRate = pResource->RefreshRate; 1606 } 1607 1608 hr = pDevice->RtCallbacks.pfnAllocateCb(pDevice->hDevice, pAllocate); 1609 Assert(hr == S_OK); 1610 if (hr == S_OK) 1611 { 1612 Assert(pAllocate->hKMResource); 1613 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pResource->SurfCount); 1614 if (pRc) 1615 { 1616 pRc->hResource = pResource->hResource; 1617 pRc->hKMResource = pAllocate->hKMResource; 1618 pRc->pDevice = pDevice; 1619 pRc->fFlags = pRcInfo->fFlags; 1620 pRc->RcDesc = pRcInfo->RcDesc; 1621 pRc->cAllocations = pRcInfo->cAllocInfos; 1622 for (UINT i = 0; i < pRcInfo->cAllocInfos; ++i) 1623 { 1624 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[1]; 1625 D3DDDI_ALLOCATIONINFO* pDdiAllocInfo = &pDdiAllocInfos[i]; 1626 PVBOXWDDM_ALLOCINFO pAllocInfo = &pAllocInfos[i]; 1627 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 1628 pAllocation->hAllocation = pDdiAllocInfo->hAllocation; 1629 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; 1630 pAllocation->pvMem = pSurf->pSysMem; 1631 pAllocation->SurfDesc = pAllocInfo->SurfDesc; 1632 } 1633 1634 pResource->hResource = pRc; 1635 // vboxResourceFree(pRc); 1636 } 1637 else 1638 { 1639 hr = E_OUTOFMEMORY; 1640 } 1641 } 1642 1643 RTMemFree(pvBuf); 1644 } 1645 else 1646 { 1647 hr = E_OUTOFMEMORY; 1648 } 1649 1650 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1651 return hr; 1652 } 1653 1438 1654 static HRESULT APIENTRY vboxWddmDDevDestroyResource(HANDLE hDevice, HANDLE hResource) 1439 1655 { 1440 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1441 AssertBreakpoint(); 1442 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1443 return E_FAIL; 1656 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1657 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 1658 HRESULT hr = S_OK; 1659 1660 Assert(pDevice); 1661 Assert(hResource); 1662 PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)hResource; 1663 if (!(pRc->fFlags & VBOXWDDM_RESOURCE_F_OPENNED)) 1664 { 1665 D3DDDICB_DEALLOCATE Dealloc; 1666 Dealloc.hResource = pRc->hResource; 1667 Assert(pRc->hResource); 1668 /* according to the docs the below two are ignored in case we set the hResource */ 1669 Dealloc.NumAllocations = 0; 1670 Dealloc.HandleList = NULL; 1671 hr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc); 1672 Assert(hr == S_OK); 1673 } 1674 1675 vboxResourceFree(pRc); 1676 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1677 return hr; 1444 1678 } 1445 1679 static HRESULT APIENTRY vboxWddmDDevSetDisplayMode(HANDLE hDevice, CONST D3DDDIARG_SETDISPLAYMODE* pData) … … 1830 2064 return E_FAIL; 1831 2065 } 2066 2067 static HRESULT vboxAllocationInit(PVBOXWDDMDISP_ALLOCATION pAlloc, D3DDDI_OPENALLOCATIONINFO *pInfo) 2068 { 2069 HRESULT hr = S_OK; 2070 pAlloc->hAllocation = pInfo->hAllocation; 2071 Assert(pInfo->PrivateDriverDataSize == sizeof (VBOXWDDM_ALLOCINFO)); 2072 Assert(pInfo->pPrivateDriverData); 2073 if (pInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO)) 2074 { 2075 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pInfo->pPrivateDriverData; 2076 pAlloc->enmType = pAllocInfo->enmType; 2077 Assert(pAllocInfo->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE 2078 || VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE 2079 || VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE); 2080 pAlloc->pvMem = NULL; 2081 pAlloc->SurfDesc = pAllocInfo->SurfDesc; 2082 } 2083 else 2084 { 2085 vboxVDbgPrintR((__FUNCTION__": ERROR: PrivateDriverDataSize(%d) < (%d)\n", pInfo->PrivateDriverDataSize, sizeof (VBOXWDDM_ALLOCINFO))); 2086 hr = E_INVALIDARG; 2087 } 2088 return hr; 2089 } 2090 1832 2091 static HRESULT APIENTRY vboxWddmDDevOpenResource(HANDLE hDevice, D3DDDIARG_OPENRESOURCE* pData) 1833 2092 { 1834 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1835 AssertBreakpoint(); 1836 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 1837 return E_FAIL; 2093 vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 2094 PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice; 2095 HRESULT hr = S_OK; 2096 2097 Assert(pDevice); 2098 Assert(pData->NumAllocations); 2099 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pData->NumAllocations); 2100 Assert(pRc); 2101 if (pRc) 2102 { 2103 pRc->hResource = pData->hResource; 2104 pRc->hKMResource = pData->hKMResource; 2105 pRc->pDevice = pDevice; 2106 pRc->RcDesc.enmRotation = pData->Rotation; 2107 pRc->fFlags = VBOXWDDM_RESOURCE_F_OPENNED; 2108 if (!pData->pPrivateDriverData || !pData->PrivateDriverDataSize) 2109 { 2110 /* this is a "standard" allocation resource */ 2111 2112 /* both should be actually zero */ 2113 Assert(!pData->pPrivateDriverData && !pData->PrivateDriverDataSize); 2114 pRc->RcDesc.enmPool = D3DDDIPOOL_LOCALVIDMEM; 2115 pRc->RcDesc.enmMultisampleType = D3DDDIMULTISAMPLE_NONE; 2116 pRc->RcDesc.MultisampleQuality = 0; 2117 pRc->RcDesc.MipLevels = 0; 2118 pRc->RcDesc.Fvf; 2119 pRc->RcDesc.fFlags.Value = 0; 2120 2121 Assert(pData->NumAllocations); 2122 D3DDDI_OPENALLOCATIONINFO* pDdiAllocInfo = &pData->pOpenAllocationInfo[0]; 2123 Assert(pDdiAllocInfo->pPrivateDriverData); 2124 Assert(pDdiAllocInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO)); 2125 if (pDdiAllocInfo->pPrivateDriverData && pDdiAllocInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO)) 2126 { 2127 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pDdiAllocInfo->pPrivateDriverData; 2128 switch(pAllocInfo->enmType) 2129 { 2130 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE: 2131 pRc->RcDesc.fFlags.Primary = 1; 2132 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 2133 case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE: 2134 pRc->RcDesc.enmFormat = pAllocInfo->SurfDesc.format; 2135 pRc->RcDesc.VidPnSourceId = pAllocInfo->SurfDesc.VidPnSourceId; 2136 pRc->RcDesc.RefreshRate = pAllocInfo->SurfDesc.RefreshRate; 2137 break; 2138 default: 2139 AssertBreakpoint(); 2140 hr = E_INVALIDARG; 2141 } 2142 } 2143 else 2144 hr = E_INVALIDARG; 2145 } 2146 else 2147 { 2148 /* this is a "generic" resource whose creation is initiaded by the UMD */ 2149 Assert(pData->PrivateDriverDataSize == sizeof (VBOXWDDM_RCINFO)); 2150 if (pData->PrivateDriverDataSize >= sizeof (VBOXWDDM_RCINFO)) 2151 { 2152 VBOXWDDM_RCINFO *pRcInfo = (VBOXWDDM_RCINFO*)pData->pPrivateDriverData; 2153 Assert(pRcInfo->fFlags == VBOXWDDM_RESOURCE_F_TYPE_GENERIC); 2154 Assert(pRcInfo->cAllocInfos == pData->NumAllocations); 2155 pRc->fFlags = pRcInfo->fFlags | VBOXWDDM_RESOURCE_F_OPENNED; 2156 pRc->RcDesc = pRcInfo->RcDesc; 2157 pRc->cAllocations = pData->NumAllocations; 2158 } 2159 else 2160 hr = E_INVALIDARG; 2161 } 2162 2163 if (hr == S_OK) 2164 { 2165 for (UINT i = 0; i < pData->NumAllocations; ++i) 2166 { 2167 hr = vboxAllocationInit(&pRc->aAllocations[i], &pData->pOpenAllocationInfo[i]); 2168 Assert(hr == S_OK); 2169 if (hr != S_OK) 2170 break; 2171 } 2172 } 2173 2174 if (hr == S_OK) 2175 pData->hResource = pRc; 2176 else 2177 vboxResourceFree(pRc); 2178 } 2179 else 2180 { 2181 vboxVDbgPrintR((__FUNCTION__": vboxResourceAlloc failed for hDevice(0x%p), NumAllocations(%d)\n", hDevice, pData->NumAllocations)); 2182 hr = E_OUTOFMEMORY; 2183 } 2184 2185 vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice)); 2186 return hr; 1838 2187 } 1839 2188 static HRESULT APIENTRY vboxWddmDDevGetCaptureAllocationHandle(HANDLE hDevice, D3DDDIARG_GETCAPTUREALLOCATIONHANDLE* pData) -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h
r29798 r29883 74 74 } VBOXWDDMDISP_DEVICE, *PVBOXWDDMDISP_DEVICE; 75 75 76 typedef struct VBOXWDDMDISP_ALLOCATION 77 { 78 D3DKMT_HANDLE hAllocation; 79 VBOXWDDM_ALLOC_TYPE enmType; 80 CONST VOID* pvMem; 81 VBOXWDDM_SURFACE_DESC SurfDesc; 82 } VBOXWDDMDISP_ALLOCATION, *PVBOXWDDMDISP_ALLOCATION; 83 84 typedef struct VBOXWDDMDISP_RESOURCE 85 { 86 HANDLE hResource; 87 D3DKMT_HANDLE hKMResource; 88 PVBOXWDDMDISP_DEVICE pDevice; 89 uint32_t fFlags; 90 VBOXWDDM_RC_DESC RcDesc; 91 UINT cAllocations; 92 VBOXWDDMDISP_ALLOCATION aAllocations[1]; 93 } VBOXWDDMDISP_RESOURCE, *PVBOXWDDMDISP_RESOURCE; 94 76 95 DECLINLINE(bool) vboxDispD3DIs3DEnabled(VBOXWDDMDISP_ADAPTER * pAdapter) 77 96 { -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r29625 r29883 985 985 { 986 986 if (!xres) 987 xres = DeviceExtension->aSources[0].pPrimaryAllocation-> u.SurfInfo.width;987 xres = DeviceExtension->aSources[0].pPrimaryAllocation->SurfDesc.width; 988 988 if (!yres) 989 yres = DeviceExtension->aSources[0].pPrimaryAllocation-> u.SurfInfo.height;989 yres = DeviceExtension->aSources[0].pPrimaryAllocation->SurfDesc.height; 990 990 if (!bpp) 991 bpp = DeviceExtension->aSources[0].pPrimaryAllocation-> u.SurfInfo.bpp;991 bpp = DeviceExtension->aSources[0].pPrimaryAllocation->SurfDesc.bpp; 992 992 } 993 993 #endif -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r29798 r29883 166 166 struct VBOXWDDM_ALLOCATION * pShadowAllocation; 167 167 VBOXVIDEOOFFSET offVram; 168 VBOXWDDM_SURFACE_DESC Surf Info;168 VBOXWDDM_SURFACE_DESC SurfDesc; 169 169 VBOXVBVAINFO Vbva; 170 170 #endif … … 636 636 637 637 D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo); 638 UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format);639 638 640 639 DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PDEVICE_EXTENSION pDevExt) … … 668 667 } 669 668 670 DECLINLINE(bool) vboxWddmCmpSurfDescs (VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)669 DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2) 671 670 { 672 671 if (pDesc1->width != pDesc2->width) … … 691 690 { 692 691 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pShadowAllocation; 693 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pOldShadowInfo = VBOXWDDM_ALLOCATION_BODY(pOldAlloc, VBOXWDDM_ALLOCATION_SHADOWSURFACE);694 692 /* clear the visibility info fo the current primary */ 695 pOld ShadowInfo->bVisible = FALSE;696 pOld ShadowInfo->bAssigned = FALSE;697 Assert(pOld ShadowInfo->VidPnSourceId == srcId);693 pOldAlloc->bVisible = FALSE; 694 pOldAlloc->bAssigned = FALSE; 695 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId); 698 696 /* release the shadow surface */ 699 pOld ShadowInfo->VidPnSourceId = D3DDDI_ID_UNINITIALIZED;697 pOldAlloc->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 700 698 } 701 699 702 700 if (pAllocation) 703 701 { 704 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pShadowInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHADOWSURFACE); 705 pShadowInfo->bVisible = FALSE; 702 pAllocation->bVisible = FALSE; 706 703 /* this check ensures the shadow is not used for other source simultaneously */ 707 Assert(p ShadowInfo->VidPnSourceId == D3DDDI_ID_UNINITIALIZED);708 p ShadowInfo->VidPnSourceId = srcId;709 p ShadowInfo->bAssigned = TRUE;710 if (!vboxWddmCmpSurfDescs (&pSource->SurfInfo, &pAllocation->u.SurfInfo))704 Assert(pAllocation->SurfDesc.VidPnSourceId == D3DDDI_ID_UNINITIALIZED); 705 pAllocation->SurfDesc.VidPnSourceId = srcId; 706 pAllocation->bAssigned = TRUE; 707 if (!vboxWddmCmpSurfDescsBase(&pSource->SurfDesc, &pAllocation->SurfDesc)) 711 708 pSource->offVram = VBOXVIDEOOFFSET_VOID; /* force guest->host notification */ 712 pSource->Surf Info = pAllocation->u.SurfInfo;709 pSource->SurfDesc = pAllocation->SurfDesc; 713 710 } 714 711 … … 725 722 { 726 723 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pPrimaryAllocation; 727 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pOldPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pOldAlloc, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);728 724 /* clear the visibility info fo the current primary */ 729 pOld PrimaryInfo->bVisible = FALSE;730 pOld PrimaryInfo->bAssigned = FALSE;731 Assert(pOld PrimaryInfo->VidPnSourceId == srcId);725 pOldAlloc->bVisible = FALSE; 726 pOldAlloc->bAssigned = FALSE; 727 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId); 732 728 } 733 729 734 730 if (pAllocation) 735 731 { 736 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 737 pPrimaryInfo->bVisible = FALSE; 738 Assert(pPrimaryInfo->VidPnSourceId == srcId); 739 pPrimaryInfo->VidPnSourceId = srcId; 740 pPrimaryInfo->bAssigned = TRUE; 732 pAllocation->bVisible = FALSE; 733 Assert(pAllocation->SurfDesc.VidPnSourceId == srcId); 734 pAllocation->SurfDesc.VidPnSourceId = srcId; 735 pAllocation->bAssigned = TRUE; 741 736 } 742 737 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp
r29798 r29883 1048 1048 int VBoxFreeDisplaysHGSMI(PDEVICE_EXTENSION PrimaryExtension) 1049 1049 { 1050 int rc ;1050 int rc = VINF_SUCCESS; 1051 1051 for (int i = PrimaryExtension->cSources-1; i >= 0; --i) 1052 1052 { … … 1057 1057 rc = vboxVbvaDestroy(PrimaryExtension, &PrimaryExtension->aSources[i].Vbva); 1058 1058 AssertRC(rc); 1059 if (RT_FAILURE(rc)) 1060 { 1061 /* @todo: */ 1062 } 1063 } 1064 } 1065 1066 rc = vboxVdmaDisable(PrimaryExtension, &PrimaryExtension->u.primary.Vdma); 1067 AssertRC(rc); 1068 if (RT_SUCCESS(rc)) 1069 { 1070 rc = vboxVdmaDestroy(PrimaryExtension, &PrimaryExtension->u.primary.Vdma); 1071 AssertRC(rc); 1072 if (RT_SUCCESS(rc)) 1073 { 1074 /*rc = */VBoxUnmapAdapterMemory(PrimaryExtension, &PrimaryExtension->u.primary.pvMiniportHeap, PrimaryExtension->u.primary.cbMiniportHeap); 1075 /* 1076 AssertRC(rc); 1059 1077 if (RT_SUCCESS(rc)) 1060 { 1061 rc = vboxVdmaDisable(PrimaryExtension, &PrimaryExtension->u.primary.Vdma); 1078 */ 1079 { 1080 HGSMIHeapDestroy(&PrimaryExtension->u.primary.hgsmiAdapterHeap); 1081 1082 /* Map the adapter information. It will be needed for HGSMI IO. */ 1083 /*rc = */VBoxUnmapAdapterMemory(PrimaryExtension, &PrimaryExtension->u.primary.pvAdapterInformation, VBVA_ADAPTER_INFORMATION_SIZE); 1084 /* 1062 1085 AssertRC(rc); 1063 if (RT_SUCCESS(rc)) 1064 { 1065 rc = vboxVdmaDestroy(PrimaryExtension, &PrimaryExtension->u.primary.Vdma); 1066 AssertRC(rc); 1067 if (RT_SUCCESS(rc)) 1068 { 1069 /*rc = */VBoxUnmapAdapterMemory(PrimaryExtension, &PrimaryExtension->u.primary.pvMiniportHeap, PrimaryExtension->u.primary.cbMiniportHeap); 1070 /* 1071 AssertRC(rc); 1072 if (RT_SUCCESS(rc)) 1086 if (RT_FAILURE(rc)) 1087 drprintf((__FUNCTION__"VBoxUnmapAdapterMemory PrimaryExtension->u.primary.pvAdapterInformation failed, rc(%d)\n", rc)); 1073 1088 */ 1074 { 1075 HGSMIHeapDestroy(&PrimaryExtension->u.primary.hgsmiAdapterHeap); 1076 1077 /* Map the adapter information. It will be needed for HGSMI IO. */ 1078 /*rc = */VBoxUnmapAdapterMemory(PrimaryExtension, &PrimaryExtension->u.primary.pvAdapterInformation, VBVA_ADAPTER_INFORMATION_SIZE); 1079 /* 1080 AssertRC(rc); 1081 if (RT_FAILURE(rc)) 1082 drprintf((__FUNCTION__"VBoxUnmapAdapterMemory PrimaryExtension->u.primary.pvAdapterInformation failed, rc(%d)\n", rc)); 1083 */ 1084 1085 } 1086 } 1087 } 1089 1088 1090 } 1089 1091 } -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h
r29710 r29883 24 24 #include <VBox/VBoxVideo.h> 25 25 26 /* @todo: implement a check to ensure display & miniport versions match 27 * one would increase this whenever defines in this file change*/28 #define VBOXVIDEOIF_VERSION 126 /* @todo: implement a check to ensure display & miniport versions match. 27 * One would increase this whenever definitions in this file are changed */ 28 #define VBOXVIDEOIF_VERSION 2 29 29 30 30 /* create allocation func */ … … 38 38 VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE 39 39 /* custom allocation types requested from user-mode d3d module will go here */ 40 , VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC 40 41 } VBOXWDDM_ALLOC_TYPE; 41 42 … … 47 48 UINT bpp; 48 49 UINT pitch; 50 UINT depth; 51 UINT slicePitch; 52 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; 53 D3DDDI_RATIONAL RefreshRate; 49 54 } VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC; 50 55 … … 52 57 { 53 58 VBOXWDDM_ALLOC_TYPE enmType; 54 union 55 { 56 VBOXWDDM_SURFACE_DESC SurfInfo; 57 } u; 59 VBOXWDDM_SURFACE_DESC SurfDesc; 58 60 } VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO; 59 61 60 #define VBOXWDDM_ALLOCINFO_HEADSIZE() (sizeof (VBOXWDDM_ALLOCINFO))61 #define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s))62 #define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd)))63 #define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ( (_t*)(((uint8_t*)(_p)) + VBOXWDDM_ALLOCINFO_HEADSIZE()) )64 #define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - VBOXWDDM_ALLOCATION_HEADSIZE()))62 //#define VBOXWDDM_ALLOCINFO_HEADSIZE() (sizeof (VBOXWDDM_ALLOCINFO)) 63 //#define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s)) 64 //#define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd))) 65 //#define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ( (_t*)(((uint8_t*)(_p)) + VBOXWDDM_ALLOCINFO_HEADSIZE()) ) 66 //#define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - VBOXWDDM_ALLOCATION_HEADSIZE())) 65 67 68 /* this resource is OpenResource'd rather than CreateResource'd */ 69 #define VBOXWDDM_RESOURCE_F_OPENNED 0x00000001 70 /* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */ 71 #define VBOXWDDM_RESOURCE_F_TYPE_GENERIC 0x00000002 72 73 typedef struct VBOXWDDM_RC_DESC 74 { 75 D3DDDI_RESOURCEFLAGS fFlags; 76 D3DDDIFORMAT enmFormat; 77 D3DDDI_POOL enmPool; 78 D3DDDIMULTISAMPLE_TYPE enmMultisampleType; 79 UINT MultisampleQuality; 80 UINT MipLevels; 81 UINT Fvf; 82 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; 83 D3DDDI_RATIONAL RefreshRate; 84 D3DDDI_ROTATION enmRotation; 85 } VBOXWDDM_RC_DESC, *PVBOXWDDM_RC_DESC; 86 87 typedef struct VBOXWDDM_RCINFO 88 { 89 uint32_t fFlags; 90 VBOXWDDM_RC_DESC RcDesc; 91 uint32_t cAllocInfos; 92 // VBOXWDDM_ALLOCINFO aAllocInfos[1]; 93 } VBOXWDDM_RCINFO, *PVBOXWDDM_RCINFO; 66 94 67 95 #define VBOXVHWA_F_ENABLED 0x00000001 … … 89 117 /* submit cmd func */ 90 118 119 120 121 122 /* tooling */ 123 DECLINLINE(UINT) vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format) 124 { 125 switch (format) 126 { 127 case D3DDDIFMT_R8G8B8: 128 return 24; 129 case D3DDDIFMT_A8R8G8B8: 130 case D3DDDIFMT_X8R8G8B8: 131 return 32; 132 case D3DDDIFMT_R5G6B5: 133 case D3DDDIFMT_X1R5G5B5: 134 case D3DDDIFMT_A1R5G5B5: 135 case D3DDDIFMT_A4R4G4B4: 136 return 16; 137 case D3DDDIFMT_R3G3B2: 138 case D3DDDIFMT_A8: 139 return 8; 140 case D3DDDIFMT_A8R3G3B2: 141 case D3DDDIFMT_X4R4G4B4: 142 return 16; 143 case D3DDDIFMT_A2B10G10R10: 144 case D3DDDIFMT_A8B8G8R8: 145 case D3DDDIFMT_X8B8G8R8: 146 case D3DDDIFMT_G16R16: 147 case D3DDDIFMT_A2R10G10B10: 148 return 32; 149 case D3DDDIFMT_A16B16G16R16: 150 return 64; 151 case D3DDDIFMT_A8P8: 152 return 16; 153 case D3DDDIFMT_P8: 154 return 8; 155 default: 156 AssertBreakpoint(); 157 return 0; 158 } 159 } 160 161 #define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1)) 162 163 DECLINLINE(UINT) vboxWddmCalcPitch(UINT w, UINT bitsPerPixel) 164 { 165 UINT Pitch = bitsPerPixel * w; 166 /* pitch is now in bits, translate in bytes */ 167 return VBOXWDDM_ROUNDBOUND(Pitch, 8) >> 3; 168 } 169 91 170 #endif /* #ifndef ___VBoxVideoIf_h___ */ -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r29798 r29883 76 76 } 77 77 78 NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation , D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)78 NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 79 79 { 80 80 VBOXVIDEOOFFSET offVram = pAllocation->offVram; … … 83 83 // return STATUS_INVALID_PARAMETER; 84 84 85 // PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);86 85 /* Issue the screen info command. */ 87 86 void *p = vboxHGSMIBufferAlloc (pDevExt, … … 94 93 VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p; 95 94 96 pScreen->u32ViewIndex = /*pPrimaryInfo->*/VidPnSourceId;95 pScreen->u32ViewIndex = pAllocation->SurfDesc.VidPnSourceId; 97 96 pScreen->i32OriginX = 0; 98 97 pScreen->i32OriginY = 0; 99 98 pScreen->u32StartOffset = 0; //(uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */ 100 pScreen->u32LineSize = pAllocation-> u.SurfInfo.pitch;101 pScreen->u32Width = pAllocation-> u.SurfInfo.width;102 pScreen->u32Height = pAllocation-> u.SurfInfo.height;103 pScreen->u16BitsPerPixel = (uint16_t)pAllocation-> u.SurfInfo.bpp;99 pScreen->u32LineSize = pAllocation->SurfDesc.pitch; 100 pScreen->u32Width = pAllocation->SurfDesc.width; 101 pScreen->u32Height = pAllocation->SurfDesc.height; 102 pScreen->u16BitsPerPixel = (uint16_t)pAllocation->SurfDesc.bpp; 104 103 pScreen->u16Flags = VBVA_SCREEN_F_ACTIVE; 105 104 … … 112 111 } 113 112 114 NTSTATUS vboxWddmGhDisplayPostInfoView (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)113 NTSTATUS vboxWddmGhDisplayPostInfoView(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 115 114 { 116 115 VBOXVIDEOOFFSET offVram = pAllocation->offVram; … … 119 118 return STATUS_INVALID_PARAMETER; 120 119 121 // PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);122 120 /* Issue the screen info command. */ 123 121 void *p = vboxHGSMIBufferAlloc (pDevExt, … … 130 128 VBVAINFOVIEW *pView = (VBVAINFOVIEW *)p; 131 129 132 pView->u32ViewIndex = /*pPrimaryInfo->*/VidPnSourceId;130 pView->u32ViewIndex = pAllocation->SurfDesc.VidPnSourceId; 133 131 pView->u32ViewOffset = (uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */ 134 132 pView->u32ViewSize = vboxWddmVramCpuVisibleSegmentSize(pDevExt)/pDevExt->cSources; … … 144 142 } 145 143 146 NTSTATUS vboxWddmGhDisplaySetMode (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)144 NTSTATUS vboxWddmGhDisplaySetMode(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 147 145 { 148 146 // PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 149 if (/*pPrimaryInfo->*/ VidPnSourceId)147 if (/*pPrimaryInfo->*/pAllocation->SurfDesc.VidPnSourceId) 150 148 return STATUS_SUCCESS; 151 149 152 if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation-> u.SurfInfo.width,153 pAllocation-> u.SurfInfo.height, pAllocation->u.SurfInfo.bpp,150 if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation->SurfDesc.width, 151 pAllocation->SurfDesc.height, pAllocation->SurfDesc.bpp, 154 152 (ULONG)pAllocation->offVram)) 155 153 return STATUS_SUCCESS; … … 166 164 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 167 165 PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation; 168 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);169 166 #else 170 167 PVBOXWDDM_ALLOCATION pAllocation = pSource->pShadowAllocation; 171 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pSource->pPrimaryAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);172 168 #endif 173 169 VBOXVIDEOOFFSET offVram = vboxWddmValidatePrimary(pAllocation); … … 179 175 * Set the current mode into the hardware. 180 176 */ 181 NTSTATUS Status = vboxWddmGhDisplaySetMode (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);177 NTSTATUS Status = vboxWddmGhDisplaySetMode(pDevExt, pAllocation); 182 178 Assert(Status == STATUS_SUCCESS); 183 179 if (Status == STATUS_SUCCESS) 184 180 { 185 Status = vboxWddmGhDisplayPostInfoView (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);181 Status = vboxWddmGhDisplayPostInfoView(pDevExt, pAllocation); 186 182 Assert(Status == STATUS_SUCCESS); 187 183 if (Status == STATUS_SUCCESS) 188 184 { 189 Status = vboxWddmGhDisplayPostInfoScreen (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);185 Status = vboxWddmGhDisplayPostInfoScreen(pDevExt, pAllocation); 190 186 Assert(Status == STATUS_SUCCESS); 191 187 if (Status != STATUS_SUCCESS) … … 407 403 } 408 404 409 UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)410 {411 switch (format)412 {413 case D3DDDIFMT_R8G8B8:414 return 24;415 case D3DDDIFMT_A8R8G8B8:416 case D3DDDIFMT_X8R8G8B8:417 return 32;418 case D3DDDIFMT_R5G6B5:419 case D3DDDIFMT_X1R5G5B5:420 case D3DDDIFMT_A1R5G5B5:421 case D3DDDIFMT_A4R4G4B4:422 return 16;423 case D3DDDIFMT_R3G3B2:424 case D3DDDIFMT_A8:425 return 8;426 case D3DDDIFMT_A8R3G3B2:427 case D3DDDIFMT_X4R4G4B4:428 return 16;429 case D3DDDIFMT_A2B10G10R10:430 case D3DDDIFMT_A8B8G8R8:431 case D3DDDIFMT_X8B8G8R8:432 case D3DDDIFMT_G16R16:433 case D3DDDIFMT_A2R10G10B10:434 return 32;435 case D3DDDIFMT_A16B16G16R16:436 return 64;437 case D3DDDIFMT_A8P8:438 return 16;439 case D3DDDIFMT_P8:440 return 8;441 default:442 AssertBreakpoint();443 return 0;444 }445 }446 447 405 D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo) 448 406 { … … 509 467 510 468 return D3DDDIFMT_UNKNOWN; 511 }512 513 UINT vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)514 {515 UINT Pitch = bitsPerPixel * w;516 /* pitch is now in bits, translate in bytes */517 if(Pitch & 7)518 Pitch = (Pitch >> 3) + 1;519 else520 Pitch = (Pitch >> 3);521 522 return Pitch;523 469 } 524 470 … … 1434 1380 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE: 1435 1381 { 1436 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 1437 if (pAlloc->bAssigned) 1382 if (pAllocation->bAssigned) 1438 1383 { 1439 1384 /* @todo: do we need to notify host? */ 1440 vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[pAlloc ->VidPnSourceId], NULL, pAlloc->VidPnSourceId);1385 vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[pAllocation->SurfDesc.VidPnSourceId], NULL, pAllocation->SurfDesc.VidPnSourceId); 1441 1386 } 1442 1387 break; … … 1445 1390 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 1446 1391 { 1447 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHADOWSURFACE); 1448 if (pAlloc->bAssigned) 1449 { 1450 Assert(pAlloc->VidPnSourceId != D3DDDI_ID_UNINITIALIZED); 1392 if (pAllocation->bAssigned) 1393 { 1394 Assert(pAllocation->SurfDesc.VidPnSourceId != D3DDDI_ID_UNINITIALIZED); 1451 1395 /* @todo: do we need to notify host? */ 1452 vboxWddmAssignShadow(pDevExt, &pDevExt->aSources[pAlloc ->VidPnSourceId], NULL, pAlloc->VidPnSourceId);1396 vboxWddmAssignShadow(pDevExt, &pDevExt->aSources[pAllocation->SurfDesc.VidPnSourceId], NULL, pAllocation->SurfDesc.VidPnSourceId); 1453 1397 } 1454 1398 break; … … 1468 1412 NTSTATUS Status = STATUS_SUCCESS; 1469 1413 1470 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());1471 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())1414 Assert(pAllocationInfo->PrivateDriverDataSize == sizeof (VBOXWDDM_ALLOCINFO)); 1415 if (pAllocationInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO)) 1472 1416 { 1473 1417 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pAllocationInfo->pPrivateDriverData; 1474 switch (pAllocInfo->enmType) 1475 { 1476 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE: 1477 { 1478 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)); 1479 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)) 1480 { 1481 if (pAllocInfo->u.SurfInfo.bpp != 0) 1482 { 1483 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE)); 1484 Assert(pAllocation); 1485 if (pAllocation) 1486 { 1487 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE; 1488 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1489 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1490 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 1491 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pAllocI = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1492 pAlloc->RefreshRate = pAllocI->RefreshRate; 1493 pAlloc->VidPnSourceId = pAllocI->VidPnSourceId; 1494 // pAlloc->offAddress = VBOXVIDEOOFFSET_VOID; 1495 pAlloc->bVisible = FALSE; 1496 1497 pAllocationInfo->pPrivateDriverData = NULL; 1498 pAllocationInfo->PrivateDriverDataSize = 0; 1499 pAllocationInfo->Alignment = 0; 1500 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1501 pAllocationInfo->PitchAlignedSize = 0; 1502 pAllocationInfo->HintedBank.Value = 0; 1503 pAllocationInfo->PreferredSegment.Value = 0; 1504 #if 1 //defined(VBOXWDDM_RENDER_FROM_SHADOW) 1505 pAllocationInfo->SupportedReadSegmentSet = 1; 1506 pAllocationInfo->SupportedWriteSegmentSet = 1; 1507 #else 1508 pAllocationInfo->SupportedReadSegmentSet = 2; 1509 pAllocationInfo->SupportedWriteSegmentSet = 2; 1418 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_ALLOCATION)); 1419 Assert(pAllocation); 1420 if (pAllocation) 1421 { 1422 pAllocation->enmType = pAllocInfo->enmType; 1423 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1424 pAllocation->SurfDesc = pAllocInfo->SurfDesc; 1425 pAllocation->bVisible = FALSE; 1426 pAllocation->bAssigned = FALSE; 1427 1428 pAllocationInfo->pPrivateDriverData = NULL; 1429 pAllocationInfo->PrivateDriverDataSize = 0; 1430 pAllocationInfo->Alignment = 0; 1431 pAllocationInfo->Size = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 1432 pAllocationInfo->PitchAlignedSize = 0; 1433 pAllocationInfo->HintedBank.Value = 0; 1434 pAllocationInfo->PreferredSegment.Value = 0; 1435 pAllocationInfo->SupportedReadSegmentSet = 1; 1436 pAllocationInfo->SupportedWriteSegmentSet = 1; 1437 pAllocationInfo->EvictionSegmentSet = 0; 1438 pAllocationInfo->MaximumRenamingListLength = 0; 1439 pAllocationInfo->hAllocation = pAllocation; 1440 pAllocationInfo->Flags.Value = 0; 1441 pAllocationInfo->pAllocationUsageHint = NULL; 1442 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1443 1444 switch (pAllocInfo->enmType) 1445 { 1446 case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE: 1447 #if 0 //defined(VBOXWDDM_RENDER_FROM_SHADOW) 1448 pAllocationInfo->SupportedReadSegmentSet = 2; 1449 pAllocationInfo->SupportedWriteSegmentSet = 2; 1510 1450 #endif 1511 pAllocationInfo->EvictionSegmentSet = 0;1512 pAllocationInfo->MaximumRenamingListLength = 0;1513 pAllocationInfo->hAllocation = pAllocation;1514 pAllocationInfo->Flags.Value = 0;1515 1451 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 1516 1452 pAllocationInfo->Flags.CpuVisible = 1; 1517 1453 #endif 1518 pAllocationInfo->pAllocationUsageHint = NULL; 1519 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1520 } 1521 else 1522 { 1523 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1524 Status = STATUS_NO_MEMORY; 1525 } 1526 } 1527 else 1528 { 1529 drprintf((__FUNCTION__ ": Invalid format (%d)\n", pAllocInfo->u.SurfInfo.format)); 1530 Status = STATUS_INVALID_PARAMETER; 1531 } 1532 } 1533 else 1534 { 1535 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE))); 1454 break; 1455 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 1456 case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE: 1457 case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC: 1458 pAllocationInfo->Flags.Value = 0; 1459 pAllocationInfo->Flags.CpuVisible = 1; 1460 break; 1461 default: 1462 drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType)); 1463 AssertBreakpoint(); 1536 1464 Status = STATUS_INVALID_PARAMETER; 1537 } 1538 break; 1539 } 1540 case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE: 1541 #ifdef VBOXWDDM_RENDER_FROM_SHADOW 1542 { 1543 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()); 1544 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()) 1545 { 1546 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHADOWSURFACE)); 1547 Assert(pAllocation); 1548 if (pAllocation) 1549 { 1550 pAllocation->enmType = pAllocInfo->enmType; 1551 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1552 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1553 1554 pAllocationInfo->pPrivateDriverData = NULL; 1555 pAllocationInfo->PrivateDriverDataSize = 0; 1556 pAllocationInfo->Alignment = 0; 1557 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1558 pAllocationInfo->PitchAlignedSize = 0; 1559 pAllocationInfo->HintedBank.Value = 0; 1560 pAllocationInfo->PreferredSegment.Value = 0; 1561 pAllocationInfo->SupportedReadSegmentSet = 1; 1562 pAllocationInfo->SupportedWriteSegmentSet = 1; 1563 pAllocationInfo->EvictionSegmentSet = 0; 1564 pAllocationInfo->MaximumRenamingListLength = 0; 1565 pAllocationInfo->hAllocation = pAllocation; 1566 pAllocationInfo->Flags.Value = 0; 1567 pAllocationInfo->Flags.CpuVisible = 1; 1568 pAllocationInfo->pAllocationUsageHint = NULL; 1569 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1570 PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHADOWSURFACE); 1571 pAlloc->VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 1572 // pAlloc->bVisible = FALSE; 1573 // pAlloc->bAssigned = FALSE; 1574 } 1575 else 1576 { 1577 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1578 Status = STATUS_NO_MEMORY; 1579 } 1580 } 1581 else 1582 { 1583 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE())); 1584 Status = STATUS_INVALID_PARAMETER; 1585 } 1586 break; 1587 } 1588 #endif 1589 case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE: 1590 { 1591 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()); 1592 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE()) 1593 { 1594 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_HEADSIZE()); 1595 Assert(pAllocation); 1596 if (pAllocation) 1597 { 1598 pAllocation->enmType = pAllocInfo->enmType; 1599 pAllocation->offVram = VBOXVIDEOOFFSET_VOID; 1600 pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo; 1601 1602 pAllocationInfo->pPrivateDriverData = NULL; 1603 pAllocationInfo->PrivateDriverDataSize = 0; 1604 pAllocationInfo->Alignment = 0; 1605 pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height; 1606 pAllocationInfo->PitchAlignedSize = 0; 1607 pAllocationInfo->HintedBank.Value = 0; 1608 pAllocationInfo->PreferredSegment.Value = 0; 1609 pAllocationInfo->SupportedReadSegmentSet = 1; 1610 pAllocationInfo->SupportedWriteSegmentSet = 1; 1611 pAllocationInfo->EvictionSegmentSet = 0; 1612 pAllocationInfo->MaximumRenamingListLength = 0; 1613 pAllocationInfo->hAllocation = pAllocation; 1614 pAllocationInfo->Flags.Value = 0; 1615 pAllocationInfo->Flags.CpuVisible = 1; 1616 pAllocationInfo->pAllocationUsageHint = NULL; 1617 pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL; 1618 } 1619 else 1620 { 1621 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1622 Status = STATUS_NO_MEMORY; 1623 } 1624 } 1625 else 1626 { 1627 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE())); 1628 Status = STATUS_INVALID_PARAMETER; 1629 } 1630 break; 1631 } 1632 default: 1633 drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType)); 1634 Status = STATUS_INVALID_PARAMETER; 1635 break; 1636 } 1465 break; 1466 } 1467 1468 if (Status != STATUS_SUCCESS) 1469 vboxWddmMemFree(pAllocation); 1470 } 1471 else 1472 { 1473 drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n")); 1474 Status = STATUS_NO_MEMORY; 1475 } 1476 1637 1477 } 1638 1478 else 1639 1479 { 1640 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));1480 drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, sizeof (VBOXWDDM_ALLOCINFO))); 1641 1481 Status = STATUS_INVALID_PARAMETER; 1642 1482 } … … 1658 1498 NTSTATUS Status = STATUS_SUCCESS; 1659 1499 1500 if (pCreateAllocation->PrivateDriverDataSize) 1501 { 1502 /* @todo: Implement Resource Data Handling */ 1503 drprintf((__FUNCTION__ ": WARNING: Implement Resource Data Handling\n")); 1504 } 1505 1660 1506 for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i) 1661 1507 { … … 1717 1563 1718 1564 PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)pDescribeAllocation->hAllocation; 1719 pDescribeAllocation->Width = pAllocation-> u.SurfInfo.width;1720 pDescribeAllocation->Height = pAllocation-> u.SurfInfo.height;1721 pDescribeAllocation->Format = pAllocation-> u.SurfInfo.format;1565 pDescribeAllocation->Width = pAllocation->SurfDesc.width; 1566 pDescribeAllocation->Height = pAllocation->SurfDesc.height; 1567 pDescribeAllocation->Format = pAllocation->SurfDesc.format; 1722 1568 memset (&pDescribeAllocation->MultisampleMethod, 0, sizeof (pDescribeAllocation->MultisampleMethod)); 1723 1569 pDescribeAllocation->RefreshRate.Numerator = 60000; … … 1757 1603 { 1758 1604 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1605 memset (pAllocInfo, 0, sizeof (VBOXWDDM_ALLOCINFO)); 1759 1606 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE; 1760 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width; 1761 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height; 1762 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format; 1763 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1764 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1765 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1766 pInfo->RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate; 1767 pInfo->VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId; 1768 } 1769 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE); 1607 pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width; 1608 pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height; 1609 pAllocInfo->SurfDesc.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format; 1610 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1611 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1612 pAllocInfo->SurfDesc.depth = 0; 1613 pAllocInfo->SurfDesc.slicePitch = 0; 1614 pAllocInfo->SurfDesc.RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate; 1615 pAllocInfo->SurfDesc.VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId; 1616 } 1617 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 1770 1618 1771 1619 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 1788 1636 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1789 1637 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE; 1790 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width; 1791 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height; 1792 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format; 1793 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1794 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1795 1796 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch; 1638 pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width; 1639 pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height; 1640 pAllocInfo->SurfDesc.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format; 1641 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1642 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1643 pAllocInfo->SurfDesc.depth = 0; 1644 pAllocInfo->SurfDesc.slicePitch = 0; 1645 pAllocInfo->SurfDesc.RefreshRate.Numerator = 0; 1646 pAllocInfo->SurfDesc.RefreshRate.Denominator = 1000; 1647 pAllocInfo->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 1648 1649 pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->SurfDesc.pitch; 1797 1650 } 1798 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();1651 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 1799 1652 1800 1653 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 1814 1667 pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData; 1815 1668 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE; 1816 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width; 1817 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height; 1818 pAllocInfo->u.SurfInfo.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */ 1819 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format); 1820 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp); 1821 1822 pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch; 1823 } 1824 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE(); 1669 pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width; 1670 pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height; 1671 pAllocInfo->SurfDesc.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */ 1672 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format); 1673 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->SurfDesc.bpp); 1674 pAllocInfo->SurfDesc.depth = 0; 1675 pAllocInfo->SurfDesc.slicePitch = 0; 1676 pAllocInfo->SurfDesc.RefreshRate.Numerator = 0; 1677 pAllocInfo->SurfDesc.RefreshRate.Denominator = 1000; 1678 pAllocInfo->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED; 1679 1680 pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->SurfDesc.pitch; 1681 } 1682 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 1825 1683 1826 1684 pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0; … … 2929 2787 { 2930 2788 Assert(pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE); 2931 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);2932 2789 pAllocation->offVram = (VBOXVIDEOOFFSET)pSetVidPnSourceAddress->PrimaryAddress.QuadPart; 2933 2790 pAllocation->SegmentId = pSetVidPnSourceAddress->PrimarySegment; 2934 2791 Assert (pAllocation->SegmentId); 2935 Assert (!p Primary->bVisible);2792 Assert (!pAllocation->bVisible); 2936 2793 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 2937 if (p Primary->bVisible)2794 if (pAllocation->bVisible) 2938 2795 { 2939 2796 /* should not generally happen, but still inform host*/ … … 2983 2840 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId]; 2984 2841 PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation; 2985 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 2986 2987 Assert(pPrimary->bVisible != pSetVidPnSourceVisibility->Visible); 2988 if (pPrimary->bVisible != pSetVidPnSourceVisibility->Visible) 2989 { 2990 pPrimary->bVisible = pSetVidPnSourceVisibility->Visible; 2842 2843 Assert(pAllocation->bVisible != pSetVidPnSourceVisibility->Visible); 2844 if (pAllocation->bVisible != pSetVidPnSourceVisibility->Visible) 2845 { 2846 pAllocation->bVisible = pSetVidPnSourceVisibility->Visible; 2991 2847 #ifndef VBOXWDDM_RENDER_FROM_SHADOW 2992 if (p Primary->bVisible)2848 if (pAllocation->bVisible) 2993 2849 { 2994 2850 Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource); … … 3368 3224 DECLINLINE(VOID) vboxWddmSurfDescFromAllocation(PVBOXWDDM_ALLOCATION pAllocation, PVBOXVDMA_SURF_DESC pDesc) 3369 3225 { 3370 pDesc->width = pAllocation-> u.SurfInfo.width;3371 pDesc->height = pAllocation-> u.SurfInfo.height;3372 pDesc->format = vboxWddmFromPixFormat(pAllocation-> u.SurfInfo.format);3373 pDesc->bpp = pAllocation-> u.SurfInfo.bpp;3374 pDesc->pitch = pAllocation-> u.SurfInfo.pitch;3226 pDesc->width = pAllocation->SurfDesc.width; 3227 pDesc->height = pAllocation->SurfDesc.height; 3228 pDesc->format = vboxWddmFromPixFormat(pAllocation->SurfDesc.format); 3229 pDesc->bpp = pAllocation->SurfDesc.bpp; 3230 pDesc->pitch = pAllocation->SurfDesc.pitch; 3375 3231 pDesc->fFlags = 0; 3376 3232 } … … 3384 3240 } 3385 3241 3386 DECLINLINE( PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)3242 DECLINLINE(bool) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation) 3387 3243 { 3388 3244 if (pAllocation->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE) 3389 return NULL; 3390 3391 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 3392 if (!pPrimary->bVisible) 3393 return NULL; 3394 3395 D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pPrimary->VidPnSourceId; 3245 return false; 3246 3247 if (!pAllocation->bVisible) 3248 return false; 3249 3250 D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pAllocation->SurfDesc.VidPnSourceId; 3396 3251 if (id >= pDevExt->cSources) 3397 return NULL;3252 return false; 3398 3253 3399 3254 PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[id]; 3400 3255 if (pSource->pPrimaryAllocation != pAllocation) 3401 return NULL;3402 3403 return pPrimary;3256 return false; 3257 3258 return true; 3404 3259 } 3405 3260 … … 3456 3311 && pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE) 3457 3312 { 3458 PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pDstAlloc, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE); 3459 Assert(pPrimaryInfo->bAssigned); 3460 Assert(pPrimaryInfo->bVisible); 3461 if (pPrimaryInfo->bAssigned 3462 && pPrimaryInfo->bVisible) 3313 Assert(pDstAlloc->bAssigned); 3314 Assert(pDstAlloc->bVisible); 3315 if (pDstAlloc->bAssigned 3316 && pDstAlloc->bVisible) 3463 3317 { 3464 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[p PrimaryInfo->VidPnSourceId];3465 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, p PrimaryInfo->VidPnSourceId);3318 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->SurfDesc.VidPnSourceId]; 3319 vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pDstAlloc->SurfDesc.VidPnSourceId); 3466 3320 Assert(pPresent->SrcRect.left == pPresent->DstRect.left); 3467 3321 Assert(pPresent->SrcRect.right == pPresent->DstRect.right); … … 3507 3361 /* we do not know the shadow address yet, perform dummy DMA cycle */ 3508 3362 pPrivateData->rect = rect; 3509 pPrivateData->srcId = p PrimaryInfo->VidPnSourceId;3363 pPrivateData->srcId = pDstAlloc->SurfDesc.VidPnSourceId; 3510 3364 pPrivateData->enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY; 3511 3365 if (pSrc->SegmentId) … … 3537 3391 if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE()) 3538 3392 { 3539 if (vboxWddmPixFormatConversionSupported(pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))3393 if (vboxWddmPixFormatConversionSupported(pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)) 3540 3394 { 3541 3395 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST)); … … 3582 3436 { 3583 3437 AssertBreakpoint(); 3584 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));3438 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)); 3585 3439 Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT; 3586 3440 } … … 3626 3480 if (pDstAlloc) 3627 3481 { 3628 if (vboxWddmPixFormatConversionSupported(pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))3482 if (vboxWddmPixFormatConversionSupported(pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)) 3629 3483 { 3630 3484 memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST)); … … 3670 3524 { 3671 3525 AssertBreakpoint(); 3672 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc-> u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));3526 drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format)); 3673 3527 Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT; 3674 3528 } -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h
r29710 r29883 44 44 #endif 45 45 46 #define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))47 48 46 PVOID vboxWddmMemAlloc(IN SIZE_T cbSize); 49 47 PVOID vboxWddmMemAllocZero(IN SIZE_T cbSize); 50 48 VOID vboxWddmMemFree(PVOID pvMem); 51 52 typedef struct VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE53 {54 D3DDDI_RATIONAL RefreshRate;55 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;56 } VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE, *PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE;57 49 58 50 /* allocation */ … … 62 54 UINT SegmentId; 63 55 VBOXVIDEOOFFSET offVram; 64 union 65 { 66 VBOXWDDM_SURFACE_DESC SurfInfo; 67 } u; 56 BOOLEAN bVisible; 57 BOOLEAN bAssigned; 58 VBOXWDDM_SURFACE_DESC SurfDesc; 68 59 } VBOXWDDM_ALLOCATION, *PVBOXWDDM_ALLOCATION; 69 60 70 #define VBOXWDDM_ALLOCATION_HEADSIZE() (sizeof (VBOXWDDM_ALLOCATION)) 71 #define VBOXWDDM_ALLOCATION_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCATION_HEADSIZE() + (_s)) 72 #define VBOXWDDM_ALLOCATION_SIZE(_tCmd) (VBOXWDDM_ALLOCATION_SIZE_FROMBODYSIZE(sizeof(_tCmd))) 73 #define VBOXWDDM_ALLOCATION_BODY(_p, _t) ( (_t*)(((uint8_t*)(_p)) + VBOXWDDM_ALLOCATION_HEADSIZE()) ) 74 #define VBOXWDDM_ALLOCATION_HEAD(_pb) ((VBOXWDDM_ALLOCATION*)((uint8_t *)(_pb) - VBOXWDDM_ALLOCATION_HEADSIZE())) 75 76 77 typedef struct VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE 61 typedef struct VBOXWDDM_RESOURCE 78 62 { 63 VBOXWDDM_ALLOC_TYPE enmType; 64 UINT SegmentId; 65 VBOXVIDEOOFFSET offVram; 79 66 D3DDDI_RATIONAL RefreshRate; 80 67 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; 81 // VBOXVIDEOOFFSET offAddress;82 68 BOOLEAN bVisible; 83 69 BOOLEAN bAssigned; 84 } VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE, *PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE; 70 VBOXWDDM_SURFACE_DESC SurfDesc; 71 uint32_t cAllocations; 72 } VBOXWDDM_RESOURCE, *PVBOXWDDM_RESOURCE; 85 73 86 #ifdef VBOXWDDM_RENDER_FROM_SHADOW87 typedef struct VBOXWDDM_ALLOCATION_SHADOWSURFACE88 {89 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;90 // VBOXVIDEOOFFSET offAddress;91 BOOLEAN bVisible;92 BOOLEAN bAssigned;93 } VBOXWDDM_ALLOCATION_SHADOWSURFACE, *PVBOXWDDM_ALLOCATION_SHADOWSURFACE;94 #endif95 74 96 75 typedef enum
Note:
See TracChangeset
for help on using the changeset viewer.