- Timestamp:
- Oct 31, 2019 3:44:04 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r81599 r81609 1505 1505 && RT_BOOL(pSurfaceDest->surfaceFlags & SVGA3D_SURFACE_HINT_TEXTURE)) 1506 1506 { 1507 const uint32_t cid = pSurfaceSrc->idAssociatedContext; 1508 1509 PVMSVGA3DCONTEXT pContext; 1510 rc = vmsvga3dContextFromCid(pState, cid, &pContext); 1507 /* Create the destination texture in the same context as the source texture. */ 1508 uint32_t const cidSrc = pSurfaceSrc->idAssociatedContext; 1509 1510 PVMSVGA3DCONTEXT pContextSrc; 1511 rc = vmsvga3dContextFromCid(pState, cidSrc, &pContextSrc); 1511 1512 AssertRCReturn(rc, rc); 1512 1513 1513 LogFunc(("sid=%x type=%x format=%d -> create texture\n", sidDest, pSurfaceDest->surfaceFlags, pSurfaceDest->format));1514 rc = vmsvga3dBackCreateTexture(pState, pContext , cid, pSurfaceDest);1514 LogFunc(("sid=%x type=%x format=%d -> create dest texture\n", sidDest, pSurfaceDest->surfaceFlags, pSurfaceDest->format)); 1515 rc = vmsvga3dBackCreateTexture(pState, pContextSrc, cidSrc, pSurfaceDest); 1515 1516 AssertRCReturn(rc, rc); 1516 1517 } … … 1522 1523 && pSurfaceDest->u.pSurface) 1523 1524 { 1524 /// @todo should use the src context because only the shared hardware surface is required from the dst context, 1525 // while the src context may be also needed to copy data to the source bounce texture. 1526 const uint32_t cidDst = pSurfaceDest->idAssociatedContext; 1527 1528 PVMSVGA3DCONTEXT pContextDst; 1529 rc = vmsvga3dContextFromCid(pState, cidDst, &pContextDst); 1525 /* Both surfaces in hardware. Use the src context to copy one to another, because the src context may be needed 1526 * to copy data from source texture to the source bounce texture. while only the shared hardware surface is required 1527 * from the dst context. 1528 */ 1529 uint32_t const cidSrc = pSurfaceSrc->idAssociatedContext; 1530 1531 PVMSVGA3DCONTEXT pContextSrc; 1532 rc = vmsvga3dContextFromCid(pState, cidSrc, &pContextSrc); 1530 1533 AssertRCReturn(rc, rc); 1531 1534 … … 1535 1538 1536 1539 IDirect3DSurface9 *pSrc; 1537 rc = vmsvga3dGetD3DSurface(pState, pContext Dst, pSurfaceSrc, src.face, src.mipmap, false, &pSrc);1540 rc = vmsvga3dGetD3DSurface(pState, pContextSrc, pSurfaceSrc, src.face, src.mipmap, false, &pSrc); 1538 1541 AssertRCReturn(rc, rc); 1539 1542 1540 1543 IDirect3DSurface9 *pDest; 1541 rc = vmsvga3dGetD3DSurface(pState, pContext Dst, pSurfaceDest, dest.face, dest.mipmap, false, &pDest);1544 rc = vmsvga3dGetD3DSurface(pState, pContextSrc, pSurfaceDest, dest.face, dest.mipmap, false, &pDest); 1542 1545 AssertRCReturnStmt(rc, D3D_RELEASE(pSrc), rc); 1543 1546 1544 1547 for (uint32_t i = 0; i < cCopyBoxes; ++i) 1545 1548 { 1546 HRESULT hr;1547 1548 1549 SVGA3dCopyBox clipBox = pBox[i]; 1549 1550 vmsvgaClipCopyBox(&pMipmapLevelSrc->mipmapSize, &pMipmapLevelDest->mipmapSize, &clipBox); … … 1580 1581 Assert(!clipBox.srcz && !clipBox.z); 1581 1582 1582 hr = pContextDst->pDevice->StretchRect(pSrc, &RectSrc, pDest, &RectDest, D3DTEXF_NONE);1583 HRESULT hr = pContextSrc->pDevice->StretchRect(pSrc, &RectSrc, pDest, &RectDest, D3DTEXF_NONE); 1583 1584 if (hr != D3D_OK) 1584 1585 { 1585 /* This can happen for compressed texture formats . */1586 /* This can happen for compressed texture formats for example. */ 1586 1587 LogFunc(("StretchRect failed with %x. Try a slow path.\n", hr)); 1587 1588 if ( pSurfaceSrc->bounce.pTexture 1588 1589 && (pSurfaceSrc->fUsageD3D & D3DUSAGE_RENDERTARGET)) 1589 1590 { 1590 #if 1 1591 /* Copy the source texture mipmap level to the bounce texture. 1592 * Get the data using the surface associated context. 1593 */ 1594 PVMSVGA3DCONTEXT pContextSrc; 1595 rc = vmsvga3dContextFromCid(pState, pSurfaceSrc->idAssociatedContext, &pContextSrc); 1596 if (RT_SUCCESS(rc)) 1591 /* Copy the source texture mipmap level to the source bounce texture. */ 1592 hr = D3D9GetRenderTargetData(pContextSrc, pSurfaceSrc, src.face, src.mipmap); 1593 AssertMsg(hr == D3D_OK, ("D3D9GetRenderTargetData failed with %x\n", hr)); 1594 if (hr == D3D_OK) 1597 1595 { 1598 hr = D3D9GetRenderTargetData(pContextSrc, pSurfaceSrc, src.face, src.mipmap); 1599 AssertMsg(hr == D3D_OK, ("D3D9GetRenderTargetData failed with %x\n", hr)); 1600 if (hr == D3D_OK) 1601 { 1602 /* Copy the source bounce texture to the destination surface. */ 1603 IDirect3DSurface9 *pBounceSurf; 1604 rc = vmsvga3dGetD3DSurface(pState, pContextDst, pSurfaceSrc, src.face, src.mipmap, true, &pBounceSurf); 1605 if (RT_SUCCESS(rc)) 1606 { 1607 POINT pointDest; 1608 pointDest.x = clipBox.x; 1609 pointDest.y = clipBox.y; 1610 1611 hr = pContextDst->pDevice->UpdateSurface(pBounceSurf, &RectSrc, pDest, &pointDest); 1612 Assert(hr == D3D_OK); 1613 1614 D3D_RELEASE(pBounceSurf); 1615 } 1616 else 1617 { 1618 AssertRC(rc); 1619 hr = E_INVALIDARG; 1620 } 1621 } 1622 } 1623 else 1624 { 1625 AssertRC(rc); 1626 hr = E_INVALIDARG; 1627 } 1628 #else 1629 /* Copy the texture mipmap level to the bounce texture. */ 1630 1631 /* Source is the texture, destination is the corresponding bounce texture. */ 1632 IDirect3DSurface9 *pBounceSurf; 1633 rc = vmsvga3dGetD3DSurface(pState, pContextDst, pSurfaceSrc, src.face, src.mipmap, true, &pBounceSurf); 1634 AssertRC(rc); 1635 if (RT_SUCCESS(rc)) 1636 { 1637 Assert(pSrc != pBounceSurf); 1638 1639 hr = pContextDst->pDevice->GetRenderTargetData(pSrc, pBounceSurf); 1640 Assert(hr == D3D_OK); 1641 if (SUCCEEDED(hr)) 1596 /* Copy the source bounce texture to the destination surface. */ 1597 IDirect3DSurface9 *pSrcBounce; 1598 rc = vmsvga3dGetD3DSurface(pState, pContextSrc, pSurfaceSrc, src.face, src.mipmap, true, &pSrcBounce); 1599 if (RT_SUCCESS(rc)) 1642 1600 { 1643 1601 POINT pointDest; … … 1645 1603 pointDest.y = clipBox.y; 1646 1604 1647 hr = pContext Dst->pDevice->UpdateSurface(pBounceSurf, &RectSrc, pDest, &pointDest);1605 hr = pContextSrc->pDevice->UpdateSurface(pSrcBounce, &RectSrc, pDest, &pointDest); 1648 1606 Assert(hr == D3D_OK); 1607 1608 D3D_RELEASE(pSrcBounce); 1649 1609 } 1650 1651 D3D_RELEASE(pBounceSurf); 1610 else 1611 { 1612 AssertRC(rc); 1613 hr = E_INVALIDARG; 1614 } 1652 1615 } 1653 #endif1654 1616 } 1655 1617 else if ( (pSurfaceSrc->fUsageD3D & D3DUSAGE_RENDERTARGET) == 0 … … 1657 1619 { 1658 1620 /* Can lock both. */ 1659 vmsvga3dSurfaceFlush(pSurfaceSrc);1660 vmsvga3dSurfaceFlush(pSurfaceDest);1661 1662 1621 D3DLOCKED_RECT LockedSrcRect; 1663 1622 hr = pSrc->LockRect(&LockedSrcRect, &RectSrc, D3DLOCK_READONLY); … … 1705 1664 1706 1665 /* Track the StretchRect operation. */ 1707 vmsvga3dSurfaceTrackUsage(pState, pContext Dst, pSurfaceSrc);1708 vmsvga3dSurfaceTrackUsage(pState, pContext Dst, pSurfaceDest);1666 vmsvga3dSurfaceTrackUsage(pState, pContextSrc, pSurfaceSrc); 1667 vmsvga3dSurfaceTrackUsage(pState, pContextSrc, pSurfaceDest); 1709 1668 } 1710 1669 else 1711 1670 { 1712 /* 1713 * Copy from/to memory to/from a surface. Or mem->mem. 1714 * Use the context of existing HW surface, if any. 1671 /* One of the surfaces is in memory. 1672 * 1673 * Copy from/to memory to/from a HW surface. Or mem->mem. 1674 * Use the context of the HW surface, if any. 1715 1675 */ 1716 1676 PVMSVGA3DCONTEXT pContext = NULL; … … 1831 1791 { 1832 1792 hr = pD3DSurf->UnlockRect(); 1833 AssertMsgReturn (hr == D3D_OK, ("Unlock failed with %x\n", hr), VERR_INTERNAL_ERROR);1793 AssertMsgReturnStmt(hr == D3D_OK, ("Unlock failed with %x\n", hr), D3D_RELEASE(pD3DSurf), VERR_INTERNAL_ERROR); 1834 1794 } 1835 1795 } 1836 1796 1837 /* If the destination bounce texture has been used, then update the actual texture. */ 1797 D3D_RELEASE(pD3DSurf); 1798 1799 /* If the destination bounce texture has been used, then update the actual destination texture. */ 1838 1800 if ( pSurfaceDest->u.pTexture 1839 1801 && pSurfaceDest->bounce.pTexture … … 1844 1806 1845 1807 /* Copy the new content to the actual texture object. */ 1846 #if 11847 1808 HRESULT hr2 = D3D9UpdateTexture(pContext, pSurfaceDest); 1848 #else1849 IDirect3DBaseTexture9 *pSourceTexture;1850 IDirect3DBaseTexture9 *pDestinationTexture;1851 if (pSurfaceDest->enmD3DResType == VMSVGA3D_D3DRESTYPE_CUBE_TEXTURE)1852 {1853 pSourceTexture = pSurfaceDest->bounce.pCubeTexture;1854 pDestinationTexture = pSurfaceDest->u.pCubeTexture;1855 }1856 else1857 {1858 pSourceTexture = pSurfaceDest->bounce.pTexture;1859 pDestinationTexture = pSurfaceDest->u.pTexture;1860 }1861 HRESULT hr2 = pContext->pDevice->UpdateTexture(pSourceTexture, pDestinationTexture);1862 #endif1863 1809 AssertMsg(hr2 == D3D_OK, ("UpdateTexture failed with %x\n", hr2)); RT_NOREF(hr2); 1864 1810 … … 1866 1812 vmsvga3dSurfaceTrackUsage(pState, pContext, pSurfaceDest); 1867 1813 } 1868 1869 D3D_RELEASE(pD3DSurf);1870 1814 } 1871 1815 … … 5729 5673 { 5730 5674 float *pValuesF = (float *)pValues; 5731 Log(("ConstantF %d: value=%d, %d, %d, %d\n", reg + i, (int)(pValuesF[i*4 + 0] * 100 .0f), (int)(pValuesF[i*4 + 1] * 100.0f), (int)(pValuesF[i*4 + 2] * 100.0f), (int)(pValuesF[i*4 + 3] * 100.0f)));5675 Log(("ConstantF %d: value=%d, %d, %d, %d\n", reg + i, (int)(pValuesF[i*4 + 0] * 10000.0f), (int)(pValuesF[i*4 + 1] * 10000.0f), (int)(pValuesF[i*4 + 2] * 10000.0f), (int)(pValuesF[i*4 + 3] * 10000.0f))); 5732 5676 break; 5733 5677 }
Note:
See TracChangeset
for help on using the changeset viewer.