Changeset 91361 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Sep 24, 2021 12:48:04 PM (3 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
r89356 r91361 942 942 943 943 944 int vmsvgaR3UpdateGBSurface(PVGASTATECC pThisCC, uint32_t idDXContext,SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBox)944 int vmsvgaR3UpdateGBSurface(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBox) 945 945 { 946 946 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; … … 955 955 { 956 956 VMSVGA3D_MAPPED_SURFACE map; 957 rc = pSvgaR3State->pFuncsMap->pfnSurfaceMap(pThisCC, idDXContext, pImageId, pBox, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map);957 rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBox, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map); 958 958 if (RT_SUCCESS(rc)) 959 959 { … … 979 979 } 980 980 981 pSvgaR3State->pFuncsMap->pfnSurfaceUnmap(pThisCC, pImageId, &map, /* fWritten= */ true);981 vmsvga3dSurfaceUnmap(pThisCC, pImageId, &map, /* fWritten= */ true); 982 982 } 983 983 } … … 990 990 991 991 992 int vmsvgaR3UpdateGBSurfaceEx(PVGASTATECC pThisCC, uint32_t idDXContext,SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBoxDst, SVGA3dPoint const *pPtSrc)992 int vmsvgaR3UpdateGBSurfaceEx(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBoxDst, SVGA3dPoint const *pPtSrc) 993 993 { 994 994 /* pPtSrc must be verified by the caller. */ … … 1004 1004 { 1005 1005 VMSVGA3D_MAPPED_SURFACE map; 1006 rc = pSvgaR3State->pFuncsMap->pfnSurfaceMap(pThisCC, idDXContext, pImageId, pBoxDst, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map);1006 rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBoxDst, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map); 1007 1007 if (RT_SUCCESS(rc)) 1008 1008 { … … 1028 1028 } 1029 1029 1030 pSvgaR3State->pFuncsMap->pfnSurfaceUnmap(pThisCC, pImageId, &map, /* fWritten= */ true);1030 vmsvga3dSurfaceUnmap(pThisCC, pImageId, &map, /* fWritten= */ true); 1031 1031 } 1032 1032 } … … 1281 1281 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, 1282 1282 pCmd->multisampleCount, pCmd->autogenFilter, 1283 pCmd->face[0].numMipLevels, &paMipLevelSizes[0] );1283 pCmd->face[0].numMipLevels, &paMipLevelSizes[0], /* fAllocMipLevels = */ true); 1284 1284 } 1285 1285 … … 1351 1351 { 1352 1352 /* Create the host surface. */ 1353 /** @todo fGBO = true flag. */1354 1353 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, 1355 1354 pCmd->multisampleCount, pCmd->autogenFilter, 1356 pCmd->numMipLevels, &pCmd->size );1355 pCmd->numMipLevels, &pCmd->size, /* fAllocMipLevels = */ false); 1357 1356 } 1358 1357 } … … 1469 1468 1470 1469 1470 static int vmsvgaR3TransferSurfaceLevel(PVGASTATECC pThisCC, 1471 PVMSVGAMOB pMob, 1472 SVGA3dSurfaceImageId const *pImage, 1473 SVGA3dBox const *pBox, 1474 SVGA3dTransferType enmTransfer) 1475 { 1476 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1477 1478 VMSVGA3D_SURFACE_MAP enmMapType; 1479 if (enmTransfer == SVGA3D_WRITE_HOST_VRAM) 1480 enmMapType = VMSVGA3D_SURFACE_MAP_WRITE_DISCARD; 1481 else if (enmTransfer == SVGA3D_READ_HOST_VRAM) 1482 enmMapType = VMSVGA3D_SURFACE_MAP_READ; 1483 else 1484 AssertFailedReturn(VERR_INVALID_PARAMETER); 1485 1486 VMSGA3D_BOX_DIMENSIONS dims; 1487 int rc = vmsvga3dGetBoxDimensions(pThisCC, pImage, pBox, &dims); 1488 AssertRCReturn(rc, rc); 1489 1490 VMSVGA3D_MAPPED_SURFACE map; 1491 rc = vmsvga3dSurfaceMap(pThisCC, pImage, pBox, enmMapType, &map); 1492 if (RT_SUCCESS(rc)) 1493 { 1494 /* Copy mapped surface <-> MOB. */ 1495 uint8_t *pu8Map = (uint8_t *)map.pvData; 1496 uint32_t offMob = dims.offSubresource + dims.offBox; 1497 for (uint32_t z = 0; z < dims.cDepth; ++z) 1498 { 1499 for (uint32_t y = 0; y < dims.cyBlocks; ++y) 1500 { 1501 if (enmTransfer == SVGA3D_READ_HOST_VRAM) 1502 rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow); 1503 else 1504 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow); 1505 if (RT_FAILURE(rc)) 1506 break; 1507 1508 pu8Map += map.cbRowPitch; 1509 offMob += dims.cbPitch; 1510 } 1511 } 1512 1513 // vmsvga3dMapWriteBmpFile(&map, "Dynamic"); 1514 1515 bool const fWritten = (enmTransfer == SVGA3D_WRITE_HOST_VRAM); 1516 vmsvga3dSurfaceUnmap(pThisCC, pImage, &map, fWritten); 1517 } 1518 1519 return rc; 1520 } 1521 1522 1471 1523 /* SVGA_3D_CMD_UPDATE_GB_IMAGE 1101 */ 1472 static void vmsvga3dCmdUpdateGBImage(PVGASTATECC pThisCC, uint32_t idDXContext,SVGA3dCmdUpdateGBImage const *pCmd)1473 { 1474 // 1524 static void vmsvga3dCmdUpdateGBImage(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBImage const *pCmd) 1525 { 1526 //ASMBreakpoint(); 1475 1527 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1476 1528 1477 1529 LogFlowFunc(("sid=%u @%u,%u,%u %ux%ux%u\n", 1478 1530 pCmd->image.sid, pCmd->box.x, pCmd->box.y, pCmd->box.z, pCmd->box.w, pCmd->box.h, pCmd->box.d)); 1531 1532 /* 1533 SVGA3dSurfaceFormat format; 1534 SVGA3dSurface1Flags surface1Flags; 1535 uint32 numMipLevels; 1536 uint32 multisampleCount; 1537 SVGA3dTextureFilter autogenFilter; 1538 SVGA3dSize size; 1539 SVGAMobId mobid; 1540 uint32 arraySize; 1541 uint32 mobPitch; 1542 SVGA3dSurface2Flags surface2Flags; 1543 uint8 multisamplePattern; 1544 uint8 qualityLevel; 1545 uint16 bufferByteStride; 1546 float minLOD; 1547 */ 1479 1548 1480 1549 /* "update a surface from its backing MOB." */ … … 1487 1556 if (pMob) 1488 1557 { 1489 VMSVGA3D_MAPPED_SURFACE map; 1490 /** @todo vmsvga3dSurfaceMap */ 1491 rc = pSvgaR3State->pFuncsMap->pfnSurfaceMap(pThisCC, idDXContext, &pCmd->image, &pCmd->box, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map); 1492 if (RT_SUCCESS(rc)) 1558 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &pCmd->image, &pCmd->box, SVGA3D_WRITE_HOST_VRAM); 1559 AssertRC(rc); 1560 } 1561 } 1562 } 1563 1564 1565 /* SVGA_3D_CMD_UPDATE_GB_SURFACE 1102 */ 1566 static void vmsvga3dCmdUpdateGBSurface(PVGASTATECC pThisCC, SVGA3dCmdUpdateGBSurface const *pCmd) 1567 { 1568 //ASMBreakpoint(); 1569 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1570 1571 LogFlowFunc(("sid=%u\n", 1572 pCmd->sid)); 1573 1574 /* "update a surface from its backing MOB." */ 1575 SVGAOTableSurfaceEntry entrySurface; 1576 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 1577 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface)); 1578 if (RT_SUCCESS(rc)) 1579 { 1580 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid); 1581 if (pMob) 1582 { 1583 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 1584 ? SVGA3D_MAX_SURFACE_FACES 1585 : RT_MAX(entrySurface.arraySize, 1); 1586 for (uint32_t iArray = 0; iArray < arraySize; ++iArray) 1493 1587 { 1494 /* Copy MOB -> mapped surface. */ 1495 uint32_t offSrc = pCmd->box.x * map.cbPixel 1496 + pCmd->box.y * entrySurface.size.width * map.cbPixel 1497 + pCmd->box.z * entrySurface.size.height * entrySurface.size.width * map.cbPixel; 1498 uint8_t *pu8Dst = (uint8_t *)map.pvData; 1499 for (uint32_t z = 0; z < pCmd->box.d; ++z) 1588 for (uint32_t iMipmap = 0; iMipmap < entrySurface.numMipLevels; ++iMipmap) 1500 1589 { 1501 for (uint32_t y = 0; y < pCmd->box.h; ++y) 1502 { 1503 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offSrc, pu8Dst, pCmd->box.w * map.cbPixel); 1504 if (RT_FAILURE(rc)) 1505 break; 1506 1507 pu8Dst += map.cbRowPitch; 1508 offSrc += entrySurface.size.width * map.cbPixel; 1509 } 1510 1511 pu8Dst += map.cbDepthPitch; 1512 offSrc += entrySurface.size.height * entrySurface.size.width * map.cbPixel; 1590 SVGA3dSurfaceImageId image; 1591 image.sid = pCmd->sid; 1592 image.face = iArray; 1593 image.mipmap = iMipmap; 1594 1595 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_WRITE_HOST_VRAM); 1596 AssertRCBreak(rc); 1513 1597 } 1514 1515 // vmsvga3dMapWriteBmpFile(&map, "Dynamic"); 1516 1517 pSvgaR3State->pFuncsMap->pfnSurfaceUnmap(pThisCC, &pCmd->image, &map, /* fWritten = */true); 1598 } 1599 } 1600 } 1601 } 1602 1603 1604 /* SVGA_3D_CMD_READBACK_GB_IMAGE 1103 */ 1605 static void vmsvga3dCmdReadbackGBImage(PVGASTATECC pThisCC, SVGA3dCmdReadbackGBImage const *pCmd) 1606 { 1607 //ASMBreakpoint(); 1608 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1609 1610 LogFlowFunc(("sid=%u, face=%u, mipmap=%u\n", 1611 pCmd->image.sid, pCmd->image.face, pCmd->image.mipmap)); 1612 1613 /* Read a surface to its backing MOB. */ 1614 SVGAOTableSurfaceEntry entrySurface; 1615 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 1616 pCmd->image.sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface)); 1617 if (RT_SUCCESS(rc)) 1618 { 1619 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid); 1620 if (pMob) 1621 { 1622 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &pCmd->image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM); 1623 AssertRC(rc); 1624 } 1625 } 1626 } 1627 1628 1629 /* SVGA_3D_CMD_READBACK_GB_SURFACE 1104 */ 1630 static void vmsvga3dCmdReadbackGBSurface(PVGASTATECC pThisCC, SVGA3dCmdReadbackGBSurface const *pCmd) 1631 { 1632 //ASMBreakpoint(); 1633 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1634 1635 LogFlowFunc(("sid=%u\n", 1636 pCmd->sid)); 1637 1638 /* Read a surface to its backing MOB. */ 1639 SVGAOTableSurfaceEntry entrySurface; 1640 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 1641 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface)); 1642 if (RT_SUCCESS(rc)) 1643 { 1644 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid); 1645 if (pMob) 1646 { 1647 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 1648 ? SVGA3D_MAX_SURFACE_FACES 1649 : RT_MAX(entrySurface.arraySize, 1); 1650 for (uint32_t iArray = 0; iArray < arraySize; ++iArray) 1651 { 1652 for (uint32_t iMipmap = 0; iMipmap < entrySurface.numMipLevels; ++iMipmap) 1653 { 1654 SVGA3dSurfaceImageId image; 1655 image.sid = pCmd->sid; 1656 image.face = iArray; 1657 image.mipmap = iMipmap; 1658 1659 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM); 1660 AssertRCBreak(rc); 1661 } 1518 1662 } 1519 1663 } … … 1742 1886 /* Copy the screen target surface to the memory buffer. */ 1743 1887 VMSVGA3D_MAPPED_SURFACE map; 1744 rc = pSvgaR3State->pFuncsMap->pfnSurfaceMap(pThisCC, SVGA_ID_INVALID, &entryScreenTarget.image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);1888 rc = vmsvga3dSurfaceMap(pThisCC, &entryScreenTarget.image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map); 1745 1889 if (RT_SUCCESS(rc)) 1746 1890 { … … 1759 1903 } 1760 1904 1761 pSvgaR3State->pFuncsMap->pfnSurfaceUnmap(pThisCC, &entryScreenTarget.image, &map, /* fWritten = */ false);1905 vmsvga3dSurfaceUnmap(pThisCC, &entryScreenTarget.image, &map, /* fWritten = */ false); 1762 1906 1763 1907 vmsvgaR3UpdateScreen(pThisCC, pScreen, pCmd->rect.x, pCmd->rect.y, pCmd->rect.w, pCmd->rect.h); … … 1791 1935 entry.arraySize = pCmd->arraySize; 1792 1936 // entry.mobPitch = 0; 1937 // ... 1793 1938 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 1794 1939 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry)); … … 1796 1941 { 1797 1942 /* Create the host surface. */ 1798 /** @todo fGBO = true flag.*/1943 /** @todo SVGAOTableSurfaceEntry as input parameter? */ 1799 1944 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, 1800 1945 pCmd->multisampleCount, pCmd->autogenFilter, 1801 pCmd->numMipLevels, &pCmd->size );1946 pCmd->numMipLevels, &pCmd->size, /* fAllocMipLevels = */ false); 1802 1947 } 1803 1948 } … … 1807 1952 static void vmsvga3dCmdDefineGBMob64(PVGASTATECC pThisCC, SVGA3dCmdDefineGBMob64 const *pCmd) 1808 1953 { 1809 // 1954 //ASMBreakpoint(); 1810 1955 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1811 1956 … … 1965 2110 1966 2111 /* SVGA_3D_CMD_DX_READBACK_CONTEXT 1146 */ 1967 static int vmsvga3dCmdDXReadbackContext(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackContext const *pCmd, uint32_t cbCmd) 1968 { 1969 #ifdef VMSVGA3D_DX 1970 ASMBreakpoint(); 1971 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1972 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 1973 return vmsvga3dDXReadbackContext(pThisCC, idDXContext); 1974 #else 1975 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); 2112 static int vmsvga3dCmdDXReadbackContext(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackContext const *pCmd, uint32_t cbCmd) 2113 { 2114 #ifdef VMSVGA3D_DX 2115 //ASMBreakpoint(); 2116 RT_NOREF(cbCmd); 2117 2118 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2119 2120 /* "Request that the device flush the contents back into guest memory." */ 2121 SVGAOTableDXContextEntry entry; 2122 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_DXCONTEXT], 2123 pCmd->cid, sizeof(SVGAOTableDXContextEntry), &entry, sizeof(entry)); 2124 if (RT_SUCCESS(rc)) 2125 { 2126 if (entry.mobid != SVGA_ID_INVALID) 2127 { 2128 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entry.mobid); 2129 if (pMob) 2130 { 2131 /* Get the content. */ 2132 SVGADXContextMobFormat *pSvgaDXContext = (SVGADXContextMobFormat *)RTMemAlloc(sizeof(SVGADXContextMobFormat)); 2133 if (pSvgaDXContext) 2134 { 2135 rc = vmsvga3dDXReadbackContext(pThisCC, pCmd->cid, pSvgaDXContext); 2136 if (RT_SUCCESS(rc)) 2137 rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, 0, pSvgaDXContext, sizeof(SVGADXContextMobFormat)); 2138 2139 RTMemFree(pSvgaDXContext); 2140 } 2141 else 2142 rc = VERR_NO_MEMORY; 2143 } 2144 } 2145 } 2146 2147 return rc; 2148 #else 2149 RT_NOREF(pThisCC, pCmd, cbCmd); 1976 2150 return VERR_NOT_SUPPORTED; 1977 2151 #endif … … 2084 2258 { 2085 2259 #ifdef VMSVGA3D_DX 2086 ASMBreakpoint(); 2087 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2088 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 2089 return vmsvga3dDXDrawInstanced(pThisCC, idDXContext); 2260 //ASMBreakpoint(); 2261 RT_NOREF(cbCmd); 2262 return vmsvga3dDXDrawInstanced(pThisCC, idDXContext, pCmd); 2090 2263 #else 2091 2264 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); … … 2099 2272 { 2100 2273 #ifdef VMSVGA3D_DX 2101 ASMBreakpoint(); 2102 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2103 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 2104 return vmsvga3dDXDrawIndexedInstanced(pThisCC, idDXContext); 2274 //ASMBreakpoint(); 2275 RT_NOREF(cbCmd); 2276 return vmsvga3dDXDrawIndexedInstanced(pThisCC, idDXContext, pCmd); 2105 2277 #else 2106 2278 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); … … 2491 2663 2492 2664 /* SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE 1182 */ 2493 static int vmsvga3dCmdDXUpdateSubResource(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXUpdateSubResource const *pCmd, uint32_t cbCmd) 2494 { 2495 #ifdef VMSVGA3D_DX 2496 ASMBreakpoint(); 2497 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2498 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 2499 return vmsvga3dDXUpdateSubResource(pThisCC, idDXContext); 2500 #else 2501 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); 2665 static int vmsvga3dCmdDXUpdateSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXUpdateSubResource const *pCmd, uint32_t cbCmd) 2666 { 2667 #ifdef VMSVGA3D_DX 2668 //ASMBreakpoint(); 2669 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2670 RT_NOREF(cbCmd); 2671 2672 LogFlowFunc(("sid=%u, subResource=%u, box=%d,%d,%d %ux%ux%u\n", 2673 pCmd->sid, pCmd->subResource, pCmd->box.x, pCmd->box.y, pCmd->box.z, pCmd->box.w, pCmd->box.h, pCmd->box.z)); 2674 2675 /* "Inform the device that the guest-contents have been updated." */ 2676 SVGAOTableSurfaceEntry entrySurface; 2677 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 2678 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface)); 2679 if (RT_SUCCESS(rc)) 2680 { 2681 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid); 2682 if (pMob) 2683 { 2684 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 2685 ? SVGA3D_MAX_SURFACE_FACES 2686 : RT_MAX(entrySurface.arraySize, 1); 2687 ASSERT_GUEST_RETURN(pCmd->subResource < arraySize * entrySurface.numMipLevels, VERR_INVALID_PARAMETER); 2688 /* pCmd->box will be verified by the mapping function. */ 2689 RT_UNTRUSTED_VALIDATED_FENCE(); 2690 2691 /** @todo Mapping functions should use subresource index rather than SVGA3dSurfaceImageId? */ 2692 SVGA3dSurfaceImageId image; 2693 image.sid = pCmd->sid; 2694 vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &image.mipmap, &image.face); 2695 2696 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, &pCmd->box, SVGA3D_WRITE_HOST_VRAM); 2697 AssertRC(rc); 2698 } 2699 } 2700 2701 return rc; 2702 #else 2703 RT_NOREF(pThisCC, pCmd, cbCmd); 2502 2704 return VERR_NOT_SUPPORTED; 2503 2705 #endif … … 2506 2708 2507 2709 /* SVGA_3D_CMD_DX_READBACK_SUBRESOURCE 1183 */ 2508 static int vmsvga3dCmdDXReadbackSubResource(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXReadbackSubResource const *pCmd, uint32_t cbCmd) 2509 { 2510 #ifdef VMSVGA3D_DX 2511 ASMBreakpoint(); 2512 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2513 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 2514 return vmsvga3dDXReadbackSubResource(pThisCC, idDXContext); 2515 #else 2516 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); 2710 static int vmsvga3dCmdDXReadbackSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackSubResource const *pCmd, uint32_t cbCmd) 2711 { 2712 #ifdef VMSVGA3D_DX 2713 //ASMBreakpoint(); 2714 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2715 RT_NOREF(cbCmd); 2716 2717 LogFlowFunc(("sid=%u, subResource=%u\n", 2718 pCmd->sid, pCmd->subResource)); 2719 2720 /* "Request the device to flush the dirty contents into the guest." */ 2721 SVGAOTableSurfaceEntry entrySurface; 2722 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 2723 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface)); 2724 if (RT_SUCCESS(rc)) 2725 { 2726 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid); 2727 if (pMob) 2728 { 2729 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 2730 ? SVGA3D_MAX_SURFACE_FACES 2731 : RT_MAX(entrySurface.arraySize, 1); 2732 ASSERT_GUEST_RETURN(pCmd->subResource < arraySize * entrySurface.numMipLevels, VERR_INVALID_PARAMETER); 2733 RT_UNTRUSTED_VALIDATED_FENCE(); 2734 2735 /** @todo Mapping functions should use subresource index rather than SVGA3dSurfaceImageId? */ 2736 SVGA3dSurfaceImageId image; 2737 image.sid = pCmd->sid; 2738 vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &image.mipmap, &image.face); 2739 2740 rc = vmsvgaR3TransferSurfaceLevel(pThisCC, pMob, &image, /* all pBox = */ NULL, SVGA3D_READ_HOST_VRAM); 2741 AssertRC(rc); 2742 } 2743 } 2744 2745 return rc; 2746 #else 2747 RT_NOREF(pThisCC, pCmd, cbCmd); 2517 2748 return VERR_NOT_SUPPORTED; 2518 2749 #endif … … 2521 2752 2522 2753 /* SVGA_3D_CMD_DX_INVALIDATE_SUBRESOURCE 1184 */ 2523 static int vmsvga3dCmdDXInvalidateSubResource(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXInvalidateSubResource const *pCmd, uint32_t cbCmd) 2524 { 2525 #ifdef VMSVGA3D_DX 2526 ASMBreakpoint(); 2527 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2528 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 2529 return vmsvga3dDXInvalidateSubResource(pThisCC, idDXContext); 2530 #else 2531 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); 2754 static int vmsvga3dCmdDXInvalidateSubResource(PVGASTATECC pThisCC, SVGA3dCmdDXInvalidateSubResource const *pCmd, uint32_t cbCmd) 2755 { 2756 #ifdef VMSVGA3D_DX 2757 ASMBreakpoint(); 2758 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2759 RT_NOREF(cbCmd); 2760 2761 LogFlowFunc(("sid=%u, subResource=%u\n", 2762 pCmd->sid, pCmd->subResource)); 2763 2764 /* "Notify the device that the contents can be lost." */ 2765 SVGAOTableSurfaceEntry entrySurface; 2766 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 2767 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface)); 2768 if (RT_SUCCESS(rc)) 2769 { 2770 uint32_t iFace; 2771 uint32_t iMipmap; 2772 vmsvga3dCalcMipmapAndFace(entrySurface.numMipLevels, pCmd->subResource, &iMipmap, &iFace); 2773 vmsvga3dSurfaceInvalidate(pThisCC, pCmd->sid, iFace, iMipmap); 2774 } 2775 2776 return rc; 2777 #else 2778 RT_NOREF(pThisCC, pCmd, cbCmd); 2532 2779 return VERR_NOT_SUPPORTED; 2533 2780 #endif … … 2912 3159 2913 3160 /* SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER 1210 */ 2914 static int vmsvga3dCmdDXTransferFromBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXTransferFromBuffer const *pCmd, uint32_t cbCmd) 2915 { 2916 #ifdef VMSVGA3D_DX 2917 ASMBreakpoint(); 2918 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2919 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 2920 return vmsvga3dDXTransferFromBuffer(pThisCC, idDXContext); 2921 #else 2922 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); 3161 static int vmsvga3dCmdDXTransferFromBuffer(PVGASTATECC pThisCC, SVGA3dCmdDXTransferFromBuffer const *pCmd, uint32_t cbCmd) 3162 { 3163 #ifdef VMSVGA3D_DX 3164 //ASMBreakpoint(); 3165 RT_NOREF(cbCmd); 3166 3167 /* Plan: 3168 * - map the buffer; 3169 * - map the surface; 3170 * - copy from buffer map to the surface map. 3171 */ 3172 3173 int rc; 3174 3175 SVGA3dSurfaceImageId imageBuffer; 3176 imageBuffer.sid = pCmd->srcSid; 3177 imageBuffer.face = 0; 3178 imageBuffer.mipmap = 0; 3179 3180 SVGA3dSurfaceImageId imageSurface; 3181 imageSurface.sid = pCmd->destSid; 3182 rc = vmsvga3dCalcSurfaceMipmapAndFace(pThisCC, pCmd->destSid, pCmd->destSubResource, &imageSurface.mipmap, &imageSurface.face); 3183 AssertRCReturn(rc, rc); 3184 3185 /* 3186 * Map the buffer. 3187 */ 3188 VMSVGA3D_MAPPED_SURFACE mapBuffer; 3189 rc = vmsvga3dSurfaceMap(pThisCC, &imageBuffer, NULL, VMSVGA3D_SURFACE_MAP_READ, &mapBuffer); 3190 if (RT_SUCCESS(rc)) 3191 { 3192 /* 3193 * Map the surface. 3194 */ 3195 VMSVGA3D_MAPPED_SURFACE mapSurface; 3196 rc = vmsvga3dSurfaceMap(pThisCC, &imageSurface, &pCmd->destBox, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &mapSurface); 3197 if (RT_SUCCESS(rc)) 3198 { 3199 /* 3200 * Copy the mapped buffer to the surface. 3201 */ 3202 uint8_t const *pu8Buffer = (uint8_t *)mapBuffer.pvData; 3203 uint32_t const cbBuffer = mapBuffer.box.w * mapBuffer.cbPixel; 3204 3205 if (pCmd->srcOffset <= cbBuffer) 3206 { 3207 RT_UNTRUSTED_VALIDATED_FENCE(); 3208 uint8_t const *pu8BufferBegin = pu8Buffer; 3209 uint8_t const *pu8BufferEnd = pu8Buffer + (cbBuffer - pCmd->srcOffset); 3210 3211 pu8Buffer += pCmd->srcOffset; 3212 3213 uint8_t *pu8Surface = (uint8_t *)mapSurface.pvData; 3214 3215 uint32_t const cbWidth = mapSurface.box.w * mapSurface.cbPixel; 3216 for (uint32_t z = 0; z < mapSurface.box.d && RT_SUCCESS(rc); ++z) 3217 { 3218 uint8_t const *pu8BufferRow = pu8Buffer; 3219 uint8_t *pu8SurfaceRow = pu8Surface; 3220 for (uint32_t y = 0; y < mapSurface.box.h; ++y) 3221 { 3222 ASSERT_GUEST_STMT_BREAK( (uintptr_t)pu8BufferRow >= (uintptr_t)pu8BufferBegin 3223 && (uintptr_t)pu8BufferRow < (uintptr_t)pu8BufferEnd 3224 && (uintptr_t)(pu8BufferRow + cbWidth) > (uintptr_t)pu8BufferBegin 3225 && (uintptr_t)(pu8BufferRow + cbWidth) <= (uintptr_t)pu8BufferEnd, 3226 rc = VERR_INVALID_PARAMETER); 3227 3228 memcpy(pu8SurfaceRow, pu8BufferRow, cbWidth); 3229 3230 pu8SurfaceRow += mapSurface.cbRowPitch; 3231 pu8BufferRow += pCmd->srcPitch; 3232 } 3233 3234 pu8Buffer += pCmd->srcSlicePitch; 3235 pu8Surface += mapSurface.cbDepthPitch; 3236 } 3237 } 3238 else 3239 ASSERT_GUEST_FAILED_STMT(rc = VERR_INVALID_PARAMETER); 3240 3241 vmsvga3dSurfaceUnmap(pThisCC, &imageSurface, &mapSurface, true); 3242 } 3243 3244 vmsvga3dSurfaceUnmap(pThisCC, &imageBuffer, &mapBuffer, false); 3245 } 3246 3247 return rc; 3248 #else 3249 RT_NOREF(pThisCC, pCmd, cbCmd); 2923 3250 return VERR_NOT_SUPPORTED; 2924 3251 #endif … … 2990 3317 { 2991 3318 #ifdef VMSVGA3D_DX 2992 ASMBreakpoint(); 2993 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 2994 RT_NOREF(pSvgaR3State, pCmd, cbCmd); 2995 return vmsvga3dDXPredTransferFromBuffer(pThisCC, idDXContext); 3319 //ASMBreakpoint(); 3320 RT_NOREF(idDXContext, cbCmd); 3321 3322 /* This command is executed in a context: "The context is implied from the command buffer header." 3323 * However the device design allows to do the transfer without a context, so re-use context-less command handler. 3324 */ 3325 SVGA3dCmdDXTransferFromBuffer cmd; 3326 cmd.srcSid = pCmd->srcSid; 3327 cmd.srcOffset = pCmd->srcOffset; 3328 cmd.srcPitch = pCmd->srcPitch; 3329 cmd.srcSlicePitch = pCmd->srcSlicePitch; 3330 cmd.destSid = pCmd->destSid; 3331 cmd.destSubResource = pCmd->destSubResource; 3332 cmd.destBox = pCmd->destBox; 3333 return vmsvga3dCmdDXTransferFromBuffer(pThisCC, &cmd, sizeof(cmd)); 2996 3334 #else 2997 3335 RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd); … … 4313 4651 SVGA3dCmdUpdateGBImage *pCmd = (SVGA3dCmdUpdateGBImage *)pvCmd; 4314 4652 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4315 vmsvga3dCmdUpdateGBImage(pThisCC, idDXContext,pCmd);4653 vmsvga3dCmdUpdateGBImage(pThisCC, pCmd); 4316 4654 break; 4317 4655 } … … 4321 4659 SVGA3dCmdUpdateGBSurface *pCmd = (SVGA3dCmdUpdateGBSurface *)pvCmd; 4322 4660 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4323 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);4661 vmsvga3dCmdUpdateGBSurface(pThisCC, pCmd); 4324 4662 break; 4325 4663 } … … 4329 4667 SVGA3dCmdReadbackGBImage *pCmd = (SVGA3dCmdReadbackGBImage *)pvCmd; 4330 4668 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4331 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);4669 vmsvga3dCmdReadbackGBImage(pThisCC, pCmd); 4332 4670 break; 4333 4671 } … … 4337 4675 SVGA3dCmdReadbackGBSurface *pCmd = (SVGA3dCmdReadbackGBSurface *)pvCmd; 4338 4676 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4339 VMSVGA_3D_CMD_NOTIMPL(); RT_NOREF(pCmd);4677 vmsvga3dCmdReadbackGBSurface(pThisCC, pCmd); 4340 4678 break; 4341 4679 } … … 4666 5004 SVGA3dCmdDXReadbackContext *pCmd = (SVGA3dCmdDXReadbackContext *)pvCmd; 4667 5005 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4668 rcParse = vmsvga3dCmdDXReadbackContext(pThisCC, idDXContext,pCmd, cbCmd);5006 rcParse = vmsvga3dCmdDXReadbackContext(pThisCC, pCmd, cbCmd); 4669 5007 break; 4670 5008 } … … 4954 5292 SVGA3dCmdDXUpdateSubResource *pCmd = (SVGA3dCmdDXUpdateSubResource *)pvCmd; 4955 5293 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4956 rcParse = vmsvga3dCmdDXUpdateSubResource(pThisCC, idDXContext,pCmd, cbCmd);5294 rcParse = vmsvga3dCmdDXUpdateSubResource(pThisCC, pCmd, cbCmd); 4957 5295 break; 4958 5296 } … … 4962 5300 SVGA3dCmdDXReadbackSubResource *pCmd = (SVGA3dCmdDXReadbackSubResource *)pvCmd; 4963 5301 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4964 rcParse = vmsvga3dCmdDXReadbackSubResource(pThisCC, idDXContext,pCmd, cbCmd);5302 rcParse = vmsvga3dCmdDXReadbackSubResource(pThisCC, pCmd, cbCmd); 4965 5303 break; 4966 5304 } … … 4970 5308 SVGA3dCmdDXInvalidateSubResource *pCmd = (SVGA3dCmdDXInvalidateSubResource *)pvCmd; 4971 5309 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 4972 rcParse = vmsvga3dCmdDXInvalidateSubResource(pThisCC, idDXContext,pCmd, cbCmd);5310 rcParse = vmsvga3dCmdDXInvalidateSubResource(pThisCC, pCmd, cbCmd); 4973 5311 break; 4974 5312 } … … 5178 5516 SVGA3dCmdDXTransferFromBuffer *pCmd = (SVGA3dCmdDXTransferFromBuffer *)pvCmd; 5179 5517 VMSVGAFIFO_CHECK_3D_CMD_MIN_SIZE_BREAK(sizeof(*pCmd)); 5180 rcParse = vmsvga3dCmdDXTransferFromBuffer(pThisCC, idDXContext,pCmd, cbCmd);5518 rcParse = vmsvga3dCmdDXTransferFromBuffer(pThisCC, pCmd, cbCmd); 5181 5519 break; 5182 5520 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r90852 r91361 3324 3324 if (RT_SUCCESS(rc)) 3325 3325 { 3326 LogFunc(("status %RX32 errorOffset %RX32 id %RX64 flags %RX32 length %RX32 ptr %RX64 offset %RX32 dxContext %RX32 (%RX32 %RX32 %RX32 %RX32 %RX32 %RX32)\n", 3327 pCmdBuf->hdr.status, 3328 pCmdBuf->hdr.errorOffset, 3329 pCmdBuf->hdr.id, 3330 pCmdBuf->hdr.flags, 3331 pCmdBuf->hdr.length, 3332 pCmdBuf->hdr.ptr.pa, 3333 pCmdBuf->hdr.offset, 3334 pCmdBuf->hdr.dxContext, 3335 pCmdBuf->hdr.mustBeZero[0], 3336 pCmdBuf->hdr.mustBeZero[1], 3337 pCmdBuf->hdr.mustBeZero[2], 3338 pCmdBuf->hdr.mustBeZero[3], 3339 pCmdBuf->hdr.mustBeZero[4], 3340 pCmdBuf->hdr.mustBeZero[5])); 3341 3326 3342 /* Verify the command buffer header. */ 3327 3343 if (RT_LIKELY( pCmdBuf->hdr.status == SVGA_CB_STATUS_NONE … … 5827 5843 5828 5844 extern VMSVGA3DBACKENDDESC const g_BackendLegacy; 5829 #if def VMSVGA3D_DX5845 #if defined(VMSVGA3D_DX_BACKEND) 5830 5846 extern VMSVGA3DBACKENDDESC const g_BackendDX; 5831 5847 #endif … … 5857 5873 5858 5874 VMSVGA3DBACKENDDESC const *pBackend = NULL; 5859 #if def VMSVGA3D_DX5875 #if defined(VMSVGA3D_DX_BACKEND) 5860 5876 if (pThis->fVMSVGA10) 5861 5877 pBackend = &g_BackendDX; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h
r88904 r91361 648 648 649 649 #ifdef VBOX_WITH_VMSVGA3D 650 int vmsvgaR3UpdateGBSurface(PVGASTATECC pThisCC, uint32_t idDXContext,SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBox);651 int vmsvgaR3UpdateGBSurfaceEx(PVGASTATECC pThisCC, uint32_t idDXContext,SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBoxDst, SVGA3dPoint const *pPtSrc);650 int vmsvgaR3UpdateGBSurface(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBox); 651 int vmsvgaR3UpdateGBSurfaceEx(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBoxDst, SVGA3dPoint const *pPtSrc); 652 652 #endif 653 653 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp
r88904 r91361 153 153 154 154 155 int vmsvga3dDXReadbackContext(PVGASTATECC pThisCC, uint32_t idDXContext )155 int vmsvga3dDXReadbackContext(PVGASTATECC pThisCC, uint32_t idDXContext, SVGADXContextMobFormat *pSvgaDXContext) 156 156 { 157 157 int rc; … … 166 166 167 167 rc = pSvgaR3State->pFuncsDX->pfnDXReadbackContext(pThisCC, pDXContext); 168 if (RT_SUCCESS(rc)) 169 memcpy(pSvgaDXContext, &pDXContext->svgaDXContext, sizeof(*pSvgaDXContext)); 168 170 return rc; 169 171 } … … 292 294 ASSERT_GUEST_RETURN(pDXContext->cot.paSampler, VERR_INVALID_STATE); 293 295 for (uint32_t i = 0; i < cSamplerId; ++i) 294 ASSERT_GUEST_RETURN(paSamplerId[i] < pDXContext->cot.cSampler, VERR_INVALID_PARAMETER); 296 { 297 SVGA3dSamplerId const samplerId = paSamplerId[i]; 298 ASSERT_GUEST_RETURN( samplerId < pDXContext->cot.cSampler 299 || samplerId == SVGA_ID_INVALID, VERR_INVALID_PARAMETER); 300 } 295 301 RT_UNTRUSTED_VALIDATED_FENCE(); 296 302 … … 320 326 image.mipmap = 0; 321 327 VMSVGA3D_MAPPED_SURFACE map; 322 int rc2 = pSvgaR3State->pFuncsMap->pfnSurfaceMap(pThisCC, idDXContext, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);328 int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map); 323 329 if (RT_SUCCESS(rc2)) 324 330 { 325 331 vmsvga3dMapWriteBmpFile(&map, "rt-"); 326 pSvgaR3State->pFuncsMap->pfnSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);332 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false); 327 333 } 328 334 #endif … … 348 354 349 355 350 int vmsvga3dDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext )356 int vmsvga3dDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstanced const *pCmd) 351 357 { 352 358 int rc; … … 360 366 AssertRCReturn(rc, rc); 361 367 362 rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstanced(pThisCC, pDXContext); 363 return rc; 364 } 365 366 367 int vmsvga3dDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext) 368 rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstanced(pThisCC, pDXContext, 369 pCmd->vertexCountPerInstance, pCmd->instanceCount, pCmd->startVertexLocation, pCmd->startInstanceLocation); 370 return rc; 371 } 372 373 374 int vmsvga3dDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstanced const *pCmd) 368 375 { 369 376 int rc; … … 377 384 AssertRCReturn(rc, rc); 378 385 379 rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstanced(pThisCC, pDXContext); 386 rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstanced(pThisCC, pDXContext, 387 pCmd->indexCountPerInstance, pCmd->instanceCount, pCmd->startIndexLocation, pCmd->baseVertexLocation, pCmd->startInstanceLocation); 380 388 return rc; 381 389 } … … 827 835 AssertRCReturn(rc, rc); 828 836 837 /** @todo Memcpy if both resources do not have the hardware resource. */ 838 829 839 rc = pSvgaR3State->pFuncsDX->pfnDXPredCopyRegion(pThisCC, pDXContext, pCmd->dstSid, pCmd->dstSubResource, pCmd->srcSid, pCmd->srcSubResource, &pCmd->box); 830 840 return rc; … … 885 895 886 896 rc = pSvgaR3State->pFuncsDX->pfnDXGenMips(pThisCC, pDXContext, shaderResourceViewId); 887 return rc;888 }889 890 891 int vmsvga3dDXUpdateSubResource(PVGASTATECC pThisCC, uint32_t idDXContext)892 {893 int rc;894 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;895 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXUpdateSubResource, VERR_INVALID_STATE);896 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;897 AssertReturn(p3dState, VERR_INVALID_STATE);898 899 PVMSVGA3DDXCONTEXT pDXContext;900 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);901 AssertRCReturn(rc, rc);902 903 rc = pSvgaR3State->pFuncsDX->pfnDXUpdateSubResource(pThisCC, pDXContext);904 return rc;905 }906 907 908 int vmsvga3dDXReadbackSubResource(PVGASTATECC pThisCC, uint32_t idDXContext)909 {910 int rc;911 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;912 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXReadbackSubResource, VERR_INVALID_STATE);913 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;914 AssertReturn(p3dState, VERR_INVALID_STATE);915 916 PVMSVGA3DDXCONTEXT pDXContext;917 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);918 AssertRCReturn(rc, rc);919 920 rc = pSvgaR3State->pFuncsDX->pfnDXReadbackSubResource(pThisCC, pDXContext);921 return rc;922 }923 924 925 int vmsvga3dDXInvalidateSubResource(PVGASTATECC pThisCC, uint32_t idDXContext)926 {927 int rc;928 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;929 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXInvalidateSubResource, VERR_INVALID_STATE);930 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;931 AssertReturn(p3dState, VERR_INVALID_STATE);932 933 PVMSVGA3DDXCONTEXT pDXContext;934 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);935 AssertRCReturn(rc, rc);936 937 rc = pSvgaR3State->pFuncsDX->pfnDXInvalidateSubResource(pThisCC, pDXContext);938 897 return rc; 939 898 } … … 1400 1359 AssertRCReturn(rc, rc); 1401 1360 1361 AssertReturn(pDXContext->paShader, VERR_INVALID_STATE); 1362 1402 1363 SVGA3dShaderId const shaderId = pCmd->shaderId; 1403 1364 … … 1414 1375 pEntry->mobid = SVGA_ID_INVALID; 1415 1376 1416 if (!pDXContext->paShader) 1417 { 1418 /* Create host array for information abput shaders. */ 1419 pDXContext->paShader = (PVMSVGA3DSHADER)RTMemAllocZ(pDXContext->cot.cShader * sizeof(VMSVGA3DSHADER)); 1420 AssertReturn(pDXContext->paShader, VERR_NO_MEMORY); 1421 for (uint32_t i = 0; i < pDXContext->cot.cShader; ++i) 1422 pDXContext->paShader[i].id = SVGA_ID_INVALID; 1423 } 1377 /** @todo Remove from here. */ 1378 // if (!pDXContext->paShader) 1379 // { 1380 // /* Create host array for information about shaders. */ 1381 // pDXContext->paShader = (PVMSVGA3DSHADER)RTMemAllocZ(pDXContext->cot.cShader * sizeof(VMSVGA3DSHADER)); 1382 // AssertReturn(pDXContext->paShader, VERR_NO_MEMORY); 1383 // for (uint32_t i = 0; i < pDXContext->cot.cShader; ++i) 1384 // pDXContext->paShader[i].id = SVGA_ID_INVALID; 1385 // } 1424 1386 1425 1387 PVMSVGA3DSHADER pShader = &pDXContext->paShader[shaderId]; … … 1438 1400 pShader->u.pvBackendShader = NULL; 1439 1401 1440 rc = pSvgaR3State->pFuncsDX->pfnDXDefineShader(pThisCC, pDXContext, pShader);1402 rc = pSvgaR3State->pFuncsDX->pfnDXDefineShader(pThisCC, pDXContext, shaderId, pEntry); 1441 1403 return rc; 1442 1404 } … … 1668 1630 1669 1631 uint32_t cEntries = 0; 1632 uint32_t cValidEntries = 0; 1670 1633 if (RT_SUCCESS(rc)) 1671 1634 { … … 1687 1650 1688 1651 cEntries = cbCOT / s_acbEntry[pCmd->type]; 1689 uint32_t const cValidEntries = validSizeInBytes / s_acbEntry[pCmd->type]; 1690 1691 rc = pSvgaR3State->pFuncsDX->pfnDXSetCOTable(pThisCC, pDXContext, pCmd->type, cEntries, cValidEntries); 1652 cValidEntries = validSizeInBytes / s_acbEntry[pCmd->type]; 1692 1653 } 1693 1654 … … 1742 1703 pDXContext->cot.paShader = (SVGACOTableDXShaderEntry *)pvCOT; 1743 1704 pDXContext->cot.cShader = cEntries; 1705 1706 /* Create host array for information about shaders. */ 1707 RTMemFree(pDXContext->paShader); 1708 pDXContext->paShader = NULL; 1709 1710 if (pDXContext->cot.cShader) 1711 { 1712 pDXContext->paShader = (PVMSVGA3DSHADER)RTMemAllocZ(pDXContext->cot.cShader * sizeof(VMSVGA3DSHADER)); 1713 AssertReturn(pDXContext->paShader, VERR_NO_MEMORY); 1714 for (uint32_t i = 0; i < pDXContext->cot.cShader; ++i) 1715 pDXContext->paShader[i].id = SVGA_ID_INVALID; 1716 } 1744 1717 break; 1745 1718 case SVGA_COTABLE_UAVIEW: … … 1753 1726 vmsvgaR3MobBackingStoreDelete(pSvgaR3State, pMob); 1754 1727 1728 /* Notify the backend. */ 1729 if (RT_SUCCESS(rc)) 1730 rc = pSvgaR3State->pFuncsDX->pfnDXSetCOTable(pThisCC, pDXContext, pCmd->type, cValidEntries); 1731 1755 1732 return rc; 1756 1733 } … … 1796 1773 1797 1774 1798 int vmsvga3dDXTransferFromBuffer(PVGASTATECC pThisCC, uint32_t idDXContext)1799 {1800 int rc;1801 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;1802 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXTransferFromBuffer, VERR_INVALID_STATE);1803 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;1804 AssertReturn(p3dState, VERR_INVALID_STATE);1805 1806 PVMSVGA3DDXCONTEXT pDXContext;1807 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);1808 AssertRCReturn(rc, rc);1809 1810 rc = pSvgaR3State->pFuncsDX->pfnDXTransferFromBuffer(pThisCC, pDXContext);1811 return rc;1812 }1813 1814 1815 1775 int vmsvga3dDXSurfaceCopyAndReadback(PVGASTATECC pThisCC, uint32_t idDXContext) 1816 1776 { … … 1881 1841 1882 1842 1883 int vmsvga3dDXPredTransferFromBuffer(PVGASTATECC pThisCC, uint32_t idDXContext)1884 {1885 int rc;1886 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;1887 AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXPredTransferFromBuffer, VERR_INVALID_STATE);1888 PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;1889 AssertReturn(p3dState, VERR_INVALID_STATE);1890 1891 PVMSVGA3DDXCONTEXT pDXContext;1892 rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);1893 AssertRCReturn(rc, rc);1894 1895 rc = pSvgaR3State->pFuncsDX->pfnDXPredTransferFromBuffer(pThisCC, pDXContext);1896 return rc;1897 }1898 1899 1900 1843 int vmsvga3dDXMobFence64(PVGASTATECC pThisCC, uint32_t idDXContext) 1901 1844 { -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r91011 r91361 547 547 uint32_t id; /** @todo sid */ 548 548 /* Which context created the corresponding resource. 549 * SVGA_ID_INVALID means that resource has not been created yet , or has been created by the shared context.549 * SVGA_ID_INVALID means that resource has not been created yet. 550 550 * A resource has been created if VMSVGA3DSURFACE_HAS_HW_SURFACE is true. 551 551 * … … 1315 1315 { 1316 1316 *ppDXContext = NULL; 1317 if (cid == SVGA_ID_INVALID)1318 return VERR_INVALID_STATE;1319 1317 AssertReturn(cid < pState->cDXContexts, VERR_INVALID_PARAMETER); 1320 1318 PVMSVGA3DDXCONTEXT const pDXContext = pState->papDXContexts[cid]; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-savedstate.cpp
r89163 r91361 497 497 498 498 rc = vmsvga3dSurfaceDefine(pThisCC, sid, surface.surfaceFlags, surface.format, surface.multiSampleCount, 499 surface.autogenFilter, surface.cLevels, &pMipmapLevelSize[0] );499 surface.autogenFilter, surface.cLevels, &pMipmapLevelSize[0], /* fAllocMipLevels = */ true); 500 500 AssertRCReturn(rc, rc); 501 501 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
r89163 r91361 44 44 #include <d3d11.h> 45 45 46 47 /** Fake ID for the backend DX context. The context creates all shared textures. */ 48 #define DX_CID_BACKEND UINT32_C(0xfffffffe) 49 46 50 #define DX_RELEASE_ARRAY(a_Count, a_papArray) do { \ 47 51 for (uint32_t i = 0; i < (a_Count); ++i) \ … … 73 77 VMSVGA3DBACKRESTYPE enmResType; 74 78 DXGI_FORMAT enmDxgiFormat; 79 union 80 { 81 ID3D11Resource *pResource; 82 ID3D11Texture2D *pTexture2D; 83 ID3D11Texture3D *pTexture3D; 84 ID3D11Buffer *pBuffer; 85 } u; 86 87 ID3D11Texture2D *pDynamicTexture; /* For screen updates from memory. */ /** @todo One for all screens. */ 88 ID3D11Texture2D *pStagingTexture; /* For Reading the screen content. */ /** @todo One for all screens. */ 89 ID3D11Texture3D *pDynamicTexture3D; /* For screen updates from memory. */ /** @todo One for all screens. */ 90 ID3D11Texture3D *pStagingTexture3D; /* For Reading the screen content. */ /** @todo One for all screens. */ 91 92 /* Screen targets are created as shared surfaces. */ 93 HANDLE SharedHandle; /* The shared handle of this structure. */ 94 95 /* DX context which last rendered to the texture. 96 * This is only for render targets and screen targets, which can be shared between contexts. 97 * The backend context (cid == DX_CID_BACKEND) can also be a drawing context. 98 */ 99 uint32_t cidDrawing; 100 75 101 /** AVL tree containing DXSHAREDTEXTURE structures. */ 76 102 AVLU32TREE SharedTextureTree; 77 union 78 { 79 struct 80 { 81 ID3D11Resource *pResource; 82 } Resource; 83 struct 84 { 85 ID3D11Texture2D *pTexture; /* The texture for the screen content. */ 86 ID3D11Texture2D *pDynamicTexture; /* For screen updates from memory. */ /** @todo One for all screens. */ 87 ID3D11Texture2D *pStagingTexture; /* For Reading the screen content. */ /** @todo One for all screens. */ 88 /* Screen targets are created as shared surfaces. */ 89 HANDLE SharedHandle; /* The shared handle of this structure. */ 90 } ScreenTarget; 91 struct 92 { 93 ID3D11Texture2D *pTexture; /* The texture for the screen content. */ 94 ID3D11Texture2D *pDynamicTexture; /* For screen updates from memory. */ /** @todo One for every format. */ 95 ID3D11Texture2D *pStagingTexture; /* For Reading the screen content. */ /** @todo One for every format. */ 96 } Texture; 97 struct 98 { 99 ID3D11Buffer *pBuffer; 100 } Buffer; 101 } u; 103 102 104 } VMSVGA3DBACKENDSURFACE; 103 105 … … 147 149 typedef struct VMSVGA3DBACKENDDXCONTEXT 148 150 { 149 DXDEVICE device; /* D evice for the this context operation. */151 DXDEVICE device; /* DX device interfaces for this context operations. */ 150 152 151 153 /* Arrays for Context-Object Tables. Number of entries depends on COTable size. */ … … 206 208 } 207 209 208 210 #define DX_REPLACE_X8_WITH_A8 209 211 static DXGI_FORMAT vmsvgaDXSurfaceFormat2Dxgi(SVGA3dSurfaceFormat format) 210 212 { … … 218 220 switch (format) 219 221 { 222 #ifdef DX_REPLACE_X8_WITH_A8 223 case SVGA3D_X8R8G8B8: return DXGI_FORMAT_B8G8R8A8_UNORM; 224 #else 220 225 case SVGA3D_X8R8G8B8: return DXGI_FORMAT_B8G8R8X8_UNORM; 226 #endif 221 227 case SVGA3D_A8R8G8B8: return DXGI_FORMAT_B8G8R8A8_UNORM; 222 228 case SVGA3D_R5G6B5: return DXGI_FORMAT_B5G6R5_UNORM; … … 333 339 case SVGA3D_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_TYPELESS; 334 340 case SVGA3D_B8G8R8A8_UNORM_SRGB: return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; 341 #ifdef DX_REPLACE_X8_WITH_A8 342 case SVGA3D_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_TYPELESS; 343 case SVGA3D_B8G8R8X8_UNORM_SRGB: return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; 344 #else 335 345 case SVGA3D_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8X8_TYPELESS; 336 346 case SVGA3D_B8G8R8X8_UNORM_SRGB: return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; 347 #endif 337 348 case SVGA3D_Z_DF16: break; 338 349 case SVGA3D_Z_DF24: break; … … 359 370 case SVGA3D_B5G5R5A1_UNORM: return DXGI_FORMAT_B5G5R5A1_UNORM; 360 371 case SVGA3D_B8G8R8A8_UNORM: return DXGI_FORMAT_B8G8R8A8_UNORM; 372 #ifdef DX_REPLACE_X8_WITH_A8 373 case SVGA3D_B8G8R8X8_UNORM: return DXGI_FORMAT_B8G8R8A8_UNORM; 374 #else 361 375 case SVGA3D_B8G8R8X8_UNORM: return DXGI_FORMAT_B8G8R8X8_UNORM; 376 #endif 362 377 case SVGA3D_BC4_UNORM: return DXGI_FORMAT_BC4_UNORM; 363 378 case SVGA3D_BC5_UNORM: return DXGI_FORMAT_BC5_UNORM; … … 698 713 LogRel(("VMSVGA: Feature level %#x\n", pDevice->FeatureLevel)); 699 714 715 #ifdef DEBUG 716 /* Break into debugger when DX runtime detects anything unusual. */ 717 HRESULT hr2; 718 ID3D11Debug *pDebug = 0; 719 hr2 = pDevice->pDevice->QueryInterface(__uuidof(ID3D11Debug), (void**)&pDebug); 720 if (SUCCEEDED(hr2)) 721 { 722 ID3D11InfoQueue *pInfoQueue = 0; 723 hr2 = pDebug->QueryInterface(__uuidof(ID3D11InfoQueue), (void**)&pInfoQueue); 724 if (SUCCEEDED(hr2)) 725 { 726 pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true); 727 pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true); 728 pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, true); 729 730 D3D11_MESSAGE_ID saIgnoredMessageIds[] = 731 { 732 /* Message ID: Caused by: */ 733 D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH, /* Autogenerated input signatures. */ 734 }; 735 736 D3D11_INFO_QUEUE_FILTER filter; 737 RT_ZERO(filter); 738 filter.DenyList.NumIDs = RT_ELEMENTS(saIgnoredMessageIds); 739 filter.DenyList.pIDList = saIgnoredMessageIds; 740 pInfoQueue->AddStorageFilterEntries(&filter); 741 742 D3D_RELEASE(pInfoQueue); 743 } 744 D3D_RELEASE(pDebug); 745 } 746 #endif 747 700 748 IDXGIDevice *pDxgiDevice = 0; 701 749 hr = pDevice->pDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&pDxgiDevice); … … 731 779 732 780 733 static ID3D11Resource *dxResource(PVMSVGA3DSURFACE pSurface, VMSVGA3DDXCONTEXT *pDXContext) 781 DECLINLINE(bool) dxIsSurfaceShareable(PVMSVGA3DSURFACE pSurface) 782 { 783 /* It is not expected that volume textures will be shared between contexts. */ 784 if (pSurface->surfaceFlags & SVGA3D_SURFACE_VOLUME) 785 return false; 786 787 return pSurface->surfaceFlags & SVGA3D_SURFACE_SCREENTARGET 788 || pSurface->surfaceFlags & SVGA3D_SURFACE_BIND_RENDER_TARGET; 789 } 790 791 792 DXDEVICE *dxDeviceFromCid(uint32_t cid, PVMSVGA3DSTATE pState) 793 { 794 if (cid != DX_CID_BACKEND) 795 { 796 VMSVGA3DDXCONTEXT *pDXContext; 797 int rc = vmsvga3dDXContextFromCid(pState, cid, &pDXContext); 798 if (RT_SUCCESS(rc)) 799 return &pDXContext->pBackendDXContext->device; 800 } 801 else 802 return &pState->pBackend->device; 803 804 AssertFailed(); 805 return NULL; 806 } 807 808 809 static int dxDeviceFlush(DXDEVICE *pDevice) 810 { 811 /** @todo Should the flush follow the query submission? */ 812 pDevice->pImmediateContext->Flush(); 813 814 ID3D11Query *pQuery = 0; 815 D3D11_QUERY_DESC qd; 816 RT_ZERO(qd); 817 qd.Query = D3D11_QUERY_EVENT; 818 819 HRESULT hr = pDevice->pDevice->CreateQuery(&qd, &pQuery); 820 Assert(hr == S_OK); RT_NOREF(hr); 821 pDevice->pImmediateContext->End(pQuery); 822 823 BOOL queryData; 824 while (pDevice->pImmediateContext->GetData(pQuery, &queryData, sizeof(queryData), 0) != S_OK) 825 RTThreadYield(); 826 827 D3D_RELEASE(pQuery); 828 829 return VINF_SUCCESS; 830 } 831 832 833 static int dxContextWait(uint32_t cidDrawing, PVMSVGA3DSTATE pState) 834 { 835 /* Flush cidDrawing context and issue a query. */ 836 DXDEVICE *pDXDevice = dxDeviceFromCid(cidDrawing, pState); 837 return dxDeviceFlush(pDXDevice); 838 } 839 840 841 static ID3D11Resource *dxResource(PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface, VMSVGA3DDXCONTEXT *pDXContext) 734 842 { 735 843 VMSVGA3DBACKENDSURFACE *pBackendSurface = pSurface->pBackendSurface; … … 737 845 AssertFailedReturn(NULL); 738 846 739 if (pDXContext->cid == pSurface->idAssociatedContext) 740 return pBackendSurface->u.Resource.pResource; 847 uint32_t const cidRequesting = pDXContext ? pDXContext->cid : DX_CID_BACKEND; 848 if (cidRequesting == pSurface->idAssociatedContext) 849 return pBackendSurface->u.pResource; 850 851 AssertReturn(pDXContext, NULL); 741 852 742 853 /* 743 854 * Another context is requesting. 744 855 */ 745 /* Expecting this for screen targets only. */ 746 Assert(pSurface->surfaceFlags & SVGA3D_SURFACE_SCREENTARGET); 747 Assert(pSurface->idAssociatedContext == SVGA_ID_INVALID); 856 Assert(dxIsSurfaceShareable(pSurface)); 857 Assert(pSurface->idAssociatedContext == DX_CID_BACKEND); 748 858 749 859 DXSHAREDTEXTURE *pSharedTexture = (DXSHAREDTEXTURE *)RTAvlU32Get(&pBackendSurface->SharedTextureTree, pDXContext->cid); … … 753 863 AssertReturn(pDevice->pDevice, NULL); 754 864 755 AssertReturn(pBackendSurface-> u.ScreenTarget.SharedHandle, NULL);865 AssertReturn(pBackendSurface->SharedHandle, NULL); 756 866 757 867 /* This context has not yet opened the texture. */ … … 763 873 AssertReturn(fSuccess, NULL); 764 874 765 HRESULT hr = pDevice->pDevice->OpenSharedResource(pBackendSurface-> u.ScreenTarget.SharedHandle, __uuidof(ID3D11Texture2D), (void**)&pSharedTexture->pTexture);875 HRESULT hr = pDevice->pDevice->OpenSharedResource(pBackendSurface->SharedHandle, __uuidof(ID3D11Texture2D), (void**)&pSharedTexture->pTexture); 766 876 Assert(SUCCEEDED(hr)); 767 877 if (SUCCEEDED(hr)) … … 775 885 } 776 886 887 /* Wait for drawing to finish. */ 888 if (pBackendSurface->cidDrawing != SVGA_ID_INVALID) 889 { 890 if (pBackendSurface->cidDrawing != pDXContext->cid) 891 { 892 dxContextWait(pBackendSurface->cidDrawing, pState); 893 pBackendSurface->cidDrawing = SVGA_ID_INVALID; 894 } 895 } 896 777 897 return pSharedTexture->pTexture; 778 898 } 779 899 900 901 static int dxTrackRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 902 { 903 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState; 904 AssertReturn(pState, VERR_INVALID_STATE); 905 906 //ASMBreakpoint(); 907 for (int i = 0; i < RT_ELEMENTS(pDXContext->svgaDXContext.renderState.renderTargetViewIds); ++i) 908 { 909 uint32_t const renderTargetViewId = pDXContext->svgaDXContext.renderState.renderTargetViewIds[i]; 910 if (renderTargetViewId == SVGA_ID_INVALID) 911 continue; 912 913 AssertContinue(renderTargetViewId < pDXContext->cot.cRTView); 914 915 SVGACOTableDXRTViewEntry const *pRTViewEntry = &pDXContext->cot.paRTView[renderTargetViewId]; 916 917 PVMSVGA3DSURFACE pSurface; 918 int rc = vmsvga3dSurfaceFromSid(pState, pRTViewEntry->sid, &pSurface); 919 if ( RT_SUCCESS(rc) 920 && pSurface->pBackendSurface) 921 { 922 pSurface->pBackendSurface->cidDrawing = pDXContext->cid; 923 } 924 } 925 return VINF_SUCCESS; 926 } 927 928 static D3D11_BLEND dxBlendFactorAlpha(uint8_t svgaBlend) 929 { 930 /* "Blend options that end in _COLOR are not allowed." but the guest sometimes sends them. */ 931 switch (svgaBlend) 932 { 933 case SVGA3D_BLENDOP_SRCCOLOR: return D3D11_BLEND_SRC_ALPHA; 934 case SVGA3D_BLENDOP_INVSRCCOLOR: return D3D11_BLEND_INV_SRC_ALPHA; 935 case SVGA3D_BLENDOP_DESTCOLOR: return D3D11_BLEND_DEST_ALPHA; 936 case SVGA3D_BLENDOP_INVDESTCOLOR: return D3D11_BLEND_INV_DEST_ALPHA; 937 case SVGA3D_BLENDOP_SRC1COLOR: return D3D11_BLEND_SRC1_ALPHA; 938 case SVGA3D_BLENDOP_INVSRC1COLOR: return D3D11_BLEND_INV_SRC1_ALPHA; 939 default: 940 break; 941 } 942 return (D3D11_BLEND)svgaBlend; 943 } 944 945 static D3D11_BLEND dxBlendFactorColor(uint8_t svgaBlend) 946 { 947 return (D3D11_BLEND)svgaBlend; 948 } 949 950 static D3D11_BLEND_OP dxBlendOp(uint8_t svgaBlendEq) 951 { 952 return (D3D11_BLEND_OP)svgaBlendEq; 953 } 780 954 781 955 /** @todo AssertCompile for types like D3D11_COMPARISON_FUNC and SVGA3dComparisonFunc */ … … 788 962 { 789 963 BlendDesc.RenderTarget[i].BlendEnable = RT_BOOL(pEntry->perRT[i].blendEnable); 790 BlendDesc.RenderTarget[i].SrcBlend = (D3D11_BLEND)pEntry->perRT[i].srcBlend;791 BlendDesc.RenderTarget[i].DestBlend = (D3D11_BLEND)pEntry->perRT[i].destBlend;792 BlendDesc.RenderTarget[i].BlendOp = (D3D11_BLEND_OP)pEntry->perRT[i].blendOp;793 BlendDesc.RenderTarget[i].SrcBlendAlpha = (D3D11_BLEND)pEntry->perRT[i].srcBlendAlpha;794 BlendDesc.RenderTarget[i].DestBlendAlpha = (D3D11_BLEND)pEntry->perRT[i].destBlendAlpha;795 BlendDesc.RenderTarget[i].BlendOpAlpha = (D3D11_BLEND_OP)pEntry->perRT[i].blendOpAlpha;964 BlendDesc.RenderTarget[i].SrcBlend = dxBlendFactorColor(pEntry->perRT[i].srcBlend); 965 BlendDesc.RenderTarget[i].DestBlend = dxBlendFactorColor(pEntry->perRT[i].destBlend); 966 BlendDesc.RenderTarget[i].BlendOp = dxBlendOp (pEntry->perRT[i].blendOp); 967 BlendDesc.RenderTarget[i].SrcBlendAlpha = dxBlendFactorAlpha(pEntry->perRT[i].srcBlendAlpha); 968 BlendDesc.RenderTarget[i].DestBlendAlpha = dxBlendFactorAlpha(pEntry->perRT[i].destBlendAlpha); 969 BlendDesc.RenderTarget[i].BlendOpAlpha = dxBlendOp (pEntry->perRT[i].blendOpAlpha); 796 970 BlendDesc.RenderTarget[i].RenderTargetWriteMask = pEntry->perRT[i].renderTargetWriteMask; 797 971 /** @todo logicOpEnable and logicOp */ … … 832 1006 { 833 1007 D3D11_SAMPLER_DESC desc; 834 desc.Filter = (D3D11_FILTER)pEntry->filter; 1008 /* Guest sometimes sends inconsistent (from D3D11 point of view) set of filter flags. */ 1009 if (pEntry->filter & SVGA3D_FILTER_ANISOTROPIC) 1010 desc.Filter = (pEntry->filter & SVGA3D_FILTER_COMPARE) 1011 ? D3D11_FILTER_COMPARISON_ANISOTROPIC 1012 : D3D11_FILTER_ANISOTROPIC; 1013 else 1014 desc.Filter = (D3D11_FILTER)pEntry->filter; 835 1015 desc.AddressU = (D3D11_TEXTURE_ADDRESS_MODE)pEntry->addressU; 836 1016 desc.AddressV = (D3D11_TEXTURE_ADDRESS_MODE)pEntry->addressV; … … 874 1054 875 1055 876 static HRESULT dxRenderTargetViewCreate(PV MSVGA3DDXCONTEXT pDXContext, SVGACOTableDXRTViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11RenderTargetView **pp)1056 static HRESULT dxRenderTargetViewCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableDXRTViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11RenderTargetView **pp) 877 1057 { 878 1058 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 879 1059 880 ID3D11Resource *pResource = dxResource(pSurface, pDXContext); 881 //pBackendSurface->u.Texture.pTexture; 1060 ID3D11Resource *pResource = dxResource(pThisCC->svga.p3dState, pSurface, pDXContext); 882 1061 883 1062 D3D11_RENDER_TARGET_VIEW_DESC desc; … … 949 1128 950 1129 951 static HRESULT dxShaderResourceViewCreate(PV MSVGA3DDXCONTEXT pDXContext, SVGACOTableDXSRViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11ShaderResourceView **pp)1130 static HRESULT dxShaderResourceViewCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableDXSRViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11ShaderResourceView **pp) 952 1131 { 953 1132 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 954 1133 955 ID3D11Resource *pResource = dxResource(pSurface, pDXContext); 956 // ID3D11Resource *pResource = pBackendSurface->u.Texture.pTexture; 1134 ID3D11Resource *pResource = dxResource(pThisCC->svga.p3dState, pSurface, pDXContext); 957 1135 958 1136 D3D11_SHADER_RESOURCE_VIEW_DESC desc; … … 1006 1184 break; 1007 1185 case SVGA3D_RESOURCE_TEXTURECUBE: 1008 AssertFailed(); /** @todo test. */1009 1186 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; 1010 1187 desc.TextureCube.MostDetailedMip = pEntry->desc.tex.mostDetailedMip; … … 1028 1205 1029 1206 1030 static HRESULT dxDepthStencilViewCreate(DXDEVICE *pDevice, SVGACOTableDXDSViewEntry const *pEntry, VMSVGA3DBACKENDSURFACE *pBackendSurface, ID3D11DepthStencilView **pp) 1031 { 1032 ID3D11Resource *pResource = pBackendSurface->u.Texture.pTexture; 1207 static HRESULT dxDepthStencilViewCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableDXDSViewEntry const *pEntry, VMSVGA3DSURFACE *pSurface, ID3D11DepthStencilView **pp) 1208 { 1209 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 1210 1211 ID3D11Resource *pResource = dxResource(pThisCC->svga.p3dState, pSurface, pDXContext); 1033 1212 1034 1213 D3D11_DEPTH_STENCIL_VIEW_DESC desc; … … 1183 1362 1184 1363 1364 static int dxBackendSurfaceAlloc(PVMSVGA3DBACKENDSURFACE *ppBackendSurface) 1365 { 1366 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 1367 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 1368 pBackendSurface->cidDrawing = SVGA_ID_INVALID; 1369 *ppBackendSurface = pBackendSurface; 1370 return VINF_SUCCESS; 1371 } 1372 1373 1185 1374 static int vmsvga3dBackSurfaceCreateScreenTarget(PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface) 1186 1375 { … … 1203 1392 } 1204 1393 1205 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 1206 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 1394 PVMSVGA3DBACKENDSURFACE pBackendSurface; 1395 int rc = dxBackendSurfaceAlloc(&pBackendSurface); 1396 AssertRCReturn(rc, rc); 1207 1397 1208 1398 D3D11_TEXTURE2D_DESC td; … … 1221 1411 td.MiscFlags = D3D11_RESOURCE_MISC_SHARED; 1222 1412 1223 HRESULT hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->u. ScreenTarget.pTexture);1413 HRESULT hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->u.pTexture2D); 1224 1414 Assert(SUCCEEDED(hr)); 1225 1415 if (SUCCEEDED(hr)) … … 1230 1420 td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 1231 1421 td.MiscFlags = 0; 1232 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface-> u.ScreenTarget.pDynamicTexture);1422 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->pDynamicTexture); 1233 1423 Assert(SUCCEEDED(hr)); 1234 1424 } … … 1240 1430 td.BindFlags = 0; /* No flags allowed. */ 1241 1431 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ; 1242 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface-> u.ScreenTarget.pStagingTexture);1432 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->pStagingTexture); 1243 1433 Assert(SUCCEEDED(hr)); 1244 1434 } … … 1248 1438 /* Get the shared handle. */ 1249 1439 IDXGIResource *pDxgiResource = NULL; 1250 hr = pBackendSurface->u. ScreenTarget.pTexture->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource);1440 hr = pBackendSurface->u.pTexture2D->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource); 1251 1441 Assert(SUCCEEDED(hr)); 1252 1442 if (SUCCEEDED(hr)) 1253 1443 { 1254 hr = pDxgiResource->GetSharedHandle(&pBackendSurface-> u.ScreenTarget.SharedHandle);1444 hr = pDxgiResource->GetSharedHandle(&pBackendSurface->SharedHandle); 1255 1445 Assert(SUCCEEDED(hr)); 1256 1446 D3D_RELEASE(pDxgiResource); … … 1266 1456 pBackendSurface->enmDxgiFormat = td.Format; 1267 1457 pSurface->pBackendSurface = pBackendSurface; 1268 pSurface->idAssociatedContext = SVGA_ID_INVALID;1458 pSurface->idAssociatedContext = DX_CID_BACKEND; 1269 1459 pSurface->fDirty = true; 1270 1460 return VINF_SUCCESS; … … 1272 1462 1273 1463 /* Failure. */ 1274 D3D_RELEASE(pBackendSurface-> u.ScreenTarget.pStagingTexture);1275 D3D_RELEASE(pBackendSurface-> u.ScreenTarget.pDynamicTexture);1276 D3D_RELEASE(pBackendSurface->u. ScreenTarget.pTexture);1464 D3D_RELEASE(pBackendSurface->pStagingTexture); 1465 D3D_RELEASE(pBackendSurface->pDynamicTexture); 1466 D3D_RELEASE(pBackendSurface->u.pTexture2D); 1277 1467 RTMemFree(pBackendSurface); 1278 1468 return VERR_NO_MEMORY; … … 1305 1495 AssertReturn(p3dState, VERR_INVALID_STATE); 1306 1496 1307 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 1308 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 1497 PVMSVGA3DBACKEND pBackend = p3dState->pBackend; 1498 AssertReturn(pBackend, VERR_INVALID_STATE); 1499 1500 UINT MiscFlags; 1501 DXDEVICE *pDXDevice; 1502 if (dxIsSurfaceShareable(pSurface)) 1503 { 1504 pDXDevice = &pBackend->device; 1505 MiscFlags = D3D11_RESOURCE_MISC_SHARED; 1506 } 1507 else 1508 { 1509 pDXDevice = &pDXContext->pBackendDXContext->device; 1510 MiscFlags = 0; 1511 } 1512 AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE); 1309 1513 1310 1514 if (pSurface->pBackendSurface != NULL) … … 1314 1518 } 1315 1519 1316 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 1317 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 1520 PVMSVGA3DBACKENDSURFACE pBackendSurface; 1521 int rc = dxBackendSurfaceAlloc(&pBackendSurface); 1522 AssertRCReturn(rc, rc); 1318 1523 1319 1524 uint32_t const cWidth = pSurface->paMipmapLevels[0].mipmapSize.width; … … 1334 1539 * Create the texture in backend device and open for the specified context. 1335 1540 */ 1336 PVMSVGA3DBACKEND pBackend = p3dState->pBackend;1337 AssertReturn(pBackend, VERR_INVALID_STATE);1338 1339 DXDEVICE *pDXDevice = &pBackend->device;1340 AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE);1341 1342 1541 D3D11_TEXTURE2D_DESC td; 1343 1542 RT_ZERO(td); … … 1353 1552 td.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; 1354 1553 td.CPUAccessFlags = 0; 1355 td.MiscFlags = D3D11_RESOURCE_MISC_SHARED;1356 1357 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->u. ScreenTarget.pTexture);1554 td.MiscFlags = MiscFlags; 1555 1556 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->u.pTexture2D); 1358 1557 Assert(SUCCEEDED(hr)); 1359 1558 if (SUCCEEDED(hr)) … … 1364 1563 td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 1365 1564 td.MiscFlags = 0; 1366 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface-> u.ScreenTarget.pDynamicTexture);1565 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->pDynamicTexture); 1367 1566 Assert(SUCCEEDED(hr)); 1368 1567 } … … 1374 1573 td.BindFlags = 0; /* No flags allowed. */ 1375 1574 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ; 1376 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface-> u.ScreenTarget.pStagingTexture);1575 hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->pStagingTexture); 1377 1576 Assert(SUCCEEDED(hr)); 1378 1577 } … … 1382 1581 /* Get the shared handle. */ 1383 1582 IDXGIResource *pDxgiResource = NULL; 1384 hr = pBackendSurface->u. ScreenTarget.pTexture->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource);1583 hr = pBackendSurface->u.pTexture2D->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource); 1385 1584 Assert(SUCCEEDED(hr)); 1386 1585 if (SUCCEEDED(hr)) 1387 1586 { 1388 hr = pDxgiResource->GetSharedHandle(&pBackendSurface-> u.ScreenTarget.SharedHandle);1587 hr = pDxgiResource->GetSharedHandle(&pBackendSurface->SharedHandle); 1389 1588 Assert(SUCCEEDED(hr)); 1390 1589 D3D_RELEASE(pDxgiResource); … … 1402 1601 Assert(cWidth == cHeight); 1403 1602 Assert(cDepth == 1); 1404 1405 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_CUBE_TEXTURE; 1406 AssertFailed(); /** @todo implement */ 1407 hr = E_FAIL; 1603 //ASMBreakpoint(); 1604 D3D11_SUBRESOURCE_DATA *paInitialData = NULL; 1605 D3D11_SUBRESOURCE_DATA aInitialData[6 * SVGA3D_MAX_MIP_LEVELS]; 1606 if (pSurface->paMipmapLevels[0].pSurfaceData) 1607 { 1608 /** @todo Can happen for a non GBO surface or if GBO texture was updated prior to creation if the hardware resource. Test this. */ 1609 /** @todo for (i = 0; i < pSurface->cFaces * numMipLevels; ++i) */ 1610 for (uint32_t iFace = 0; iFace < 6; ++iFace) 1611 { 1612 for (uint32_t i = 0; i < numMipLevels; ++i) 1613 { 1614 uint32_t const iSubresource = vmsvga3dCalcSubresource(i, iFace, numMipLevels); 1615 1616 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[iSubresource]; 1617 D3D11_SUBRESOURCE_DATA *p = &aInitialData[iSubresource]; 1618 p->pSysMem = pMipmapLevel->pSurfaceData; 1619 p->SysMemPitch = pMipmapLevel->cbSurfacePitch; 1620 p->SysMemSlicePitch = pMipmapLevel->cbSurfacePlane; 1621 } 1622 } 1623 paInitialData = &aInitialData[0]; 1624 } 1625 1626 D3D11_TEXTURE2D_DESC td; 1627 RT_ZERO(td); 1628 td.Width = cWidth; 1629 td.Height = cHeight; 1630 td.MipLevels = numMipLevels; 1631 td.ArraySize = 6; 1632 td.Format = dxgiFormat; 1633 td.SampleDesc.Count = 1; 1634 td.SampleDesc.Quality = 0; 1635 td.Usage = D3D11_USAGE_DEFAULT; 1636 td.BindFlags = dxBindFlags(pSurface->surfaceFlags); 1637 td.CPUAccessFlags = 0; /** @todo */ 1638 td.MiscFlags = MiscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE; /** @todo */ 1639 if ( numMipLevels > 1 1640 && (td.BindFlags & (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET)) == (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET)) 1641 td.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; /* Required for GenMips. */ 1642 1643 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->u.pTexture2D); 1644 Assert(SUCCEEDED(hr)); 1645 if (SUCCEEDED(hr)) 1646 { 1647 /* Map-able texture. */ 1648 td.MipLevels = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 1649 td.ArraySize = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 1650 td.Usage = D3D11_USAGE_DYNAMIC; 1651 td.BindFlags = D3D11_BIND_SHADER_RESOURCE; /* Have to specify a supported flag, otherwise E_INVALIDARG will be returned. */ 1652 td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 1653 td.MiscFlags = 0; 1654 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pDynamicTexture); 1655 Assert(SUCCEEDED(hr)); 1656 } 1657 1658 if (SUCCEEDED(hr)) 1659 { 1660 /* Staging texture. */ 1661 td.Usage = D3D11_USAGE_STAGING; 1662 td.BindFlags = 0; /* No flags allowed. */ 1663 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ; 1664 td.MiscFlags = 0; 1665 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pStagingTexture); 1666 Assert(SUCCEEDED(hr)); 1667 } 1668 1669 if ( SUCCEEDED(hr) 1670 && MiscFlags == D3D11_RESOURCE_MISC_SHARED) 1671 { 1672 /* Get the shared handle. */ 1673 IDXGIResource *pDxgiResource = NULL; 1674 hr = pBackendSurface->u.pTexture2D->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource); 1675 Assert(SUCCEEDED(hr)); 1676 if (SUCCEEDED(hr)) 1677 { 1678 hr = pDxgiResource->GetSharedHandle(&pBackendSurface->SharedHandle); 1679 Assert(SUCCEEDED(hr)); 1680 D3D_RELEASE(pDxgiResource); 1681 } 1682 } 1683 1684 if (SUCCEEDED(hr)) 1685 { 1686 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_CUBE_TEXTURE; 1687 } 1408 1688 } 1409 1689 else if (pSurface->surfaceFlags & SVGA3D_SURFACE_1D) … … 1419 1699 * Volume texture. 1420 1700 */ 1421 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_3D; 1422 AssertFailed(); /** @todo implement */ 1423 hr = E_FAIL; 1701 Assert(pSurface->cFaces == 1); 1702 1703 D3D11_SUBRESOURCE_DATA *paInitialData = NULL; 1704 D3D11_SUBRESOURCE_DATA aInitialData[SVGA3D_MAX_MIP_LEVELS]; 1705 if (pSurface->paMipmapLevels[0].pSurfaceData) 1706 { 1707 /** @todo Can happen for a non GBO surface or if GBO texture was updated prior to creation if the hardware resource. Test this. */ 1708 for (uint32_t i = 0; i < numMipLevels; ++i) 1709 { 1710 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; 1711 D3D11_SUBRESOURCE_DATA *p = &aInitialData[i]; 1712 p->pSysMem = pMipmapLevel->pSurfaceData; 1713 p->SysMemPitch = pMipmapLevel->cbSurfacePitch; 1714 p->SysMemSlicePitch = pMipmapLevel->cbSurfacePlane; 1715 } 1716 paInitialData = &aInitialData[0]; 1717 } 1718 1719 D3D11_TEXTURE3D_DESC td; 1720 RT_ZERO(td); 1721 td.Width = cWidth; 1722 td.Height = cHeight; 1723 td.Depth = cDepth; 1724 td.MipLevels = numMipLevels; 1725 td.Format = dxgiFormat; 1726 td.Usage = D3D11_USAGE_DEFAULT; 1727 td.BindFlags = dxBindFlags(pSurface->surfaceFlags); 1728 td.CPUAccessFlags = 0; /** @todo */ 1729 td.MiscFlags = MiscFlags; /** @todo */ 1730 if ( numMipLevels > 1 1731 && (td.BindFlags & (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET)) == (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET)) 1732 td.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; /* Required for GenMips. */ 1733 1734 hr = pDXDevice->pDevice->CreateTexture3D(&td, paInitialData, &pBackendSurface->u.pTexture3D); 1735 Assert(SUCCEEDED(hr)); 1736 if (SUCCEEDED(hr)) 1737 { 1738 /* Map-able texture. */ 1739 td.MipLevels = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 1740 td.Usage = D3D11_USAGE_DYNAMIC; 1741 td.BindFlags = D3D11_BIND_SHADER_RESOURCE; /* Have to specify a supported flag, otherwise E_INVALIDARG will be returned. */ 1742 td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 1743 td.MiscFlags = 0; 1744 hr = pDXDevice->pDevice->CreateTexture3D(&td, paInitialData, &pBackendSurface->pDynamicTexture3D); 1745 Assert(SUCCEEDED(hr)); 1746 } 1747 1748 if (SUCCEEDED(hr)) 1749 { 1750 /* Staging texture. */ 1751 td.Usage = D3D11_USAGE_STAGING; 1752 td.BindFlags = 0; /* No flags allowed. */ 1753 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ; 1754 td.MiscFlags = 0; 1755 hr = pDXDevice->pDevice->CreateTexture3D(&td, paInitialData, &pBackendSurface->pStagingTexture3D); 1756 Assert(SUCCEEDED(hr)); 1757 } 1758 1759 if ( SUCCEEDED(hr) 1760 && MiscFlags == D3D11_RESOURCE_MISC_SHARED) 1761 { 1762 /* Get the shared handle. */ 1763 IDXGIResource *pDxgiResource = NULL; 1764 hr = pBackendSurface->u.pTexture3D->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource); 1765 Assert(SUCCEEDED(hr)); 1766 if (SUCCEEDED(hr)) 1767 { 1768 hr = pDxgiResource->GetSharedHandle(&pBackendSurface->SharedHandle); 1769 Assert(SUCCEEDED(hr)); 1770 D3D_RELEASE(pDxgiResource); 1771 } 1772 } 1773 1774 if (SUCCEEDED(hr)) 1775 { 1776 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_3D; 1777 } 1424 1778 } 1425 1779 else … … 1434 1788 if (pSurface->paMipmapLevels[0].pSurfaceData) 1435 1789 { 1436 /** @todo Can happen for a non GBO surface . Test this. */1790 /** @todo Can happen for a non GBO surface or if GBO texture was updated prior to creation if the hardware resource. Test this. */ 1437 1791 for (uint32_t i = 0; i < numMipLevels; ++i) 1438 1792 { … … 1458 1812 td.BindFlags = dxBindFlags(pSurface->surfaceFlags); 1459 1813 td.CPUAccessFlags = 0; /** @todo */ 1460 td.MiscFlags = 0; /** @todo */1814 td.MiscFlags = MiscFlags; /** @todo */ 1461 1815 if ( numMipLevels > 1 1462 1816 && (td.BindFlags & (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET)) == (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET)) 1463 1817 td.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; /* Required for GenMips. */ 1464 1818 1465 hr = pD evice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->u.Texture.pTexture);1819 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->u.pTexture2D); 1466 1820 Assert(SUCCEEDED(hr)); 1467 1821 if (SUCCEEDED(hr)) … … 1473 1827 td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 1474 1828 td.MiscFlags = 0; 1475 hr = pD evice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->u.Texture.pDynamicTexture);1829 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pDynamicTexture); 1476 1830 Assert(SUCCEEDED(hr)); 1477 1831 } … … 1484 1838 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ; 1485 1839 td.MiscFlags = 0; 1486 hr = pD evice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->u.Texture.pStagingTexture);1840 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pStagingTexture); 1487 1841 Assert(SUCCEEDED(hr)); 1842 } 1843 1844 if ( SUCCEEDED(hr) 1845 && MiscFlags == D3D11_RESOURCE_MISC_SHARED) 1846 { 1847 /* Get the shared handle. */ 1848 IDXGIResource *pDxgiResource = NULL; 1849 hr = pBackendSurface->u.pTexture2D->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource); 1850 Assert(SUCCEEDED(hr)); 1851 if (SUCCEEDED(hr)) 1852 { 1853 hr = pDxgiResource->GetSharedHandle(&pBackendSurface->SharedHandle); 1854 Assert(SUCCEEDED(hr)); 1855 D3D_RELEASE(pDxgiResource); 1856 } 1488 1857 } 1489 1858 … … 1508 1877 pBackendSurface->enmDxgiFormat = dxgiFormat; 1509 1878 pSurface->pBackendSurface = pBackendSurface; 1510 if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_SCREEN_TARGET)1511 pSurface->idAssociatedContext = SVGA_ID_INVALID;1879 if (RT_BOOL(MiscFlags & D3D11_RESOURCE_MISC_SHARED)) 1880 pSurface->idAssociatedContext = DX_CID_BACKEND; 1512 1881 else 1513 1882 pSurface->idAssociatedContext = pDXContext->cid; … … 1516 1885 1517 1886 /* Failure. */ 1518 D3D_RELEASE(pBackendSurface-> u.Texture.pStagingTexture);1519 D3D_RELEASE(pBackendSurface-> u.Texture.pDynamicTexture);1520 D3D_RELEASE(pBackendSurface->u. Texture.pTexture);1887 D3D_RELEASE(pBackendSurface->pStagingTexture); 1888 D3D_RELEASE(pBackendSurface->pDynamicTexture); 1889 D3D_RELEASE(pBackendSurface->u.pTexture2D); 1521 1890 RTMemFree(pBackendSurface); 1522 1891 return VERR_NO_MEMORY; … … 1526 1895 static int vmsvga3dBackSurfaceCreateDepthStencilTexture(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) 1527 1896 { 1528 DXDEVICE *pD evice = &pDXContext->pBackendDXContext->device;1529 AssertReturn(pD evice->pDevice, VERR_INVALID_STATE);1897 DXDEVICE *pDXDevice = &pDXContext->pBackendDXContext->device; 1898 AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE); 1530 1899 1531 1900 if (pSurface->pBackendSurface != NULL) … … 1535 1904 } 1536 1905 1537 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 1538 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 1906 PVMSVGA3DBACKENDSURFACE pBackendSurface; 1907 int rc = dxBackendSurfaceAlloc(&pBackendSurface); 1908 AssertRCReturn(rc, rc); 1909 1910 uint32_t const cWidth = pSurface->paMipmapLevels[0].mipmapSize.width; 1911 uint32_t const cHeight = pSurface->paMipmapLevels[0].mipmapSize.height; 1912 uint32_t const numMipLevels = pSurface->cLevels; 1913 1914 D3D11_SUBRESOURCE_DATA *paInitialData = NULL; 1915 D3D11_SUBRESOURCE_DATA aInitialData[SVGA3D_MAX_MIP_LEVELS]; 1916 if (pSurface->paMipmapLevels[0].pSurfaceData) 1917 { 1918 /** @todo Can happen for a non GBO surface or if GBO texture was updated prior to creation if the hardware resource. Test this. */ 1919 for (uint32_t i = 0; i < numMipLevels; ++i) 1920 { 1921 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; 1922 D3D11_SUBRESOURCE_DATA *p = &aInitialData[i]; 1923 p->pSysMem = pMipmapLevel->pSurfaceData; 1924 p->SysMemPitch = pMipmapLevel->cbSurfacePitch; 1925 p->SysMemSlicePitch = pMipmapLevel->cbSurfacePlane; 1926 } 1927 paInitialData = &aInitialData[0]; 1928 } 1539 1929 1540 1930 D3D11_TEXTURE2D_DESC td; 1541 1931 RT_ZERO(td); 1542 td.Width = pSurface->paMipmapLevels[0].mipmapSize.width;1543 td.Height = pSurface->paMipmapLevels[0].mipmapSize.height;1932 td.Width = cWidth; 1933 td.Height = cHeight; 1544 1934 Assert(pSurface->cLevels == 1); 1545 1935 td.MipLevels = 1; … … 1550 1940 td.SampleDesc.Quality = 0; 1551 1941 td.Usage = D3D11_USAGE_DEFAULT; 1552 td.BindFlags = D3D11_BIND_DEPTH_STENCIL;1942 td.BindFlags = dxBindFlags(pSurface->surfaceFlags); 1553 1943 td.CPUAccessFlags = 0; 1554 1944 td.MiscFlags = 0; 1555 1945 1556 HRESULT hr = pD evice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->u.Texture.pTexture);1946 HRESULT hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->u.pTexture2D); 1557 1947 Assert(SUCCEEDED(hr)); 1948 if (SUCCEEDED(hr)) 1949 { 1950 /* Map-able texture. */ 1951 td.MipLevels = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 1952 td.Usage = D3D11_USAGE_DYNAMIC; 1953 td.BindFlags = D3D11_BIND_SHADER_RESOURCE; /* Have to specify a supported flag, otherwise E_INVALIDARG will be returned. */ 1954 td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; 1955 td.MiscFlags = 0; 1956 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pDynamicTexture); 1957 Assert(SUCCEEDED(hr)); 1958 } 1959 1960 if (SUCCEEDED(hr)) 1961 { 1962 /* Staging texture. */ 1963 td.Usage = D3D11_USAGE_STAGING; 1964 td.BindFlags = 0; /* No flags allowed. */ 1965 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ; 1966 td.MiscFlags = 0; 1967 hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pStagingTexture); 1968 Assert(SUCCEEDED(hr)); 1969 } 1970 1558 1971 if (SUCCEEDED(hr)) 1559 1972 { … … 1565 1978 pSurface->pBackendSurface = pBackendSurface; 1566 1979 pSurface->idAssociatedContext = pDXContext->cid; 1567 pSurface->fDirty = true;1980 //pSurface->fDirty = true; 1568 1981 return VINF_SUCCESS; 1569 1982 } 1570 1983 1571 1984 /* Failure. */ 1572 D3D_RELEASE(pBackendSurface-> u.Texture.pStagingTexture);1573 D3D_RELEASE(pBackendSurface-> u.Texture.pDynamicTexture);1574 D3D_RELEASE(pBackendSurface->u. Texture.pTexture);1985 D3D_RELEASE(pBackendSurface->pStagingTexture); 1986 D3D_RELEASE(pBackendSurface->pDynamicTexture); 1987 D3D_RELEASE(pBackendSurface->u.pTexture2D); 1575 1988 RTMemFree(pBackendSurface); 1576 1989 return VERR_NO_MEMORY; … … 1598 2011 } 1599 2012 1600 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 1601 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 2013 PVMSVGA3DBACKENDSURFACE pBackendSurface; 2014 int rc = dxBackendSurfaceAlloc(&pBackendSurface); 2015 AssertRCReturn(rc, rc); 1602 2016 1603 2017 D3D11_BUFFER_DESC bd; … … 1614 2028 bd.StructureByteStride = 0; 1615 2029 1616 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, 0, &pBackendSurface->u. Buffer.pBuffer);2030 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, 0, &pBackendSurface->u.pBuffer); 1617 2031 if (SUCCEEDED(hr)) 1618 2032 { … … 1629 2043 1630 2044 /* Failure. */ 1631 D3D_RELEASE(pBackendSurface->u. Buffer.pBuffer);2045 D3D_RELEASE(pBackendSurface->u.pBuffer); 1632 2046 RTMemFree(pBackendSurface); 1633 2047 return VERR_NO_MEMORY; … … 1649 2063 } 1650 2064 1651 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 1652 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 2065 PVMSVGA3DBACKENDSURFACE pBackendSurface; 2066 int rc = dxBackendSurfaceAlloc(&pBackendSurface); 2067 AssertRCReturn(rc, rc); 1653 2068 1654 2069 D3D11_BUFFER_DESC bd; … … 1661 2076 bd.StructureByteStride = 0; 1662 2077 1663 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, 0, &pBackendSurface->u. Buffer.pBuffer);2078 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, 0, &pBackendSurface->u.pBuffer); 1664 2079 if (SUCCEEDED(hr)) 1665 2080 { … … 1676 2091 1677 2092 /* Failure. */ 1678 D3D_RELEASE(pBackendSurface->u. Buffer.pBuffer);2093 D3D_RELEASE(pBackendSurface->u.pBuffer); 1679 2094 RTMemFree(pBackendSurface); 1680 2095 return VERR_NO_MEMORY; … … 1694 2109 bd.StructureByteStride = 0; 1695 2110 1696 return pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBackendSurface->u. Buffer.pBuffer);2111 return pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBackendSurface->u.pBuffer); 1697 2112 } 1698 2113 … … 1711 2126 bd.StructureByteStride = 0; 1712 2127 1713 return pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBackendSurface->u. Buffer.pBuffer);2128 return pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBackendSurface->u.pBuffer); 1714 2129 } 1715 2130 … … 1726 2141 } 1727 2142 1728 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 1729 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 2143 PVMSVGA3DBACKENDSURFACE pBackendSurface; 2144 int rc = dxBackendSurfaceAlloc(&pBackendSurface); 2145 AssertRCReturn(rc, rc); 1730 2146 1731 2147 HRESULT hr; … … 1743 2159 } 1744 2160 else 1745 D3D_RELEASE(pBackendSurface->u. Buffer.pBuffer);2161 D3D_RELEASE(pBackendSurface->u.pBuffer); 1746 2162 } 1747 2163 else if (pSurface->surfaceFlags & ( SVGA3D_SURFACE_BIND_VERTEX_BUFFER … … 1757 2173 } 1758 2174 else 1759 D3D_RELEASE(pBackendSurface->u. Buffer.pBuffer);2175 D3D_RELEASE(pBackendSurface->u.pBuffer); 1760 2176 } 1761 2177 else … … 1801 2217 } 1802 2218 1803 rc = RTLdrLoadSystem("D3DCompiler_47", /* fNoUnload = */ true, &pBackend->hD3DCompiler);1804 AssertRC(rc);1805 2219 if (RT_SUCCESS(rc)) 1806 2220 { 1807 rc = RTLdrGetSymbol(pBackend->hD3DCompiler, "D3DDisassemble", (void **)&pBackend->pfnD3DDisassemble); 1808 AssertRC(rc); 1809 } 1810 2221 /* Failure to load the shader disassembler is ignored. */ 2222 int rc2 = RTLdrLoadSystem("D3DCompiler_47", /* fNoUnload = */ true, &pBackend->hD3DCompiler); 2223 AssertRC(rc2); 2224 if (RT_SUCCESS(rc2)) 2225 { 2226 rc2 = RTLdrGetSymbol(pBackend->hD3DCompiler, "D3DDisassemble", (void **)&pBackend->pfnD3DDisassemble); 2227 AssertRC(rc2); 2228 } 2229 Log6Func(("Load D3DDisassemble: %Rrc\n", rc2)); 2230 } 2231 //ASMBreakpoint(); 1811 2232 return rc; 1812 2233 } … … 1835 2256 if (pState->pBackend) 1836 2257 { 2258 /** @todo Clean up backends. */ 2259 1837 2260 dxDeviceDestroy(pState->pBackend, &pState->pBackend->device); 1838 2261 … … 2079 2502 2080 2503 2081 static DECLCALLBACK(int) dxContextFlushShared(PAVLU32NODECORE pCore, void *pvUser) 2082 { 2083 PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)pvUser; 2084 2085 // Flush pCore->Key context and issue a query. 2086 PVMSVGA3DDXCONTEXT pDXContextDrawing; 2087 int rc = vmsvga3dDXContextFromCid(pState, pCore->Key, &pDXContextDrawing); 2088 AssertRCReturn(rc, rc); 2089 2090 DXDEVICE *pDeviceDrawing = &pDXContextDrawing->pBackendDXContext->device; 2091 pDeviceDrawing->pImmediateContext->Flush(); 2092 2093 ID3D11Query *pQuery = 0; 2094 D3D11_QUERY_DESC qd; 2095 RT_ZERO(qd); 2096 qd.Query = D3D11_QUERY_EVENT; 2097 HRESULT hr2 = pDeviceDrawing->pDevice->CreateQuery(&qd, &pQuery); 2098 Assert(hr2 == S_OK); RT_NOREF(hr2); 2099 2100 pDeviceDrawing->pImmediateContext->End(pQuery); 2101 2102 BOOL queryData; 2103 while (pDeviceDrawing->pImmediateContext->GetData(pQuery, &queryData, sizeof(queryData), 0) != S_OK) 2104 { 2105 RTThreadYield(); 2106 } 2107 D3D_RELEASE(pQuery); 2108 2109 return VINF_SUCCESS; 2110 } 2111 2112 2113 2114 static DECLCALLBACK(int) vmsvga3dSurfaceMap(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, 2115 VMSVGA3D_SURFACE_MAP enmMapType, VMSVGA3D_MAPPED_SURFACE *pMap) 2504 static DECLCALLBACK(int) vmsvga3dBackSurfaceMap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, 2505 VMSVGA3D_SURFACE_MAP enmMapType, VMSVGA3D_MAPPED_SURFACE *pMap) 2116 2506 { 2117 2507 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState; … … 2125 2515 AssertRCReturn(rc, rc); 2126 2516 2127 Assert(pImage->face == 0 && pImage->mipmap == 0); /** @todo implement. */2128 2129 PVMSVGA3DDXCONTEXT pDXContext;2130 2131 2517 PVMSVGA3DBACKENDSURFACE pBackendSurface = pSurface->pBackendSurface; 2132 if (!pBackendSurface) 2133 { 2134 /* This means that the guest uploads new data to the surface. 2135 * So the data should be copied either to a host memory buffer, 2136 * or to the actual surface. 2137 * In the latter case the BackendSurface must be created here. 2138 */ 2139 rc = vmsvga3dDXContextFromCid(pState, idDXContext, &pDXContext); 2140 AssertRCReturn(rc, rc); 2141 2142 rc = vmsvga3dBackSurfaceCreate(pThisCC, pDXContext, pSurface); 2143 AssertRCReturn(rc, rc); 2144 2145 pBackendSurface = pSurface->pBackendSurface; 2146 } 2147 2148 /* Figure out whether the surface belongs to a DXContext or to the backend. */ 2149 if (pSurface->idAssociatedContext != SVGA_ID_INVALID) 2150 vmsvga3dDXContextFromCid(pState, pSurface->idAssociatedContext, &pDXContext); 2151 else 2152 pDXContext = NULL; 2153 2154 DXDEVICE *pDevice; 2155 if (pDXContext) 2156 pDevice = &pDXContext->pBackendDXContext->device; 2157 else 2158 pDevice = &pBackend->device; 2159 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 2518 AssertPtrReturn(pBackendSurface, VERR_INVALID_STATE); 2519 2520 PVMSVGA3DMIPMAPLEVEL pMipLevel; 2521 rc = vmsvga3dMipmapLevel(pSurface, pImage->face, pImage->mipmap, &pMipLevel); 2522 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 2523 2524 /* A surface is always mapped by the DX context which has created the surface. */ 2525 DXDEVICE *pDevice = dxDeviceFromCid(pSurface->idAssociatedContext, pState); 2526 AssertReturn(pDevice && pDevice->pDevice, VERR_INVALID_STATE); 2160 2527 2161 2528 SVGA3dBox clipBox; … … 2163 2530 { 2164 2531 clipBox = *pBox; 2165 vmsvgaR3ClipBox(&p Surface->paMipmapLevels[0].mipmapSize, &clipBox);2532 vmsvgaR3ClipBox(&pMipLevel->mipmapSize, &clipBox); 2166 2533 ASSERT_GUEST_RETURN(clipBox.w && clipBox.h && clipBox.d, VERR_INVALID_PARAMETER); 2167 2534 } … … 2171 2538 clipBox.y = 0; 2172 2539 clipBox.z = 0; 2173 clipBox.w = p Surface->paMipmapLevels[0].mipmapSize.width;2174 clipBox.h = p Surface->paMipmapLevels[0].mipmapSize.height;2175 clipBox.d = p Surface->paMipmapLevels[0].mipmapSize.depth;2540 clipBox.w = pMipLevel->mipmapSize.width; 2541 clipBox.h = pMipLevel->mipmapSize.height; 2542 clipBox.d = pMipLevel->mipmapSize.depth; 2176 2543 } 2177 2544 … … 2194 2561 if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_SCREEN_TARGET) 2195 2562 { 2563 Assert(pImage->face == 0 && pImage->mipmap == 0); 2564 2196 2565 ID3D11Texture2D *pMappedTexture; 2197 2566 if (enmMapType == VMSVGA3D_SURFACE_MAP_READ) 2198 2567 { 2199 pMappedTexture = pBackendSurface-> u.ScreenTarget.pStagingTexture;2200 2201 /* * @todoWait for the surface to finish drawing. */2202 if (pBackendSurface-> SharedTextureTree)2568 pMappedTexture = pBackendSurface->pStagingTexture; 2569 2570 /* Wait for the surface to finish drawing. */ 2571 if (pBackendSurface->cidDrawing != SVGA_ID_INVALID) 2203 2572 { 2204 int rc2 = RTAvlU32DoWithAll(&pBackendSurface->SharedTextureTree, 0, dxContextFlushShared, pState);2205 AssertRC(rc2);2573 dxContextWait(pBackendSurface->cidDrawing, pState); 2574 pBackendSurface->cidDrawing = SVGA_ID_INVALID; 2206 2575 } 2207 2576 2208 2577 /* Copy the texture content to the staging texture. */ 2209 pDevice->pImmediateContext->CopyResource(pBackendSurface-> u.ScreenTarget.pStagingTexture, pBackendSurface->u.ScreenTarget.pTexture);2578 pDevice->pImmediateContext->CopyResource(pBackendSurface->pStagingTexture, pBackendSurface->u.pTexture2D); 2210 2579 } 2211 2580 else 2212 pMappedTexture = pBackendSurface-> u.ScreenTarget.pDynamicTexture;2581 pMappedTexture = pBackendSurface->pDynamicTexture; 2213 2582 2214 2583 UINT const Subresource = 0; /* Screen target surfaces have only one subresource. */ … … 2230 2599 rc = VERR_NOT_SUPPORTED; 2231 2600 } 2232 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE) 2233 { 2601 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE 2602 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_CUBE_TEXTURE 2603 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 2604 { 2605 //Assert(pImage->face == 0 && pImage->mipmap == 0); 2606 if (!pBackendSurface->pStagingTexture || !pBackendSurface->pDynamicTexture) return VERR_NOT_IMPLEMENTED; 2234 2607 ID3D11Texture2D *pMappedTexture; 2235 2608 if (enmMapType == VMSVGA3D_SURFACE_MAP_READ) 2236 2609 { 2237 pMappedTexture = pBackendSurface->u.ScreenTarget.pStagingTexture; 2238 2239 /* Copy the texture content to the staging texture. */ 2240 pDevice->pImmediateContext->CopyResource(pBackendSurface->u.ScreenTarget.pStagingTexture, pBackendSurface->u.ScreenTarget.pTexture); 2610 pMappedTexture = pBackendSurface->pStagingTexture; 2611 2612 /* Wait for the surface to finish drawing. */ 2613 if (pBackendSurface->cidDrawing != SVGA_ID_INVALID) 2614 { 2615 dxContextWait(pBackendSurface->cidDrawing, pState); 2616 pBackendSurface->cidDrawing = SVGA_ID_INVALID; 2617 } 2618 2619 /* Copy the texture content to the staging texture. 2620 * The requested miplevel of the texture is copied to the miplevel 0 of the staging texture, 2621 * because the staging (and dynamic) structures do not have miplevels. 2622 * Always copy entire miplevel so all Dst are zero and pSrcBox is NULL, as D3D11 requires. 2623 */ 2624 ID3D11Resource *pDstResource = pBackendSurface->pStagingTexture; 2625 UINT DstSubresource = 0; 2626 UINT DstX = 0; 2627 UINT DstY = 0; 2628 UINT DstZ = 0; 2629 ID3D11Resource *pSrcResource = pBackendSurface->u.pTexture2D; 2630 UINT SrcSubresource = D3D11CalcSubresource(pImage->mipmap, pImage->face, pSurface->cLevels); 2631 D3D11_BOX *pSrcBox = NULL; 2632 //D3D11_BOX SrcBox; 2633 //SrcBox.left = 0; 2634 //SrcBox.top = 0; 2635 //SrcBox.front = 0; 2636 //SrcBox.right = pMipLevel->mipmapSize.width; 2637 //SrcBox.bottom = pMipLevel->mipmapSize.height; 2638 //SrcBox.back = pMipLevel->mipmapSize.depth; 2639 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 2640 pSrcResource, SrcSubresource, pSrcBox); 2241 2641 } 2242 2642 else 2243 pMappedTexture = pBackendSurface-> u.ScreenTarget.pDynamicTexture;2244 2245 UINT const Subresource = 0; /* Screen target surfaces have only one subresource. */2643 pMappedTexture = pBackendSurface->pDynamicTexture; 2644 2645 UINT const Subresource = 0; 2246 2646 HRESULT hr = pDevice->pImmediateContext->Map(pMappedTexture, Subresource, 2247 2647 d3d11MapType, /* MapFlags = */ 0, &mappedResource); … … 2264 2664 { 2265 2665 UINT const Subresource = 0; /* Buffers have only one subresource. */ 2266 HRESULT hr = pDevice->pImmediateContext->Map(pSurface->pBackendSurface->u. Buffer.pBuffer, Subresource,2666 HRESULT hr = pDevice->pImmediateContext->Map(pSurface->pBackendSurface->u.pBuffer, Subresource, 2267 2667 d3d11MapType, /* MapFlags = */ 0, &mappedResource); 2268 2668 if (SUCCEEDED(hr)) … … 2293 2693 2294 2694 2295 static DECLCALLBACK(int) vmsvga3d SurfaceUnmap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, VMSVGA3D_MAPPED_SURFACE *pMap, bool fWritten)2695 static DECLCALLBACK(int) vmsvga3dBackSurfaceUnmap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, VMSVGA3D_MAPPED_SURFACE *pMap, bool fWritten) 2296 2696 { 2297 2697 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState; … … 2309 2709 AssertReturn(pBackendSurface, VERR_INVALID_PARAMETER); 2310 2710 2311 PVMSVGA3DDXCONTEXT pDXContext; 2312 /* Figure out whether the surface belongs to a DXContext or to the backend. */ 2313 if (pSurface->idAssociatedContext != SVGA_ID_INVALID) 2314 vmsvga3dDXContextFromCid(pState, pSurface->idAssociatedContext, &pDXContext); 2315 else 2316 pDXContext = NULL; 2317 2318 DXDEVICE *pDevice; 2319 if (pDXContext) 2320 pDevice = &pDXContext->pBackendDXContext->device; 2321 else 2322 pDevice = &pBackend->device; 2323 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 2711 PVMSVGA3DMIPMAPLEVEL pMipLevel; 2712 rc = vmsvga3dMipmapLevel(pSurface, pImage->face, pImage->mipmap, &pMipLevel); 2713 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 2714 2715 /* A surface is always mapped by the DX context which has created the surface. */ 2716 DXDEVICE *pDevice = dxDeviceFromCid(pSurface->idAssociatedContext, pState); 2717 AssertReturn(pDevice && pDevice->pDevice, VERR_INVALID_STATE); 2324 2718 2325 2719 if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_SCREEN_TARGET) … … 2327 2721 ID3D11Texture2D *pMappedTexture; 2328 2722 if (pMap->enmMapType == VMSVGA3D_SURFACE_MAP_READ) 2329 pMappedTexture = pBackendSurface-> u.ScreenTarget.pStagingTexture;2723 pMappedTexture = pBackendSurface->pStagingTexture; 2330 2724 else 2331 pMappedTexture = pBackendSurface-> u.ScreenTarget.pDynamicTexture;2725 pMappedTexture = pBackendSurface->pDynamicTexture; 2332 2726 2333 2727 UINT const Subresource = 0; /* Screen target surfaces have only one subresource. */ … … 2339 2733 || pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE_DISCARD)) 2340 2734 { 2341 ID3D11Resource *pDstResource = pBackendSurface->u. ScreenTarget.pTexture;2735 ID3D11Resource *pDstResource = pBackendSurface->u.pTexture2D; 2342 2736 UINT DstSubresource = Subresource; 2343 2737 UINT DstX = pMap->box.x; 2344 2738 UINT DstY = pMap->box.y; 2345 2739 UINT DstZ = pMap->box.z; 2346 ID3D11Resource *pSrcResource = pBackendSurface-> u.ScreenTarget.pDynamicTexture;2740 ID3D11Resource *pSrcResource = pBackendSurface->pDynamicTexture; 2347 2741 UINT SrcSubresource = Subresource; 2348 2742 D3D11_BOX SrcBox; … … 2353 2747 SrcBox.bottom = pMap->box.y + pMap->box.h; 2354 2748 SrcBox.back = pMap->box.z + pMap->box.d; 2749 2355 2750 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 2356 2751 pSrcResource, SrcSubresource, &SrcBox); 2752 2753 pBackendSurface->cidDrawing = pSurface->idAssociatedContext; 2357 2754 } 2358 2755 } 2359 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE) 2756 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE 2757 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_CUBE_TEXTURE 2758 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 2360 2759 { 2361 2760 ID3D11Texture2D *pMappedTexture; 2362 2761 if (pMap->enmMapType == VMSVGA3D_SURFACE_MAP_READ) 2363 pMappedTexture = pBackendSurface-> u.ScreenTarget.pStagingTexture;2762 pMappedTexture = pBackendSurface->pStagingTexture; 2364 2763 else 2365 pMappedTexture = pBackendSurface-> u.ScreenTarget.pDynamicTexture;2366 2367 UINT const Subresource = 0; /* S creen target surfaces have onlyone subresource. */2764 pMappedTexture = pBackendSurface->pDynamicTexture; 2765 2766 UINT const Subresource = 0; /* Staging or dynamic textures have one subresource. */ 2368 2767 pDevice->pImmediateContext->Unmap(pMappedTexture, Subresource); 2369 2768 … … 2373 2772 || pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE_DISCARD)) 2374 2773 { 2375 ID3D11Resource *pDstResource = pBackendSurface->u. ScreenTarget.pTexture;2376 UINT DstSubresource = Subresource;2774 ID3D11Resource *pDstResource = pBackendSurface->u.pTexture2D; 2775 UINT DstSubresource = D3D11CalcSubresource(pImage->mipmap, pImage->face, pSurface->cLevels); 2377 2776 UINT DstX = pMap->box.x; 2378 2777 UINT DstY = pMap->box.y; 2379 2778 UINT DstZ = pMap->box.z; 2380 ID3D11Resource *pSrcResource = pBackendSurface-> u.ScreenTarget.pDynamicTexture;2779 ID3D11Resource *pSrcResource = pBackendSurface->pDynamicTexture; 2381 2780 UINT SrcSubresource = Subresource; 2382 2781 D3D11_BOX SrcBox; … … 2387 2786 SrcBox.bottom = pMap->box.y + pMap->box.h; 2388 2787 SrcBox.back = pMap->box.z + pMap->box.d; 2788 2389 2789 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 2390 2790 pSrcResource, SrcSubresource, &SrcBox); 2791 2792 pBackendSurface->cidDrawing = pSurface->idAssociatedContext; 2391 2793 } 2392 2794 } … … 2394 2796 { 2395 2797 UINT const Subresource = 0; /* Buffers have only one subresource. */ 2396 pDevice->pImmediateContext->Unmap(pBackendSurface->u. Buffer.pBuffer, Subresource);2798 pDevice->pImmediateContext->Unmap(pBackendSurface->u.pBuffer, Subresource); 2397 2799 } 2398 2800 else … … 2487 2889 ASSERT_GUEST_RETURN(clipRect.w && clipRect.h, VERR_INVALID_PARAMETER); 2488 2890 2891 /* Wait for the surface to finish drawing. */ 2892 if (pBackendSurface->cidDrawing != SVGA_ID_INVALID) 2893 { 2894 dxContextWait(pBackendSurface->cidDrawing, pState); 2895 pBackendSurface->cidDrawing = SVGA_ID_INVALID; 2896 } 2897 2489 2898 /* Copy the screen texture to the shared surface. */ 2490 2899 DWORD result = pHwScreen->pDXGIKeyedMutex->AcquireSync(0, 10000); 2491 2900 if (result == WAIT_OBJECT_0) 2492 2901 { 2493 ID3D11Query *pQuery = 0; 2494 D3D11_QUERY_DESC qd; 2495 RT_ZERO(qd); 2496 qd.Query = D3D11_QUERY_EVENT; 2497 HRESULT hr2 = pBackend->device.pDevice->CreateQuery(&qd, &pQuery); 2498 Assert(hr2 == S_OK); RT_NOREF(hr2); 2499 2500 pBackend->device.pImmediateContext->CopyResource(pHwScreen->pTexture, pBackendSurface->u.ScreenTarget.pTexture); 2501 2502 pBackend->device.pImmediateContext->Flush(); 2503 2504 pBackend->device.pImmediateContext->End(pQuery); 2505 2506 BOOL queryData; 2507 while (pBackend->device.pImmediateContext->GetData(pQuery, &queryData, sizeof(queryData), 0) != S_OK) 2508 { 2509 RTThreadYield(); 2510 } 2511 D3D_RELEASE(pQuery); 2902 pBackend->device.pImmediateContext->CopyResource(pHwScreen->pTexture, pBackendSurface->u.pTexture2D); 2903 2904 dxDeviceFlush(&pBackend->device); 2512 2905 2513 2906 result = pHwScreen->pDXGIKeyedMutex->ReleaseSync(1); … … 3097 3490 uint32_t cCopyBoxes, SVGA3dCopyBox *pBox) 3098 3491 { 3099 RT_NOREF(dest, src, cCopyBoxes, pBox); 3492 RT_NOREF(cCopyBoxes, pBox); 3493 3494 LogFunc(("src sid %d -> dst sid %d\n", src.sid, dest.sid)); 3100 3495 3101 3496 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState; 3102 3497 AssertReturn(pState, VERR_INVALID_STATE); 3103 3498 3104 AssertFailed(); 3105 return VERR_NOT_IMPLEMENTED; 3499 PVMSVGA3DBACKEND pBackend = pState->pBackend; 3500 3501 PVMSVGA3DSURFACE pSrcSurface; 3502 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, src.sid, &pSrcSurface); 3503 AssertRCReturn(rc, rc); 3504 3505 PVMSVGA3DSURFACE pDstSurface; 3506 rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, dest.sid, &pDstSurface); 3507 AssertRCReturn(rc, rc); 3508 3509 LogFunc(("src%s cid %d -> dst%s cid %d\n", 3510 pSrcSurface->pBackendSurface ? "" : " sysmem", 3511 pSrcSurface ? pSrcSurface->idAssociatedContext : SVGA_ID_INVALID, 3512 pDstSurface->pBackendSurface ? "" : " sysmem", 3513 pDstSurface ? pDstSurface->idAssociatedContext : SVGA_ID_INVALID)); 3514 3515 //DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 3516 //AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 3517 3518 if (pSrcSurface->pBackendSurface) 3519 { 3520 if (pDstSurface->pBackendSurface == NULL) 3521 { 3522 /* Create the target if it can be used as a device context shared resource (render or screen target). */ 3523 if (dxIsSurfaceShareable(pDstSurface)) 3524 { 3525 rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, NULL, pDstSurface); 3526 AssertRCReturn(rc, rc); 3527 } 3528 } 3529 3530 if (pDstSurface->pBackendSurface) 3531 { 3532 /* Surface -> Surface. */ 3533 /* Expect both of them to be shared surfaces created by the backend context. */ 3534 Assert(pSrcSurface->idAssociatedContext == DX_CID_BACKEND && pDstSurface->idAssociatedContext == DX_CID_BACKEND); 3535 3536 DXDEVICE *pDXDevice = &pBackend->device; 3537 3538 /* Clip the box. */ 3539 PVMSVGA3DMIPMAPLEVEL pSrcMipLevel; 3540 rc = vmsvga3dMipmapLevel(pSrcSurface, src.face, src.mipmap, &pSrcMipLevel); 3541 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 3542 3543 PVMSVGA3DMIPMAPLEVEL pDstMipLevel; 3544 rc = vmsvga3dMipmapLevel(pDstSurface, dest.face, dest.mipmap, &pDstMipLevel); 3545 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 3546 3547 SVGA3dCopyBox clipBox = *pBox; 3548 vmsvgaR3ClipCopyBox(&pSrcMipLevel->mipmapSize, &pDstMipLevel->mipmapSize, &clipBox); 3549 3550 UINT DstSubresource = vmsvga3dCalcSubresource(dest.mipmap, dest.face, pDstSurface->cLevels); 3551 UINT DstX = clipBox.x; 3552 UINT DstY = clipBox.y; 3553 UINT DstZ = clipBox.z; 3554 3555 UINT SrcSubresource = vmsvga3dCalcSubresource(src.mipmap, src.face, pSrcSurface->cLevels); 3556 D3D11_BOX SrcBox; 3557 SrcBox.left = clipBox.srcx; 3558 SrcBox.top = clipBox.srcy; 3559 SrcBox.front = clipBox.srcz; 3560 SrcBox.right = clipBox.srcx + clipBox.w; 3561 SrcBox.bottom = clipBox.srcy + clipBox.h; 3562 SrcBox.back = clipBox.srcz + clipBox.d; 3563 3564 Assert(cCopyBoxes == 1); /** @todo */ 3565 3566 ID3D11Resource *pDstResource; 3567 ID3D11Resource *pSrcResource; 3568 pDstResource = dxResource(pState, pDstSurface, NULL); 3569 pSrcResource = dxResource(pState, pSrcSurface, NULL); 3570 3571 pDXDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 3572 pSrcResource, SrcSubresource, &SrcBox); 3573 3574 pDstSurface->pBackendSurface->cidDrawing = DX_CID_BACKEND; 3575 } 3576 else 3577 { 3578 /* Surface -> Memory. */ 3579 AssertFailed(); /** @todo implement */ 3580 } 3581 } 3582 else 3583 { 3584 /* Memory -> Surface. */ 3585 AssertFailed(); /** @todo implement */ 3586 } 3587 3588 return rc; 3106 3589 } 3107 3590 … … 3405 3888 pSurface->pBackendSurface = NULL; 3406 3889 3890 LogFunc(("sid=%u\n", pSurface->id)); 3891 3407 3892 if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_SCREEN_TARGET) 3408 3893 { 3409 D3D_RELEASE(pBackendSurface->u.ScreenTarget.pStagingTexture); 3410 D3D_RELEASE(pBackendSurface->u.ScreenTarget.pDynamicTexture); 3411 D3D_RELEASE(pBackendSurface->u.ScreenTarget.pTexture); 3412 } 3413 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE) 3414 { 3415 D3D_RELEASE(pBackendSurface->u.Texture.pStagingTexture); 3416 D3D_RELEASE(pBackendSurface->u.Texture.pDynamicTexture); 3417 D3D_RELEASE(pBackendSurface->u.Texture.pTexture); 3894 D3D_RELEASE(pBackendSurface->pStagingTexture); 3895 D3D_RELEASE(pBackendSurface->pDynamicTexture); 3896 D3D_RELEASE(pBackendSurface->u.pTexture2D); 3897 } 3898 else if ( pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE 3899 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_CUBE_TEXTURE) 3900 { 3901 D3D_RELEASE(pBackendSurface->pStagingTexture); 3902 D3D_RELEASE(pBackendSurface->pDynamicTexture); 3903 D3D_RELEASE(pBackendSurface->u.pTexture2D); 3904 } 3905 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 3906 { 3907 D3D_RELEASE(pBackendSurface->pStagingTexture3D); 3908 D3D_RELEASE(pBackendSurface->pDynamicTexture3D); 3909 D3D_RELEASE(pBackendSurface->u.pTexture3D); 3418 3910 } 3419 3911 else if (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_BUFFER) 3420 3912 { 3421 D3D_RELEASE(pBackendSurface->u. Buffer.pBuffer);3913 D3D_RELEASE(pBackendSurface->u.pBuffer); 3422 3914 } 3423 3915 else … … 3427 3919 3428 3920 RTMemFree(pBackendSurface); 3921 3922 /* No context has created the surface, because the surface does not exist anymore. */ 3923 pSurface->idAssociatedContext = SVGA_ID_INVALID; 3429 3924 } 3430 3925 … … 3525 4020 3526 4021 VMSVGA3D_MAPPED_SURFACE map; 3527 rc = vmsvga3d SurfaceMap(pThisCC, pSurface->idAssociatedContext, &image, &box, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map);4022 rc = vmsvga3dBackSurfaceMap(pThisCC, &image, &box, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map); 3528 4023 if (RT_SUCCESS(rc)) 3529 4024 { … … 3553 4048 //vmsvga3dMapWriteBmpFile(&map, "Dynamic"); 3554 4049 3555 vmsvga3d SurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ true);4050 vmsvga3dBackSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ true); 3556 4051 } 3557 4052 #if 0 3558 4053 //ASMBreakpoint(); 3559 rc = vmsvga3d SurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);4054 rc = vmsvga3dBackSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map); 3560 4055 if (RT_SUCCESS(rc)) 3561 4056 { 3562 4057 vmsvga3dMapWriteBmpFile(&map, "Staging"); 3563 4058 3564 vmsvga3d SurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false);4059 vmsvga3dBackSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false); 3565 4060 } 3566 4061 #endif … … 3604 4099 3605 4100 VMSVGA3D_MAPPED_SURFACE map; 3606 rc = vmsvga3d SurfaceMap(pThisCC, pSurface->idAssociatedContext, &image, &box, enmMap, &map);4101 rc = vmsvga3dBackSurfaceMap(pThisCC, &image, &box, enmMap, &map); 3607 4102 if (RT_SUCCESS(rc)) 3608 4103 { … … 3629 4124 3630 4125 bool const fWritten = (transfer == SVGA3D_WRITE_HOST_VRAM); 3631 vmsvga3d SurfaceUnmap(pThisCC, &image, &map, fWritten);4126 vmsvga3dBackSurfaceUnmap(pThisCC, &image, &map, fWritten); 3632 4127 } 3633 4128 } … … 3717 4212 pDXContext->pBackendDXContext = pBackendDXContext; 3718 4213 4214 LogFunc(("cid %d\n", pDXContext->cid)); 4215 3719 4216 int rc = dxDeviceCreate(pBackend, &pBackendDXContext->device); 3720 4217 return rc; … … 3726 4223 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 3727 4224 4225 LogFunc(("cid %d\n", pDXContext->cid)); 4226 3728 4227 if (pDXContext->pBackendDXContext) 3729 4228 { 3730 dxDeviceDestroy(pBackend, &pDXContext->pBackendDXContext->device); 3731 3732 RTMemFree(pDXContext->pBackendDXContext); 4229 /* Clean up context resources. */ 4230 VMSVGA3DBACKENDDXCONTEXT *pBackendDXContext = pDXContext->pBackendDXContext; 4231 4232 if (pBackendDXContext->papRenderTargetView) 4233 DX_RELEASE_ARRAY(pBackendDXContext->cRenderTargetView, pBackendDXContext->papRenderTargetView); 4234 if (pBackendDXContext->papDepthStencilView) 4235 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilView, pBackendDXContext->papDepthStencilView); 4236 if (pBackendDXContext->papShaderResourceView) 4237 DX_RELEASE_ARRAY(pBackendDXContext->cShaderResourceView, pBackendDXContext->papShaderResourceView); 4238 if (pBackendDXContext->paElementLayout) 4239 { 4240 for (uint32_t i = 0; i < pBackendDXContext->cElementLayout; ++i) 4241 D3D_RELEASE(pBackendDXContext->paElementLayout[i].pElementLayout); 4242 } 4243 if (pBackendDXContext->papBlendState) 4244 DX_RELEASE_ARRAY(pBackendDXContext->cBlendState, pBackendDXContext->papBlendState); 4245 if (pBackendDXContext->papDepthStencilState) 4246 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilState, pBackendDXContext->papDepthStencilState); 4247 if (pBackendDXContext->papRasterizerState) 4248 DX_RELEASE_ARRAY(pBackendDXContext->cRasterizerState, pBackendDXContext->papRasterizerState); 4249 if (pBackendDXContext->papSamplerState) 4250 DX_RELEASE_ARRAY(pBackendDXContext->cSamplerState, pBackendDXContext->papSamplerState); 4251 if (pBackendDXContext->papQuery) 4252 DX_RELEASE_ARRAY(pBackendDXContext->cQuery, pBackendDXContext->papQuery); 4253 if (pBackendDXContext->paShader) 4254 { 4255 for (uint32_t i = 0; i < pBackendDXContext->cShader; ++i) 4256 D3D_RELEASE(pBackendDXContext->paShader[i].pShader); 4257 } 4258 4259 RTMemFreeZ(pBackendDXContext->papBlendState, sizeof(pBackendDXContext->papBlendState[0]) * pBackendDXContext->cBlendState); 4260 RTMemFreeZ(pBackendDXContext->papDepthStencilState, sizeof(pBackendDXContext->papDepthStencilState[0]) * pBackendDXContext->cDepthStencilState); 4261 RTMemFreeZ(pBackendDXContext->papSamplerState, sizeof(pBackendDXContext->papSamplerState[0]) * pBackendDXContext->cSamplerState); 4262 RTMemFreeZ(pBackendDXContext->papRasterizerState, sizeof(pBackendDXContext->papRasterizerState[0]) * pBackendDXContext->cRasterizerState); 4263 RTMemFreeZ(pBackendDXContext->paElementLayout, sizeof(pBackendDXContext->paElementLayout[0]) * pBackendDXContext->cElementLayout); 4264 RTMemFreeZ(pBackendDXContext->papRenderTargetView, sizeof(pBackendDXContext->papRenderTargetView[0]) * pBackendDXContext->cRenderTargetView); 4265 RTMemFreeZ(pBackendDXContext->papDepthStencilView, sizeof(pBackendDXContext->papDepthStencilView[0]) * pBackendDXContext->cDepthStencilView); 4266 RTMemFreeZ(pBackendDXContext->papShaderResourceView, sizeof(pBackendDXContext->papShaderResourceView[0]) * pBackendDXContext->cShaderResourceView); 4267 RTMemFreeZ(pBackendDXContext->papQuery, sizeof(pBackendDXContext->papQuery[0]) * pBackendDXContext->cQuery); 4268 RTMemFreeZ(pBackendDXContext->paShader, sizeof(pBackendDXContext->paShader[0]) * pBackendDXContext->cShader); 4269 4270 /* Destroy backend surfaces which belong to this context. */ 4271 /** @todo The context should have a list of surfaces (and also shared resources). */ 4272 for (uint32_t sid = 0; sid < pThisCC->svga.p3dState->cSurfaces; ++sid) 4273 { 4274 PVMSVGA3DSURFACE const pSurface = pThisCC->svga.p3dState->papSurfaces[sid]; 4275 if ( pSurface 4276 && pSurface->id == sid) 4277 { 4278 if (pSurface->idAssociatedContext == pDXContext->cid) 4279 { 4280 Assert(pSurface->pBackendSurface); 4281 vmsvga3dBackSurfaceDestroy(pThisCC, pSurface); 4282 } 4283 else if (pSurface->idAssociatedContext == DX_CID_BACKEND) 4284 { 4285 /* May have shared resources in this context. */ 4286 Assert(pSurface->pBackendSurface); 4287 DXSHAREDTEXTURE *pSharedTexture = (DXSHAREDTEXTURE *)RTAvlU32Get(&pSurface->pBackendSurface->SharedTextureTree, pDXContext->cid); 4288 if (pSharedTexture) 4289 { 4290 Assert(pSharedTexture->sid == sid); 4291 RTAvlU32Remove(&pSurface->pBackendSurface->SharedTextureTree, pDXContext->cid); 4292 D3D_RELEASE(pSharedTexture->pTexture); 4293 RTMemFreeZ(pSharedTexture, sizeof(*pSharedTexture)); 4294 } 4295 } 4296 } 4297 } 4298 4299 dxDeviceDestroy(pBackend, &pBackendDXContext->device); 4300 4301 RTMemFreeZ(pBackendDXContext, sizeof(*pBackendDXContext)); 3733 4302 pDXContext->pBackendDXContext = NULL; 3734 4303 } … … 3748 4317 { 3749 4318 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 3750 3751 RT_NOREF(pBackend, pDXContext); 3752 AssertFailed(); /** @todo Implement */ 3753 return VERR_NOT_IMPLEMENTED; 4319 RT_NOREF(pBackend, pDXContext); 4320 return VINF_SUCCESS; 3754 4321 } 3755 4322 … … 3815 4382 boxDst.d = 1; 3816 4383 3817 rc = vmsvgaR3UpdateGBSurfaceEx(pThisCC, pDXContext->cid,&imageId, &boxDst, &ptSrc);4384 rc = vmsvgaR3UpdateGBSurfaceEx(pThisCC, &imageId, &boxDst, &ptSrc); 3818 4385 AssertRCReturn(rc, rc); 3819 4386 } 3820 4387 3821 dxConstantBufferSet(pDevice, slot, type, pSurface->pBackendSurface->u. Buffer.pBuffer);4388 dxConstantBufferSet(pDevice, slot, type, pSurface->pBackendSurface->u.pBuffer); 3822 4389 return VINF_SUCCESS; 3823 4390 } … … 3865 4432 { 3866 4433 pDXShader = &pDXContext->pBackendDXContext->paShader[pShader->id]; 4434 Assert(pDXShader->enmShaderType >= SVGA3D_SHADERTYPE_MIN && pDXShader->enmShaderType < SVGA3D_SHADERTYPE_MAX); 3867 4435 uint32_t const idxShaderState = pDXShader->enmShaderType - SVGA3D_SHADERTYPE_MIN; 3868 4436 pDXContext->svgaDXContext.shaderState[idxShaderState].shaderId = pShader->id; … … 3980 4548 } 3981 4549 4550 /* Note which surfaces are being drawn. */ 4551 dxTrackRenderTargets(pThisCC, pDXContext); 4552 3982 4553 return VINF_SUCCESS; 3983 4554 } … … 3995 4566 3996 4567 pDevice->pImmediateContext->DrawIndexed(indexCount, startIndexLocation, baseVertexLocation); 4568 4569 /* Note which surfaces are being drawn. */ 4570 dxTrackRenderTargets(pThisCC, pDXContext); 4571 3997 4572 return VINF_SUCCESS; 3998 4573 } 3999 4574 4000 4575 4001 static DECLCALLBACK(int) vmsvga3dBackDXDrawInstanced(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4002 { 4576 static DECLCALLBACK(int) vmsvga3dBackDXDrawInstanced(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, 4577 uint32_t vertexCountPerInstance, uint32_t instanceCount, uint32_t startVertexLocation, uint32_t startInstanceLocation) 4578 { 4579 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4580 RT_NOREF(pBackend); 4581 4582 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4583 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4584 4003 4585 Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN); 4004 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4005 4006 RT_NOREF(pBackend, pDXContext); 4007 AssertFailed(); /** @todo Implement */ 4008 return VERR_NOT_IMPLEMENTED; 4009 } 4010 4011 4012 static DECLCALLBACK(int) vmsvga3dBackDXDrawIndexedInstanced(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4013 { 4586 4587 pDevice->pImmediateContext->DrawInstanced(vertexCountPerInstance, instanceCount, startVertexLocation, startInstanceLocation); 4588 4589 /* Note which surfaces are being drawn. */ 4590 dxTrackRenderTargets(pThisCC, pDXContext); 4591 4592 return VINF_SUCCESS; 4593 } 4594 4595 4596 static DECLCALLBACK(int) vmsvga3dBackDXDrawIndexedInstanced(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, 4597 uint32_t indexCountPerInstance, uint32_t instanceCount, uint32_t startIndexLocation, int32_t baseVertexLocation, uint32_t startInstanceLocation) 4598 { 4599 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4600 RT_NOREF(pBackend); 4601 4602 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4603 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4604 4014 4605 Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN); 4015 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4016 4017 RT_NOREF(pBackend, pDXContext); 4018 AssertFailed(); /** @todo Implement */ 4019 return VERR_NOT_IMPLEMENTED; 4606 4607 pDevice->pImmediateContext->DrawIndexedInstanced(indexCountPerInstance, instanceCount, startIndexLocation, baseVertexLocation, startInstanceLocation); 4608 4609 /* Note which surfaces are being drawn. */ 4610 dxTrackRenderTargets(pThisCC, pDXContext); 4611 4612 return VINF_SUCCESS; 4020 4613 } 4021 4614 … … 4119 4712 box.d = 1; 4120 4713 4121 rc = vmsvgaR3UpdateGBSurface(pThisCC, pDXContext->cid,&imageId, &box);4714 rc = vmsvgaR3UpdateGBSurface(pThisCC, &imageId, &box); 4122 4715 AssertRCReturn(rc, rc); 4123 4716 } 4124 4717 4125 paResources[idxVertexBuffer] = pSurface->pBackendSurface->u. Buffer.pBuffer;4718 paResources[idxVertexBuffer] = pSurface->pBackendSurface->u.pBuffer; 4126 4719 paStride[idxVertexBuffer] = paVertexBuffer[i].stride; 4127 4720 paOffset[idxVertexBuffer] = paVertexBuffer[i].offset; … … 4139 4732 } 4140 4733 4141 pDevice->pImmediateContext->IASetVertexBuffers(startBuffer, cVertexBuffer, paResources, paStride, paOffset); 4734 pDevice->pImmediateContext->IASetVertexBuffers(startBuffer, cVertexBuffer, 4735 &paResources[startBuffer], &paStride[startBuffer], &paOffset[startBuffer]); 4142 4736 4143 4737 return VINF_SUCCESS; … … 4186 4780 box.d = 1; 4187 4781 4188 rc = vmsvgaR3UpdateGBSurface(pThisCC, pDXContext->cid,&imageId, &box);4782 rc = vmsvgaR3UpdateGBSurface(pThisCC, &imageId, &box); 4189 4783 AssertRCReturn(rc, rc); 4190 4784 } 4191 4785 4192 pResource = pSurface->pBackendSurface->u. Buffer.pBuffer;4786 pResource = pSurface->pBackendSurface->u.pBuffer; 4193 4787 enmDxgiFormat = vmsvgaDXSurfaceFormat2Dxgi(format); 4194 4788 AssertReturn(enmDxgiFormat == DXGI_FORMAT_R16_UINT || enmDxgiFormat == DXGI_FORMAT_R32_UINT, VERR_INVALID_PARAMETER); … … 4539 5133 (pDstSurface->surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "")); 4540 5134 5135 /* Clip the box. */ 5136 /** @todo Use [src|dst]SubResource to index p[Src|Dst]Surface->paMipmapLevels array directly. */ 5137 uint32_t iSrcFace; 5138 uint32_t iSrcMipmap; 5139 vmsvga3dCalcMipmapAndFace(pSrcSurface->cLevels, srcSubResource, &iSrcMipmap, &iSrcFace); 5140 5141 uint32_t iDstFace; 5142 uint32_t iDstMipmap; 5143 vmsvga3dCalcMipmapAndFace(pDstSurface->cLevels, dstSubResource, &iDstMipmap, &iDstFace); 5144 5145 PVMSVGA3DMIPMAPLEVEL pSrcMipLevel; 5146 rc = vmsvga3dMipmapLevel(pSrcSurface, iSrcFace, iSrcMipmap, &pSrcMipLevel); 5147 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 5148 5149 PVMSVGA3DMIPMAPLEVEL pDstMipLevel; 5150 rc = vmsvga3dMipmapLevel(pDstSurface, iDstFace, iDstMipmap, &pDstMipLevel); 5151 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 5152 5153 SVGA3dCopyBox clipBox = *pBox; 5154 vmsvgaR3ClipCopyBox(&pSrcMipLevel->mipmapSize, &pDstMipLevel->mipmapSize, &clipBox); 5155 4541 5156 UINT DstSubresource = dstSubResource; 4542 UINT DstX = pBox->x;4543 UINT DstY = pBox->y;4544 UINT DstZ = pBox->z;5157 UINT DstX = clipBox.x; 5158 UINT DstY = clipBox.y; 5159 UINT DstZ = clipBox.z; 4545 5160 4546 5161 UINT SrcSubresource = srcSubResource; 4547 5162 D3D11_BOX SrcBox; 4548 SrcBox.left = pBox->x;4549 SrcBox.top = pBox->y;4550 SrcBox.front = pBox->z;4551 SrcBox.right = pBox->x + pBox->w;4552 SrcBox.bottom = pBox->y + pBox->h;4553 SrcBox.back = pBox->z + pBox->d;5163 SrcBox.left = clipBox.srcx; 5164 SrcBox.top = clipBox.srcy; 5165 SrcBox.front = clipBox.srcz; 5166 SrcBox.right = clipBox.srcx + clipBox.w; 5167 SrcBox.bottom = clipBox.srcy + clipBox.h; 5168 SrcBox.back = clipBox.srcz + clipBox.d; 4554 5169 4555 5170 ID3D11Resource *pDstResource; 4556 5171 ID3D11Resource *pSrcResource; 4557 5172 4558 if (pDstSurface->idAssociatedContext == pSrcSurface->idAssociatedContext) 4559 { 4560 /* Use the context which created the surfaces. */ 4561 if (pSrcSurface->idAssociatedContext != SVGA_ID_INVALID) 4562 { 4563 /* One of DXContexts has created the resources. */ 4564 if (pDXContext->cid != pSrcSurface->idAssociatedContext) 4565 { 4566 /** @todo test */ 4567 /* Get the context which has created the surfaces. */ 4568 rc = vmsvga3dDXContextFromCid(pThisCC->svga.p3dState, pSrcSurface->idAssociatedContext, &pDXContext); 4569 AssertRCReturn(rc, rc); 4570 4571 pDevice = &pDXContext->pBackendDXContext->device; 4572 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4573 } 4574 4575 pDstResource = dxResource(pDstSurface, pDXContext); 4576 pSrcResource = dxResource(pSrcSurface, pDXContext); 4577 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 4578 pSrcResource, SrcSubresource, &SrcBox); 4579 } 4580 else 4581 { 4582 /* Backend context has created the resources. */ 4583 pDstResource = pDstSurface->pBackendSurface->u.Resource.pResource; 4584 pSrcResource = pSrcSurface->pBackendSurface->u.Resource.pResource; 4585 pBackend->device.pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 4586 pSrcResource, SrcSubresource, &SrcBox); 4587 } 4588 } 4589 else 4590 { 4591 /* Different contexts. */ 4592 4593 /* One of the surfaces must be shared. */ 4594 AssertReturn( pSrcSurface->idAssociatedContext == SVGA_ID_INVALID 4595 || pDstSurface->idAssociatedContext == SVGA_ID_INVALID, VERR_NOT_SUPPORTED); 4596 4597 /* Use a context which created the not shared resource to do the copy. */ 4598 if (pSrcSurface->idAssociatedContext == SVGA_ID_INVALID) 4599 { 4600 if (pDXContext->cid != pDstSurface->idAssociatedContext) 4601 { 4602 /* Get the context which has created the destination resource. */ 4603 rc = vmsvga3dDXContextFromCid(pThisCC->svga.p3dState, pDstSurface->idAssociatedContext, &pDXContext); 4604 AssertRCReturn(rc, rc); 4605 4606 pDevice = &pDXContext->pBackendDXContext->device; 4607 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4608 } 4609 4610 pDstResource = dxResource(pDstSurface, pDXContext); 4611 pSrcResource = dxResource(pSrcSurface, pDXContext); 4612 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 4613 pSrcResource, SrcSubresource, &SrcBox); 4614 } 4615 else if (pDstSurface->idAssociatedContext == SVGA_ID_INVALID) 4616 { 4617 if (pDXContext->cid != pSrcSurface->idAssociatedContext) 4618 { 4619 /* Get the context which has created the source surface. */ 4620 rc = vmsvga3dDXContextFromCid(pThisCC->svga.p3dState, pSrcSurface->idAssociatedContext, &pDXContext); 4621 AssertRCReturn(rc, rc); 4622 4623 pDevice = &pDXContext->pBackendDXContext->device; 4624 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4625 } 4626 4627 pDstResource = dxResource(pDstSurface, pDXContext); 4628 pSrcResource = dxResource(pSrcSurface, pDXContext); 4629 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 4630 pSrcResource, SrcSubresource, &SrcBox); 4631 } 4632 else 4633 { 4634 AssertFailedReturn(VERR_NOT_SUPPORTED); 4635 } 4636 } 5173 pDstResource = dxResource(pThisCC->svga.p3dState, pDstSurface, pDXContext); 5174 pSrcResource = dxResource(pThisCC->svga.p3dState, pSrcSurface, pDXContext); 5175 5176 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 5177 pSrcResource, SrcSubresource, &SrcBox); 5178 5179 pDstSurface->pBackendSurface->cidDrawing = pDXContext->cid; 4637 5180 return VINF_SUCCESS; 4638 5181 } … … 4674 5217 4675 5218 4676 static DECLCALLBACK(int) vmsvga3dBackDXUpdateSubResource(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4677 { 4678 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4679 4680 RT_NOREF(pBackend, pDXContext); 4681 AssertFailed(); /** @todo Implement */ 4682 return VERR_NOT_IMPLEMENTED; 4683 } 4684 4685 4686 static DECLCALLBACK(int) vmsvga3dBackDXReadbackSubResource(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4687 { 4688 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4689 4690 RT_NOREF(pBackend, pDXContext); 4691 AssertFailed(); /** @todo Implement */ 4692 return VERR_NOT_IMPLEMENTED; 4693 } 4694 4695 4696 static DECLCALLBACK(int) vmsvga3dBackDXInvalidateSubResource(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4697 { 4698 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4699 4700 RT_NOREF(pBackend, pDXContext); 4701 AssertFailed(); /** @todo Implement */ 4702 return VERR_NOT_IMPLEMENTED; 4703 } 4704 4705 4706 static DECLCALLBACK(int) vmsvga3dBackDXDefineShaderResourceView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId, SVGACOTableDXSRViewEntry const *pEntry) 4707 { 4708 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4709 RT_NOREF(pBackend); 4710 4711 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4712 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4713 5219 static int dxDefineShaderResourceView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId, SVGACOTableDXSRViewEntry const *pEntry) 5220 { 4714 5221 /* Get corresponding resource for pEntry->sid. Create the surface if does not yet exist. */ 4715 5222 PVMSVGA3DSURFACE pSurface; … … 4724 5231 } 4725 5232 4726 HRESULT hr = dxShaderResourceViewCreate(p DXContext, pEntry, pSurface, &pDXContext->pBackendDXContext->papShaderResourceView[shaderResourceViewId]);5233 HRESULT hr = dxShaderResourceViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDXContext->pBackendDXContext->papShaderResourceView[shaderResourceViewId]); 4727 5234 if (SUCCEEDED(hr)) 4728 5235 return VINF_SUCCESS; … … 4731 5238 4732 5239 5240 static DECLCALLBACK(int) vmsvga3dBackDXDefineShaderResourceView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId, SVGACOTableDXSRViewEntry const *pEntry) 5241 { 5242 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5243 RT_NOREF(pBackend); 5244 5245 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 5246 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5247 5248 return dxDefineShaderResourceView(pThisCC, pDXContext, shaderResourceViewId, pEntry); 5249 } 5250 5251 4733 5252 static DECLCALLBACK(int) vmsvga3dBackDXDestroyShaderResourceView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId) 4734 5253 { … … 4741 5260 4742 5261 4743 static DECLCALLBACK(int) vmsvga3dBackDXDefineRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry) 4744 { 4745 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4746 RT_NOREF(pBackend); 4747 4748 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4749 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4750 5262 static int dxDefineRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry) 5263 { 4751 5264 /* Get corresponding resource for pEntry->sid. Create the surface if does not yet exist. */ 4752 5265 PVMSVGA3DSURFACE pSurface; … … 4761 5274 } 4762 5275 4763 HRESULT hr = dxRenderTargetViewCreate(p DXContext, pEntry, pSurface, &pDXContext->pBackendDXContext->papRenderTargetView[renderTargetViewId]);5276 HRESULT hr = dxRenderTargetViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDXContext->pBackendDXContext->papRenderTargetView[renderTargetViewId]); 4764 5277 if (SUCCEEDED(hr)) 4765 5278 return VINF_SUCCESS; 5279 4766 5280 return VERR_INVALID_STATE; 5281 } 5282 5283 5284 static DECLCALLBACK(int) vmsvga3dBackDXDefineRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry) 5285 { 5286 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5287 RT_NOREF(pBackend); 5288 5289 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 5290 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5291 5292 return dxDefineRenderTargetView(pThisCC, pDXContext, renderTargetViewId, pEntry); 4767 5293 } 4768 5294 … … 4778 5304 4779 5305 4780 static DECLCALLBACK(int) vmsvga3dBackDXDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry) 4781 { 4782 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4783 RT_NOREF(pBackend); 4784 4785 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4786 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4787 5306 static int dxDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry) 5307 { 4788 5308 /* Get corresponding resource for pEntry->sid. Create the surface if does not yet exist. */ 4789 5309 PVMSVGA3DSURFACE pSurface; … … 4791 5311 AssertRCReturn(rc, rc); 4792 5312 5313 if ( pSurface->pBackendSurface != NULL 5314 && pDXContext->cid != pSurface->idAssociatedContext) 5315 { 5316 /* Supposed to be per context. */ 5317 //AssertFailed(); // test 5318 vmsvga3dBackSurfaceDestroy(pThisCC, pSurface); 5319 } 5320 4793 5321 if (pSurface->pBackendSurface == NULL) 4794 5322 { … … 4798 5326 } 4799 5327 4800 HRESULT hr = dxDepthStencilViewCreate(p Device, pEntry, pSurface->pBackendSurface, &pDXContext->pBackendDXContext->papDepthStencilView[depthStencilViewId]);5328 HRESULT hr = dxDepthStencilViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDXContext->pBackendDXContext->papDepthStencilView[depthStencilViewId]); 4801 5329 if (SUCCEEDED(hr)) 4802 5330 return VINF_SUCCESS; … … 4804 5332 } 4805 5333 5334 static DECLCALLBACK(int) vmsvga3dBackDXDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry) 5335 { 5336 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5337 RT_NOREF(pBackend); 5338 5339 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 5340 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 5341 5342 return dxDefineDepthStencilView(pThisCC, pDXContext, depthStencilViewId, pEntry); 5343 } 5344 4806 5345 4807 5346 static DECLCALLBACK(int) vmsvga3dBackDXDestroyDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId) … … 4815 5354 4816 5355 4817 static DECLCALLBACK(int) vmsvga3dBackDXDefineElementLayout(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dElementLayoutId elementLayoutId, SVGACOTableDXElementLayoutEntry const *pEntry) 4818 { 4819 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4820 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4821 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4822 4823 RT_NOREF(pBackend, elementLayoutId, pEntry); 4824 4825 /* Not much can be done here because ID3D11Device::CreateInputLayout requires 4826 * a pShaderBytecodeWithInputSignature which is not known at this moment. 4827 * InputLayout object will be created in SVGA_3D_CMD_DX_SET_INPUT_LAYOUT. 4828 */ 4829 4830 DXELEMENTLAYOUT *pDXElementLayout = &pDXContext->pBackendDXContext->paElementLayout[pEntry->elid]; 5356 static int dxDefineElementLayout(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dElementLayoutId elementLayoutId, SVGACOTableDXElementLayoutEntry const *pEntry) 5357 { 5358 DXELEMENTLAYOUT *pDXElementLayout = &pDXContext->pBackendDXContext->paElementLayout[elementLayoutId]; 4831 5359 D3D_RELEASE(pDXElementLayout->pElementLayout); 4832 5360 … … 4860 5388 4861 5389 4862 static DECLCALLBACK(int) vmsvga3dBackDXDestroyElementLayout(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4863 { 4864 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4865 4866 RT_NOREF(pBackend, pDXContext); 4867 AssertFailed(); /** @todo Implement */ 4868 return VERR_NOT_IMPLEMENTED; 4869 } 4870 4871 4872 static DECLCALLBACK(int) vmsvga3dBackDXDefineBlendState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, 4873 SVGA3dBlendStateId blendId, SVGACOTableDXBlendStateEntry const *pEntry) 5390 static DECLCALLBACK(int) vmsvga3dBackDXDefineElementLayout(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dElementLayoutId elementLayoutId, SVGACOTableDXElementLayoutEntry const *pEntry) 4874 5391 { 4875 5392 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; … … 4878 5395 4879 5396 RT_NOREF(pBackend); 5397 5398 /* Not much can be done here because ID3D11Device::CreateInputLayout requires 5399 * a pShaderBytecodeWithInputSignature which is not known at this moment. 5400 * InputLayout object will be created in SVGA_3D_CMD_DX_SET_INPUT_LAYOUT. 5401 */ 5402 5403 Assert(elementLayoutId == pEntry->elid); 5404 5405 return dxDefineElementLayout(pDXContext, elementLayoutId, pEntry); 5406 } 5407 5408 5409 static DECLCALLBACK(int) vmsvga3dBackDXDestroyElementLayout(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 5410 { 5411 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5412 5413 RT_NOREF(pBackend, pDXContext); 5414 AssertFailed(); /** @todo Implement */ 5415 return VERR_NOT_IMPLEMENTED; 5416 } 5417 5418 5419 static int dxDefineBlendState(PVMSVGA3DDXCONTEXT pDXContext, 5420 SVGA3dBlendStateId blendId, SVGACOTableDXBlendStateEntry const *pEntry) 5421 { 5422 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 5423 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4880 5424 4881 5425 HRESULT hr = dxBlendStateCreate(pDevice, pEntry, &pDXContext->pBackendDXContext->papBlendState[blendId]); … … 4885 5429 } 4886 5430 5431 static DECLCALLBACK(int) vmsvga3dBackDXDefineBlendState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, 5432 SVGA3dBlendStateId blendId, SVGACOTableDXBlendStateEntry const *pEntry) 5433 { 5434 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5435 RT_NOREF(pBackend); 5436 5437 return dxDefineBlendState(pDXContext, blendId, pEntry); 5438 } 5439 4887 5440 4888 5441 static DECLCALLBACK(int) vmsvga3dBackDXDestroyBlendState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) … … 4896 5449 4897 5450 4898 static DECLCALLBACK(int) vmsvga3dBackDXDefineDepthStencilState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilStateId depthStencilId, SVGACOTableDXDepthStencilEntry *pEntry) 4899 { 4900 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5451 static int dxDefineDepthStencilState(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilStateId depthStencilId, SVGACOTableDXDepthStencilEntry const *pEntry) 5452 { 4901 5453 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4902 5454 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4903 4904 RT_NOREF(pBackend);4905 5455 4906 5456 HRESULT hr = dxDepthStencilStateCreate(pDevice, pEntry, &pDXContext->pBackendDXContext->papDepthStencilState[depthStencilId]); … … 4911 5461 4912 5462 5463 static DECLCALLBACK(int) vmsvga3dBackDXDefineDepthStencilState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilStateId depthStencilId, SVGACOTableDXDepthStencilEntry const *pEntry) 5464 { 5465 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5466 RT_NOREF(pBackend); 5467 5468 return dxDefineDepthStencilState(pDXContext, depthStencilId, pEntry); 5469 } 5470 5471 4913 5472 static DECLCALLBACK(int) vmsvga3dBackDXDestroyDepthStencilState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4914 5473 { … … 4921 5480 4922 5481 4923 static DECLCALLBACK(int) vmsvga3dBackDXDefineRasterizerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRasterizerStateId rasterizerId, SVGACOTableDXRasterizerStateEntry const *pEntry) 4924 { 4925 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5482 static int dxDefineRasterizerState(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRasterizerStateId rasterizerId, SVGACOTableDXRasterizerStateEntry const *pEntry) 5483 { 4926 5484 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4927 5485 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4928 4929 RT_NOREF(pBackend);4930 5486 4931 5487 HRESULT hr = dxRasterizerStateCreate(pDevice, pEntry, &pDXContext->pBackendDXContext->papRasterizerState[rasterizerId]); … … 4936 5492 4937 5493 5494 static DECLCALLBACK(int) vmsvga3dBackDXDefineRasterizerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRasterizerStateId rasterizerId, SVGACOTableDXRasterizerStateEntry const *pEntry) 5495 { 5496 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5497 RT_NOREF(pBackend); 5498 5499 return dxDefineRasterizerState(pDXContext, rasterizerId, pEntry); 5500 } 5501 5502 4938 5503 static DECLCALLBACK(int) vmsvga3dBackDXDestroyRasterizerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4939 5504 { … … 4946 5511 4947 5512 4948 static DECLCALLBACK(int) vmsvga3dBackDXDefineSamplerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSamplerId samplerId, SVGACOTableDXSamplerEntry const *pEntry) 4949 { 4950 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5513 static int dxDefineSamplerState(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSamplerId samplerId, SVGACOTableDXSamplerEntry const *pEntry) 5514 { 4951 5515 DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device; 4952 5516 AssertReturn(pDevice->pDevice, VERR_INVALID_STATE); 4953 4954 RT_NOREF(pBackend);4955 5517 4956 5518 HRESULT hr = dxSamplerStateCreate(pDevice, pEntry, &pDXContext->pBackendDXContext->papSamplerState[samplerId]); … … 4961 5523 4962 5524 5525 static DECLCALLBACK(int) vmsvga3dBackDXDefineSamplerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSamplerId samplerId, SVGACOTableDXSamplerEntry const *pEntry) 5526 { 5527 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 5528 RT_NOREF(pBackend); 5529 5530 return dxDefineSamplerState(pDXContext, samplerId, pEntry); 5531 } 5532 5533 4963 5534 static DECLCALLBACK(int) vmsvga3dBackDXDestroySamplerState(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 4964 5535 { … … 4971 5542 4972 5543 4973 static DECLCALLBACK(int) vmsvga3dBackDXDefineShader(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSHADER pShader) 4974 { 4975 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4976 5544 5545 static int dxDefineShader(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId, SVGACOTableDXShaderEntry const *pEntry) 5546 { 5547 DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[shaderId]; 5548 pDXShader->enmShaderType = pEntry->type; 5549 5550 PVMSVGA3DSHADER pShader = &pDXContext->paShader[shaderId]; 5551 pShader->u.pvBackendShader = pDXShader; 5552 5553 return VINF_SUCCESS; 5554 } 5555 5556 5557 static DECLCALLBACK(int) vmsvga3dBackDXDefineShader(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId, SVGACOTableDXShaderEntry const *pEntry) 5558 { 5559 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; 4977 5560 RT_NOREF(pBackend); 4978 5561 4979 DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[ pShader->id];5562 DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[shaderId]; 4980 5563 D3D_RELEASE(pDXShader->pShader); 4981 pDXShader->enmShaderType = pShader->type; 4982 pShader->u.pvBackendShader = pDXShader; 4983 return VINF_SUCCESS; 5564 5565 return dxDefineShader(pDXContext, shaderId, pEntry); 4984 5566 } 4985 5567 … … 5006 5588 5007 5589 DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[pShader->id]; 5590 Assert(pDXShader->enmShaderType == pShader->type); 5591 5008 5592 if (pDXShader->pvDXBC) 5009 5593 { … … 5055 5639 5056 5640 HRESULT hr = dxShaderCreate(pDevice, pShader, pDXShader); 5057 if (FAILED(hr)) 5641 if (SUCCEEDED(hr)) 5642 { 5643 } 5644 else 5058 5645 rc = VERR_INVALID_STATE; 5059 5646 } … … 5096 5683 5097 5684 5098 static int dxCOTableRealloc(void **ppvCOTable, uint32_t *pcCOTable, uint32_t cbEntry, uint32_t cEntries , uint32_t cValidEntries)5685 static int dxCOTableRealloc(void **ppvCOTable, uint32_t *pcCOTable, uint32_t cbEntry, uint32_t cEntries) 5099 5686 { 5100 5687 if (*pcCOTable != cEntries) … … 5105 5692 void *pvNew = RTMemRealloc(*ppvCOTable, cEntries * cbEntry); 5106 5693 AssertReturn(pvNew, VERR_NO_MEMORY); 5107 memset((uint8_t *)pvNew + cValidEntries * cbEntry, 0, (cEntries - cValidEntries) * cbEntry);5108 5694 *ppvCOTable = pvNew; 5109 5695 } … … 5117 5703 } 5118 5704 5705 if (*ppvCOTable) 5706 memset(*ppvCOTable, 0, cEntries * cbEntry); 5707 5119 5708 return VINF_SUCCESS; 5120 5709 } 5121 5710 5122 static DECLCALLBACK(int) vmsvga3dBackDXSetCOTable(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableType type, uint32_t c Entries, uint32_t cValidEntries)5711 static DECLCALLBACK(int) vmsvga3dBackDXSetCOTable(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableType type, uint32_t cValidEntries) 5123 5712 { 5124 5713 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; … … 5129 5718 int rc = VINF_SUCCESS; 5130 5719 5131 /* Allocate paBlendState for example. */ 5132 /* Keep first cValidEntries. */ 5720 /* 5721 * 1) Release current backend table, if exists; 5722 * 2) Reallocate memory for the new backend table; 5723 * 3) If cValidEntries is not zero, then re-define corresponding backend table elements. 5724 */ 5133 5725 switch (type) 5134 5726 { 5135 5727 case SVGA_COTABLE_RTVIEW: 5728 /* Clear current entries. */ 5136 5729 if (pBackendDXContext->papRenderTargetView) 5730 DX_RELEASE_ARRAY(pBackendDXContext->cRenderTargetView, pBackendDXContext->papRenderTargetView); 5731 5732 rc = dxCOTableRealloc((void **)&pBackendDXContext->papRenderTargetView, &pBackendDXContext->cRenderTargetView, 5733 sizeof(pBackendDXContext->papRenderTargetView[0]), pDXContext->cot.cRTView); 5734 AssertRCBreak(rc); 5735 5736 for (uint32_t i = 0; i < cValidEntries; ++i) 5137 5737 { 5138 /* Clear obsolete entries. */ 5139 DX_RELEASE_ARRAY(pBackendDXContext->cRenderTargetView - cValidEntries, &pBackendDXContext->papRenderTargetView[cValidEntries]); 5738 SVGACOTableDXRTViewEntry const *pEntry = &pDXContext->cot.paRTView[i]; 5739 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5740 continue; /* Skip uninitialized entry. */ 5741 5742 dxDefineRenderTargetView(pThisCC, pDXContext, i, pEntry); 5140 5743 } 5141 5142 rc = dxCOTableRealloc((void **)&pBackendDXContext->papRenderTargetView, &pBackendDXContext->cRenderTargetView,5143 sizeof(pBackendDXContext->papRenderTargetView[0]), cEntries, cValidEntries);5144 5744 break; 5145 5745 case SVGA_COTABLE_DSVIEW: 5146 5746 if (pBackendDXContext->papDepthStencilView) 5747 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilView, pBackendDXContext->papDepthStencilView); 5748 5749 rc = dxCOTableRealloc((void **)&pBackendDXContext->papDepthStencilView, &pBackendDXContext->cDepthStencilView, 5750 sizeof(pBackendDXContext->papDepthStencilView[0]), pDXContext->cot.cDSView); 5751 AssertRCBreak(rc); 5752 5753 for (uint32_t i = 0; i < cValidEntries; ++i) 5147 5754 { 5148 /* Clear obsolete entries. */ 5149 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilView - cValidEntries, &pBackendDXContext->papDepthStencilView[cValidEntries]); 5755 SVGACOTableDXDSViewEntry const *pEntry = &pDXContext->cot.paDSView[i]; 5756 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5757 continue; /* Skip uninitialized entry. */ 5758 5759 dxDefineDepthStencilView(pThisCC, pDXContext, i, pEntry); 5150 5760 } 5151 5152 rc = dxCOTableRealloc((void **)&pBackendDXContext->papDepthStencilView, &pBackendDXContext->cDepthStencilView,5153 sizeof(pBackendDXContext->papDepthStencilView[0]), cEntries, cValidEntries);5154 5761 break; 5155 5762 case SVGA_COTABLE_SRVIEW: 5156 5763 if (pBackendDXContext->papShaderResourceView) 5764 DX_RELEASE_ARRAY(pBackendDXContext->cShaderResourceView, pBackendDXContext->papShaderResourceView); 5765 5766 rc = dxCOTableRealloc((void **)&pBackendDXContext->papShaderResourceView, &pBackendDXContext->cShaderResourceView, 5767 sizeof(pBackendDXContext->papShaderResourceView[0]), pDXContext->cot.cSRView); 5768 AssertRCBreak(rc); 5769 5770 for (uint32_t i = 0; i < cValidEntries; ++i) 5157 5771 { 5158 /* Clear obsolete entries. */ 5159 DX_RELEASE_ARRAY(pBackendDXContext->cShaderResourceView - cValidEntries, &pBackendDXContext->papShaderResourceView[cValidEntries]); 5772 SVGACOTableDXSRViewEntry const *pEntry = &pDXContext->cot.paSRView[i]; 5773 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5774 continue; /* Skip uninitialized entry. */ 5775 5776 dxDefineShaderResourceView(pThisCC, pDXContext, i, pEntry); 5160 5777 } 5161 5162 rc = dxCOTableRealloc((void **)&pBackendDXContext->papShaderResourceView, &pBackendDXContext->cShaderResourceView,5163 sizeof(pBackendDXContext->papShaderResourceView[0]), cEntries, cValidEntries);5164 5778 break; 5165 5779 case SVGA_COTABLE_ELEMENTLAYOUT: 5166 5780 if (pBackendDXContext->paElementLayout) 5167 5781 { 5168 /* Clear obsolete entries. */ 5169 for (uint32_t i = cValidEntries; i < pBackendDXContext->cElementLayout; ++i) 5782 for (uint32_t i = 0; i < pBackendDXContext->cElementLayout; ++i) 5170 5783 D3D_RELEASE(pBackendDXContext->paElementLayout[i].pElementLayout); 5171 5784 } 5172 5785 5173 5786 rc = dxCOTableRealloc((void **)&pBackendDXContext->paElementLayout, &pBackendDXContext->cElementLayout, 5174 sizeof(pBackendDXContext->paElementLayout[0]), cEntries, cValidEntries); 5787 sizeof(pBackendDXContext->paElementLayout[0]), pDXContext->cot.cElementLayout); 5788 AssertRCBreak(rc); 5789 5790 for (uint32_t i = 0; i < cValidEntries; ++i) 5791 { 5792 SVGACOTableDXElementLayoutEntry const *pEntry = &pDXContext->cot.paElementLayout[i]; 5793 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5794 continue; /* Skip uninitialized entry. */ 5795 5796 dxDefineElementLayout(pDXContext, i, pEntry); 5797 } 5175 5798 break; 5176 5799 case SVGA_COTABLE_BLENDSTATE: 5177 5800 if (pBackendDXContext->papBlendState) 5801 DX_RELEASE_ARRAY(pBackendDXContext->cBlendState, pBackendDXContext->papBlendState); 5802 5803 rc = dxCOTableRealloc((void **)&pBackendDXContext->papBlendState, &pBackendDXContext->cBlendState, 5804 sizeof(pBackendDXContext->papBlendState[0]), pDXContext->cot.cBlendState); 5805 AssertRCBreak(rc); 5806 5807 for (uint32_t i = 0; i < cValidEntries; ++i) 5178 5808 { 5179 /* Clear obsolete entries. */ 5180 DX_RELEASE_ARRAY(pBackendDXContext->cBlendState - cValidEntries, &pBackendDXContext->papBlendState[cValidEntries]); 5809 SVGACOTableDXBlendStateEntry const *pEntry = &pDXContext->cot.paBlendState[i]; 5810 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5811 continue; /* Skip uninitialized entry. */ 5812 5813 dxDefineBlendState(pDXContext, i, pEntry); 5181 5814 } 5182 5183 rc = dxCOTableRealloc((void **)&pBackendDXContext->papBlendState, &pBackendDXContext->cBlendState,5184 sizeof(pBackendDXContext->papBlendState[0]), cEntries, cValidEntries);5185 5815 break; 5186 5816 case SVGA_COTABLE_DEPTHSTENCIL: 5187 5817 if (pBackendDXContext->papDepthStencilState) 5818 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilState, pBackendDXContext->papDepthStencilState); 5819 5820 rc = dxCOTableRealloc((void **)&pBackendDXContext->papDepthStencilState, &pBackendDXContext->cDepthStencilState, 5821 sizeof(pBackendDXContext->papDepthStencilState[0]), pDXContext->cot.cDepthStencil); 5822 AssertRCBreak(rc); 5823 5824 for (uint32_t i = 0; i < cValidEntries; ++i) 5188 5825 { 5189 /* Clear obsolete entries. */ 5190 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilState - cValidEntries, &pBackendDXContext->papDepthStencilState[cValidEntries]); 5826 SVGACOTableDXDepthStencilEntry const *pEntry = &pDXContext->cot.paDepthStencil[i]; 5827 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5828 continue; /* Skip uninitialized entry. */ 5829 5830 dxDefineDepthStencilState(pDXContext, i, pEntry); 5191 5831 } 5192 5193 rc = dxCOTableRealloc((void **)&pBackendDXContext->papDepthStencilState, &pBackendDXContext->cDepthStencilState,5194 sizeof(pBackendDXContext->papDepthStencilState[0]), cEntries, cValidEntries);5195 5832 break; 5196 5833 case SVGA_COTABLE_RASTERIZERSTATE: 5197 5834 if (pBackendDXContext->papRasterizerState) 5835 DX_RELEASE_ARRAY(pBackendDXContext->cRasterizerState, pBackendDXContext->papRasterizerState); 5836 5837 rc = dxCOTableRealloc((void **)&pBackendDXContext->papRasterizerState, &pBackendDXContext->cRasterizerState, 5838 sizeof(pBackendDXContext->papRasterizerState[0]), pDXContext->cot.cRasterizerState); 5839 AssertRCBreak(rc); 5840 5841 for (uint32_t i = 0; i < cValidEntries; ++i) 5198 5842 { 5199 /* Clear obsolete entries. */ 5200 DX_RELEASE_ARRAY(pBackendDXContext->cRasterizerState - cValidEntries, &pBackendDXContext->papRasterizerState[cValidEntries]); 5843 SVGACOTableDXRasterizerStateEntry const *pEntry = &pDXContext->cot.paRasterizerState[i]; 5844 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5845 continue; /* Skip uninitialized entry. */ 5846 5847 dxDefineRasterizerState(pDXContext, i, pEntry); 5201 5848 } 5202 5203 rc = dxCOTableRealloc((void **)&pBackendDXContext->papRasterizerState, &pBackendDXContext->cRasterizerState,5204 sizeof(pBackendDXContext->papRasterizerState[0]), cEntries, cValidEntries);5205 5849 break; 5206 5850 case SVGA_COTABLE_SAMPLER: 5207 5851 if (pBackendDXContext->papSamplerState) 5852 DX_RELEASE_ARRAY(pBackendDXContext->cSamplerState, pBackendDXContext->papSamplerState); 5853 5854 rc = dxCOTableRealloc((void **)&pBackendDXContext->papSamplerState, &pBackendDXContext->cSamplerState, 5855 sizeof(pBackendDXContext->papSamplerState[0]), pDXContext->cot.cSampler); 5856 AssertRCBreak(rc); 5857 5858 for (uint32_t i = 0; i < cValidEntries; ++i) 5208 5859 { 5209 /* Clear obsolete entries. */ 5210 DX_RELEASE_ARRAY(pBackendDXContext->cSamplerState - cValidEntries, &pBackendDXContext->papSamplerState[cValidEntries]); 5860 SVGACOTableDXSamplerEntry const *pEntry = &pDXContext->cot.paSampler[i]; 5861 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5862 continue; /* Skip uninitialized entry. */ 5863 5864 dxDefineSamplerState(pDXContext, i, pEntry); 5211 5865 } 5212 5213 rc = dxCOTableRealloc((void **)&pBackendDXContext->papSamplerState, &pBackendDXContext->cSamplerState,5214 sizeof(pBackendDXContext->papSamplerState[0]), cEntries, cValidEntries);5215 5866 break; 5216 5867 case SVGA_COTABLE_STREAMOUTPUT: … … 5219 5870 case SVGA_COTABLE_DXQUERY: 5220 5871 if (pBackendDXContext->papQuery) 5872 DX_RELEASE_ARRAY(pBackendDXContext->cQuery, pBackendDXContext->papQuery); 5873 5874 rc = dxCOTableRealloc((void **)&pBackendDXContext->papQuery, &pBackendDXContext->cQuery, 5875 sizeof(pBackendDXContext->papQuery[0]), pDXContext->cot.cQuery); 5876 AssertRCBreak(rc); 5877 5878 for (uint32_t i = 0; i < cValidEntries; ++i) 5221 5879 { 5222 /* Clear obsolete entries. */ 5223 DX_RELEASE_ARRAY(pBackendDXContext->cQuery - cValidEntries, &pBackendDXContext->papQuery[cValidEntries]); 5880 SVGACOTableDXQueryEntry const *pEntry = &pDXContext->cot.paQuery[i]; 5881 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5882 continue; /* Skip uninitialized entry. */ 5883 5884 AssertFailed(); /** @todo implement */ 5224 5885 } 5225 5226 rc = dxCOTableRealloc((void **)&pBackendDXContext->papQuery, &pBackendDXContext->cQuery,5227 sizeof(pBackendDXContext->papQuery[0]), cEntries, cValidEntries);5228 5886 break; 5229 5887 case SVGA_COTABLE_DXSHADER: 5230 5888 if (pBackendDXContext->paShader) 5231 5889 { 5232 /* Clear obsolete entries. */ 5233 for (uint32_t i = cValidEntries; i < pBackendDXContext->cShader; ++i) 5890 for (uint32_t i = 0; i < pBackendDXContext->cShader; ++i) 5234 5891 D3D_RELEASE(pBackendDXContext->paShader[i].pShader); 5235 5892 } 5236 5893 5237 5894 rc = dxCOTableRealloc((void **)&pBackendDXContext->paShader, &pBackendDXContext->cShader, 5238 sizeof(pBackendDXContext->paShader[0]), cEntries, cValidEntries); 5895 sizeof(pBackendDXContext->paShader[0]), pDXContext->cot.cShader); 5896 AssertRCBreak(rc); 5897 5898 for (uint32_t i = 0; i < cValidEntries; ++i) 5899 { 5900 SVGACOTableDXShaderEntry const *pEntry = &pDXContext->cot.paShader[i]; 5901 /** @todo The caller must verify the COTable content using same rules as when a new entry is defined. */ 5902 if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL) 5903 continue; /* Skip uninitialized entry. */ 5904 5905 /** @todo this should be in the commd DX code (the caller). */ 5906 PVMSVGA3DSHADER pShader = &pDXContext->paShader[i]; 5907 pShader->id = i; 5908 pShader->cid = pDXContext->cid; 5909 pShader->type = pEntry->type; 5910 pShader->cbData = pEntry->sizeInBytes; 5911 pShader->pShaderProgram = NULL; 5912 pShader->u.pvBackendShader = NULL; 5913 5914 dxDefineShader(pDXContext, i, pEntry); 5915 } 5239 5916 break; 5240 5917 case SVGA_COTABLE_UAVIEW: … … 5257 5934 5258 5935 5259 static DECLCALLBACK(int) vmsvga3dBackDXTransferFromBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)5260 {5261 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;5262 5263 RT_NOREF(pBackend, pDXContext);5264 AssertFailed(); /** @todo Implement */5265 return VERR_NOT_IMPLEMENTED;5266 }5267 5268 5269 5936 static DECLCALLBACK(int) vmsvga3dBackDXSurfaceCopyAndReadback(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 5270 5937 { … … 5298 5965 5299 5966 static DECLCALLBACK(int) vmsvga3dBackDXReadbackAllQuery(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 5300 {5301 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;5302 5303 RT_NOREF(pBackend, pDXContext);5304 AssertFailed(); /** @todo Implement */5305 return VERR_NOT_IMPLEMENTED;5306 }5307 5308 5309 static DECLCALLBACK(int) vmsvga3dBackDXPredTransferFromBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)5310 5967 { 5311 5968 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend; … … 5858 6515 p->pfnDXPresentBlt = vmsvga3dBackDXPresentBlt; 5859 6516 p->pfnDXGenMips = vmsvga3dBackDXGenMips; 5860 p->pfnDXUpdateSubResource = vmsvga3dBackDXUpdateSubResource;5861 p->pfnDXReadbackSubResource = vmsvga3dBackDXReadbackSubResource;5862 p->pfnDXInvalidateSubResource = vmsvga3dBackDXInvalidateSubResource;5863 6517 p->pfnDXDefineShaderResourceView = vmsvga3dBackDXDefineShaderResourceView; 5864 6518 p->pfnDXDestroyShaderResourceView = vmsvga3dBackDXDestroyShaderResourceView; … … 5885 6539 p->pfnDXSetCOTable = vmsvga3dBackDXSetCOTable; 5886 6540 p->pfnDXBufferCopy = vmsvga3dBackDXBufferCopy; 5887 p->pfnDXTransferFromBuffer = vmsvga3dBackDXTransferFromBuffer;5888 6541 p->pfnDXSurfaceCopyAndReadback = vmsvga3dBackDXSurfaceCopyAndReadback; 5889 6542 p->pfnDXMoveQuery = vmsvga3dBackDXMoveQuery; 5890 6543 p->pfnDXBindAllQuery = vmsvga3dBackDXBindAllQuery; 5891 6544 p->pfnDXReadbackAllQuery = vmsvga3dBackDXReadbackAllQuery; 5892 p->pfnDXPredTransferFromBuffer = vmsvga3dBackDXPredTransferFromBuffer;5893 6545 p->pfnDXMobFence64 = vmsvga3dBackDXMobFence64; 5894 6546 p->pfnDXBindAllShader = vmsvga3dBackDXBindAllShader; … … 5955 6607 { 5956 6608 VMSVGA3DBACKENDFUNCSMAP *p = (VMSVGA3DBACKENDFUNCSMAP *)pvInterfaceFuncs; 5957 p->pfnSurfaceMap = vmsvga3d SurfaceMap;5958 p->pfnSurfaceUnmap = vmsvga3d SurfaceUnmap;6609 p->pfnSurfaceMap = vmsvga3dBackSurfaceMap; 6610 p->pfnSurfaceUnmap = vmsvga3dBackSurfaceUnmap; 5959 6611 } 5960 6612 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r89171 r91361 2743 2743 2744 2744 rc = vmsvga3dSurfaceDefine(pThisCC, sid, surfaceFlags, format, multisampleCount, autogenFilter, 2745 cMipLevels, &pMipLevelSize[0] );2745 cMipLevels, &pMipLevelSize[0], /* fAllocMipLevels = */ true); 2746 2746 AssertRC(rc); 2747 2747 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r89163 r91361 41 41 #include "DevVGA-SVGA-internal.h" 42 42 43 44 static int vmsvga3dSurfaceAllocMipLevels(PVMSVGA3DSURFACE pSurface) 45 { 46 /* Allocate buffer to hold the surface data until we can move it into a D3D object */ 47 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->cFaces; ++i) 48 { 49 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; 50 AssertReturn(pMipmapLevel->pSurfaceData == NULL, VERR_INVALID_STATE); 51 pMipmapLevel->pSurfaceData = RTMemAllocZ(pMipmapLevel->cbSurface); 52 AssertReturn(pMipmapLevel->pSurfaceData, VERR_NO_MEMORY); 53 } 54 return VINF_SUCCESS; 55 } 56 57 58 static void vmsvga3dSurfaceFreeMipLevels(PVMSVGA3DSURFACE pSurface) 59 { 60 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->cFaces; ++i) 61 { 62 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; 63 RTMemFreeZ(pMipmapLevel->pSurfaceData, pMipmapLevel->cbSurface); 64 pMipmapLevel->pSurfaceData = NULL; 65 } 66 } 43 67 44 68 … … 59 83 int vmsvga3dSurfaceDefine(PVGASTATECC pThisCC, uint32_t sid, SVGA3dSurface1Flags surfaceFlags, SVGA3dSurfaceFormat format, 60 84 uint32_t multisampleCount, SVGA3dTextureFilter autogenFilter, 61 uint32_t numMipLevels, SVGA3dSize const *pMipLevel0Size )85 uint32_t numMipLevels, SVGA3dSize const *pMipLevel0Size, bool fAllocMipLevels) 62 86 { 63 87 PVMSVGA3DSURFACE pSurface; … … 351 375 Assert(!VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface)); 352 376 353 /* Allocate buffer to hold the surface data until we can move it into a D3D object */ 354 for (uint32_t i = 0; i < numMipLevels * pSurface->cFaces; ++i) 355 { 356 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; 357 pMipmapLevel->pSurfaceData = RTMemAllocZ(pMipmapLevel->cbSurface); 358 AssertReturn(pMipmapLevel->pSurfaceData, VERR_NO_MEMORY); 377 if (fAllocMipLevels) 378 { 379 rc = vmsvga3dSurfaceAllocMipLevels(pSurface); 380 AssertRCReturn(rc, rc); 359 381 } 360 382 … … 403 425 if (pSurface->paMipmapLevels) 404 426 { 405 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->cFaces; ++i) 406 RTMemFreeZ(pSurface->paMipmapLevels[i].pSurfaceData, pSurface->paMipmapLevels[i].cbSurface); 427 vmsvga3dSurfaceFreeMipLevels(pSurface); 407 428 RTMemFree(pSurface->paMipmapLevels); 408 429 } … … 552 573 * the copy of the data we've got in VMSVGA3DMIMAPLEVEL::pSurfaceData. 553 574 */ 554 AssertReturn(pMipLevel->pSurfaceData, VERR_INTERNAL_ERROR); 575 if (!pMipLevel->pSurfaceData) 576 { 577 rc = vmsvga3dSurfaceAllocMipLevels(pSurface); 578 AssertRCReturn(rc, rc); 579 } 555 580 } 556 581 else if (vmsvga3dIsLegacyBackend(pThisCC)) … … 1105 1130 if (face == SVGA_ID_INVALID && mipmap == SVGA_ID_INVALID) 1106 1131 { 1132 /* This is a notification that "All images can be lost", i.e. the backend surface is not needed anymore. */ 1133 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1134 if (pSvgaR3State->pFuncs3D) 1135 pSvgaR3State->pFuncs3D->pfnSurfaceDestroy(pThisCC, pSurface); 1136 1107 1137 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->cFaces; ++i) 1108 1138 { … … 1339 1369 } 1340 1370 1371 1372 /* 1373 * 1374 * Map 1375 * 1376 */ 1377 1378 int vmsvga3dSurfaceMap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, 1379 VMSVGA3D_SURFACE_MAP enmMapType, VMSVGA3D_MAPPED_SURFACE *pMap) 1380 { 1381 PVMSVGA3DSURFACE pSurface; 1382 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pImage->sid, &pSurface); 1383 AssertRCReturn(rc, rc); 1384 1385 if (VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface)) 1386 { 1387 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1388 AssertReturn(pSvgaR3State->pFuncsMap, VERR_NOT_IMPLEMENTED); 1389 return pSvgaR3State->pFuncsMap->pfnSurfaceMap(pThisCC, pImage, pBox, enmMapType, pMap); 1390 } 1391 1392 PVMSVGA3DMIPMAPLEVEL pMipLevel; 1393 rc = vmsvga3dMipmapLevel(pSurface, pImage->face, pImage->mipmap, &pMipLevel); 1394 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 1395 1396 if (!pMipLevel->pSurfaceData) 1397 { 1398 rc = vmsvga3dSurfaceAllocMipLevels(pSurface); 1399 AssertRCReturn(rc, rc); 1400 } 1401 1402 SVGA3dBox clipBox; 1403 if (pBox) 1404 { 1405 clipBox = *pBox; 1406 vmsvgaR3ClipBox(&pMipLevel->mipmapSize, &clipBox); 1407 ASSERT_GUEST_RETURN(clipBox.w && clipBox.h && clipBox.d, VERR_INVALID_PARAMETER); 1408 } 1409 else 1410 { 1411 clipBox.x = 0; 1412 clipBox.y = 0; 1413 clipBox.z = 0; 1414 clipBox.w = pMipLevel->mipmapSize.width; 1415 clipBox.h = pMipLevel->mipmapSize.height; 1416 clipBox.d = pMipLevel->mipmapSize.depth; 1417 } 1418 1419 /// @todo Zero the box? 1420 //if (enmMapType == VMSVGA3D_SURFACE_MAP_WRITE_DISCARD) 1421 // RT_BZERO(.); 1422 1423 pMap->enmMapType = enmMapType; 1424 pMap->box = clipBox; 1425 pMap->cbPixel = pSurface->cbBlock; 1426 pMap->cbRowPitch = pMipLevel->cbSurfacePitch; 1427 pMap->cbDepthPitch = pMipLevel->cbSurfacePlane; 1428 pMap->pvData = (uint8_t *)pMipLevel->pSurfaceData 1429 + pMap->box.x * pMap->cbPixel 1430 + pMap->box.y * pMap->cbRowPitch 1431 + pMap->box.z * pMap->cbDepthPitch; 1432 1433 return VINF_SUCCESS; 1434 } 1435 1436 int vmsvga3dSurfaceUnmap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, VMSVGA3D_MAPPED_SURFACE *pMap, bool fWritten) 1437 { 1438 PVMSVGA3DSURFACE pSurface; 1439 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pImage->sid, &pSurface); 1440 AssertRCReturn(rc, rc); 1441 1442 if (VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface)) 1443 { 1444 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State; 1445 AssertReturn(pSvgaR3State->pFuncsMap, VERR_NOT_IMPLEMENTED); 1446 return pSvgaR3State->pFuncsMap->pfnSurfaceUnmap(pThisCC, pImage, pMap, fWritten); 1447 } 1448 1449 PVMSVGA3DMIPMAPLEVEL pMipLevel; 1450 rc = vmsvga3dMipmapLevel(pSurface, pImage->face, pImage->mipmap, &pMipLevel); 1451 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 1452 1453 if ( fWritten 1454 && ( pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE 1455 || pMap->enmMapType == VMSVGA3D_SURFACE_MAP_READ_WRITE 1456 || pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE_DISCARD)) 1457 { 1458 pMipLevel->fDirty = true; 1459 pSurface->fDirty = true; 1460 } 1461 1462 return VINF_SUCCESS; 1463 } 1464 1465 1466 int vmsvga3dCalcSurfaceMipmapAndFace(PVGASTATECC pThisCC, uint32_t sid, uint32_t iSubresource, uint32_t *piMipmap, uint32_t *piFace) 1467 { 1468 PVMSVGA3DSURFACE pSurface; 1469 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, sid, &pSurface); 1470 AssertRCReturn(rc, rc); 1471 1472 vmsvga3dCalcMipmapAndFace(pSurface->cLevels, iSubresource, piMipmap, piFace); 1473 return VINF_SUCCESS; 1474 } 1475 1476 1477 uint32_t vmsvga3dCalcSubresourceOffset(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage) 1478 { 1479 PVMSVGA3DSURFACE pSurface; 1480 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pImage->sid, &pSurface); 1481 AssertRCReturn(rc, 0); 1482 1483 /** @todo Store cbArraySlice in the surface structure. */ 1484 uint32_t cbArraySlice = 0; 1485 for (uint32_t i = 0; i < pSurface->cLevels; ++i) 1486 { 1487 PVMSVGA3DMIPMAPLEVEL pMipLevel = &pSurface->paMipmapLevels[i]; 1488 cbArraySlice += pMipLevel->cbSurface; 1489 } 1490 1491 uint32_t offMipLevel = 0; 1492 for (uint32_t i = 0; i < pImage->mipmap; ++i) 1493 { 1494 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; 1495 offMipLevel += pMipmapLevel->cbSurface; 1496 } 1497 1498 uint32_t offSubresource = cbArraySlice * pImage->face + offMipLevel; 1499 /** @todo Multisample? */ 1500 return offSubresource; 1501 } 1502 1503 1504 /* 1505 * Calculates memory layout of a surface box for memcpy: 1506 */ 1507 int vmsvga3dGetBoxDimensions(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, 1508 VMSGA3D_BOX_DIMENSIONS *pResult) 1509 { 1510 PVMSVGA3DSURFACE pSurface; 1511 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pImage->sid, &pSurface); 1512 AssertRCReturn(rc, rc); 1513 1514 PVMSVGA3DMIPMAPLEVEL pMipLevel; 1515 rc = vmsvga3dMipmapLevel(pSurface, pImage->face, pImage->mipmap, &pMipLevel); 1516 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 1517 1518 /* Clip the box. */ 1519 SVGA3dBox clipBox; 1520 if (pBox) 1521 { 1522 clipBox = *pBox; 1523 vmsvgaR3ClipBox(&pMipLevel->mipmapSize, &clipBox); 1524 ASSERT_GUEST_RETURN(clipBox.w && clipBox.h && clipBox.d, VERR_INVALID_PARAMETER); 1525 } 1526 else 1527 { 1528 clipBox.x = 0; 1529 clipBox.y = 0; 1530 clipBox.z = 0; 1531 clipBox.w = pMipLevel->mipmapSize.width; 1532 clipBox.h = pMipLevel->mipmapSize.height; 1533 clipBox.d = pMipLevel->mipmapSize.depth; 1534 } 1535 1536 /** @todo Calculate offSubresource here, when pSurface will have cbArraySlice field. */ 1537 pResult->offSubresource = vmsvga3dCalcSubresourceOffset(pThisCC, pImage); 1538 pResult->offBox = (clipBox.x / pSurface->cxBlock) * pSurface->cbBlock 1539 + (clipBox.y / pSurface->cyBlock) * pMipLevel->cbSurfacePitch 1540 + clipBox.z * pMipLevel->cbSurfacePlane; 1541 pResult->cbRow = (clipBox.w / pSurface->cxBlock) * pSurface->cbBlock; 1542 pResult->cbPitch = pMipLevel->cbSurfacePitch; 1543 pResult->cyBlocks = clipBox.h / pSurface->cyBlock; 1544 pResult->cDepth = clipBox.d; 1545 1546 return VINF_SUCCESS; 1547 } 1548 1549 1341 1550 /* 1342 1551 * Whether a legacy 3D backend is used. -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r89163 r91361 78 78 int vmsvga3dSurfaceDefine(PVGASTATECC pThisCC, uint32_t sid, SVGA3dSurface1Flags surfaceFlags, SVGA3dSurfaceFormat format, 79 79 uint32_t multisampleCount, SVGA3dTextureFilter autogenFilter, 80 uint32_t cMipLevels, SVGA3dSize const *pMipLevel0Size );80 uint32_t cMipLevels, SVGA3dSize const *pMipLevel0Size, bool fAllocMipLevels); 81 81 int vmsvga3dSurfaceDestroy(PVGASTATECC pThisCC, uint32_t sid); 82 82 int vmsvga3dSurfaceCopy(PVGASTATECC pThisCC, SVGA3dSurfaceImageId dest, SVGA3dSurfaceImageId src, … … 123 123 124 124 int vmsvga3dSurfaceInvalidate(PVGASTATECC pThisCC, uint32_t sid, uint32_t face, uint32_t mipmap); 125 126 int vmsvga3dSurfaceMap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, 127 VMSVGA3D_SURFACE_MAP enmMapType, VMSVGA3D_MAPPED_SURFACE *pMap); 128 int vmsvga3dSurfaceUnmap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, VMSVGA3D_MAPPED_SURFACE *pMap, bool fWritten); 129 130 uint32_t vmsvga3dCalcSubresourceOffset(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage); 131 132 typedef struct VMSGA3D_BOX_DIMENSIONS 133 { 134 uint32_t offSubresource; /* Offset of the miplevel. */ 135 uint32_t offBox; /* Offset of the box in the miplevel. */ 136 uint32_t cbRow; /* Bytes per row. */ 137 int32_t cbPitch; /* Bytes between rows. */ 138 uint32_t cyBlocks; /* Number of rows. */ 139 uint32_t cDepth; /* Number of planes. */ 140 } VMSGA3D_BOX_DIMENSIONS; 141 142 int vmsvga3dGetBoxDimensions(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, 143 VMSGA3D_BOX_DIMENSIONS *pResult); 144 145 DECLINLINE(void) vmsvga3dCalcMipmapSize(SVGA3dSize const *pSize0, uint32_t iMipmap, SVGA3dSize *pSize) 146 { 147 pSize->width = RT_MAX(pSize0->width >> iMipmap, 1); 148 pSize->height = RT_MAX(pSize0->height >> iMipmap, 1); 149 pSize->depth = RT_MAX(pSize0->depth >> iMipmap, 1); 150 } 151 152 DECLINLINE(uint32_t) vmsvga3dCalcSubresource(uint32_t iMipLevel, uint32_t iFace, uint32_t cMipLevels) 153 { 154 /* Same as in D3D */ 155 return iMipLevel + iFace * cMipLevels; 156 } 157 158 DECLINLINE(void) vmsvga3dCalcMipmapAndFace(uint32_t cMipLevels, uint32_t iSubresource, uint32_t *piMipmap, uint32_t *piFace) 159 { 160 *piFace = iSubresource / cMipLevels; 161 *piMipmap = iSubresource % cMipLevels; 162 } 163 164 int vmsvga3dCalcSurfaceMipmapAndFace(PVGASTATECC pThisCC, uint32_t sid, uint32_t iSubresource, uint32_t *piMipmap, uint32_t *piFace); 165 125 166 126 167 /* DevVGA-SVGA3d-shared.h: */ … … 344 385 typedef struct 345 386 { 346 DECLCALLBACKMEMBER(int, pfnSurfaceMap, (PVGASTATECC pThisCC, uint32_t idDXContext,SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, VMSVGA3D_SURFACE_MAP enmMapType, VMSVGA3D_MAPPED_SURFACE *pMap));387 DECLCALLBACKMEMBER(int, pfnSurfaceMap, (PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, VMSVGA3D_SURFACE_MAP enmMapType, VMSVGA3D_MAPPED_SURFACE *pMap)); 347 388 DECLCALLBACKMEMBER(int, pfnSurfaceUnmap, (PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, VMSVGA3D_MAPPED_SURFACE *pMap, bool fWritten)); 348 389 } VMSVGA3DBACKENDFUNCSMAP; … … 364 405 DECLCALLBACKMEMBER(int, pfnDXDraw, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t vertexCount, uint32_t startVertexLocation)); 365 406 DECLCALLBACKMEMBER(int, pfnDXDrawIndexed, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t indexCount, uint32_t startIndexLocation, int32_t baseVertexLocation)); 366 DECLCALLBACKMEMBER(int, pfnDXDrawInstanced, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext ));367 DECLCALLBACKMEMBER(int, pfnDXDrawIndexedInstanced, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext ));407 DECLCALLBACKMEMBER(int, pfnDXDrawInstanced, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t vertexCountPerInstance, uint32_t instanceCount, uint32_t startVertexLocation, uint32_t startInstanceLocation)); 408 DECLCALLBACKMEMBER(int, pfnDXDrawIndexedInstanced, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t indexCountPerInstance, uint32_t instanceCount, uint32_t startIndexLocation, int32_t baseVertexLocation, uint32_t startInstanceLocation)); 368 409 DECLCALLBACKMEMBER(int, pfnDXDrawAuto, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 369 410 DECLCALLBACKMEMBER(int, pfnDXSetInputLayout, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dElementLayoutId elementLayoutId)); … … 392 433 DECLCALLBACKMEMBER(int, pfnDXPresentBlt, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 393 434 DECLCALLBACKMEMBER(int, pfnDXGenMips, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId)); 394 DECLCALLBACKMEMBER(int, pfnDXUpdateSubResource, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));395 DECLCALLBACKMEMBER(int, pfnDXReadbackSubResource, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));396 DECLCALLBACKMEMBER(int, pfnDXInvalidateSubResource, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));397 435 DECLCALLBACKMEMBER(int, pfnDXDefineShaderResourceView, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId, SVGACOTableDXSRViewEntry const *pEntry)); 398 436 DECLCALLBACKMEMBER(int, pfnDXDestroyShaderResourceView, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId)); … … 405 443 DECLCALLBACKMEMBER(int, pfnDXDefineBlendState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dBlendStateId blendId, SVGACOTableDXBlendStateEntry const *pEntry)); 406 444 DECLCALLBACKMEMBER(int, pfnDXDestroyBlendState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 407 DECLCALLBACKMEMBER(int, pfnDXDefineDepthStencilState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilStateId depthStencilId, SVGACOTableDXDepthStencilEntry *pEntry));445 DECLCALLBACKMEMBER(int, pfnDXDefineDepthStencilState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilStateId depthStencilId, SVGACOTableDXDepthStencilEntry const *pEntry)); 408 446 DECLCALLBACKMEMBER(int, pfnDXDestroyDepthStencilState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 409 447 DECLCALLBACKMEMBER(int, pfnDXDefineRasterizerState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRasterizerStateId rasterizerId, SVGACOTableDXRasterizerStateEntry const *pEntry)); … … 411 449 DECLCALLBACKMEMBER(int, pfnDXDefineSamplerState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSamplerId samplerId, SVGACOTableDXSamplerEntry const *pEntry)); 412 450 DECLCALLBACKMEMBER(int, pfnDXDestroySamplerState, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 413 DECLCALLBACKMEMBER(int, pfnDXDefineShader, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSHADER pShader));451 DECLCALLBACKMEMBER(int, pfnDXDefineShader, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId, SVGACOTableDXShaderEntry const *pEntry)); 414 452 DECLCALLBACKMEMBER(int, pfnDXDestroyShader, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 415 453 DECLCALLBACKMEMBER(int, pfnDXBindShader, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSHADER pShader, void const *pvShaderBytecode)); … … 417 455 DECLCALLBACKMEMBER(int, pfnDXDestroyStreamOutput, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 418 456 DECLCALLBACKMEMBER(int, pfnDXSetStreamOutput, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 419 DECLCALLBACKMEMBER(int, pfnDXSetCOTable, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableType type, uint32_t c Entries, uint32_t cValidEntries));457 DECLCALLBACKMEMBER(int, pfnDXSetCOTable, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableType type, uint32_t cValidEntries)); 420 458 DECLCALLBACKMEMBER(int, pfnDXBufferCopy, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 421 DECLCALLBACKMEMBER(int, pfnDXTransferFromBuffer, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));422 459 DECLCALLBACKMEMBER(int, pfnDXSurfaceCopyAndReadback, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 423 460 DECLCALLBACKMEMBER(int, pfnDXMoveQuery, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 424 461 DECLCALLBACKMEMBER(int, pfnDXBindAllQuery, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 425 462 DECLCALLBACKMEMBER(int, pfnDXReadbackAllQuery, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 426 DECLCALLBACKMEMBER(int, pfnDXPredTransferFromBuffer, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));427 463 DECLCALLBACKMEMBER(int, pfnDXMobFence64, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); 428 464 DECLCALLBACKMEMBER(int, pfnDXBindAllShader, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)); … … 490 526 int vmsvga3dDXDestroyContext(PVGASTATECC pThisCC, uint32_t cid); 491 527 int vmsvga3dDXBindContext(PVGASTATECC pThisCC, uint32_t cid, SVGADXContextMobFormat *pSvgaDXContext); 492 int vmsvga3dDXReadbackContext(PVGASTATECC pThisCC, uint32_t idDXContext );528 int vmsvga3dDXReadbackContext(PVGASTATECC pThisCC, uint32_t idDXContext, SVGADXContextMobFormat *pSvgaDXContext); 493 529 int vmsvga3dDXInvalidateContext(PVGASTATECC pThisCC, uint32_t idDXContext); 494 530 int vmsvga3dDXSetSingleConstantBuffer(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetSingleConstantBuffer const *pCmd); … … 498 534 int vmsvga3dDXDraw(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDraw const *pCmd); 499 535 int vmsvga3dDXDrawIndexed(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexed const *pCmd); 500 int vmsvga3dDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext );501 int vmsvga3dDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext );536 int vmsvga3dDXDrawInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstanced const *pCmd); 537 int vmsvga3dDXDrawIndexedInstanced(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstanced const *pCmd); 502 538 int vmsvga3dDXDrawAuto(PVGASTATECC pThisCC, uint32_t idDXContext); 503 539 int vmsvga3dDXSetInputLayout(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dElementLayoutId elementLayoutId); … … 526 562 int vmsvga3dDXPresentBlt(PVGASTATECC pThisCC, uint32_t idDXContext); 527 563 int vmsvga3dDXGenMips(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXGenMips const *pCmd); 528 int vmsvga3dDXUpdateSubResource(PVGASTATECC pThisCC, uint32_t idDXContext);529 int vmsvga3dDXReadbackSubResource(PVGASTATECC pThisCC, uint32_t idDXContext);530 int vmsvga3dDXInvalidateSubResource(PVGASTATECC pThisCC, uint32_t idDXContext);531 564 int vmsvga3dDXDefineShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShaderResourceView const *pCmd); 532 565 int vmsvga3dDXDestroyShaderResourceView(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShaderResourceView const *pCmd); … … 554 587 int vmsvga3dDXReadbackCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXReadbackCOTable const *pCmd); 555 588 int vmsvga3dDXBufferCopy(PVGASTATECC pThisCC, uint32_t idDXContext); 556 int vmsvga3dDXTransferFromBuffer(PVGASTATECC pThisCC, uint32_t idDXContext);557 589 int vmsvga3dDXSurfaceCopyAndReadback(PVGASTATECC pThisCC, uint32_t idDXContext); 558 590 int vmsvga3dDXMoveQuery(PVGASTATECC pThisCC, uint32_t idDXContext); 559 591 int vmsvga3dDXBindAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext); 560 592 int vmsvga3dDXReadbackAllQuery(PVGASTATECC pThisCC, uint32_t idDXContext); 561 int vmsvga3dDXPredTransferFromBuffer(PVGASTATECC pThisCC, uint32_t idDXContext);562 593 int vmsvga3dDXMobFence64(PVGASTATECC pThisCC, uint32_t idDXContext); 563 594 int vmsvga3dDXBindAllShader(PVGASTATECC pThisCC, uint32_t idDXContext); -
trunk/src/VBox/Devices/Makefile.kmk
r91331 r91361 331 331 Graphics/DevVGA-SVGA3d-dx-shader.cpp 332 332 if "$(KBUILD_TARGET)" == "win" 333 VBoxDD_DEFS += VMSVGA3D_DX_BACKEND 333 334 VBoxDD_SOURCES += \ 334 335 Graphics/DevVGA-SVGA3d-win-dx.cpp
Note:
See TracChangeset
for help on using the changeset viewer.