VirtualBox

Changeset 30133 in vbox for trunk


Ignore:
Timestamp:
Jun 9, 2010 6:22:21 PM (15 years ago)
Author:
vboxsync
Message:

wddm/3d: more impl

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp

    r30120 r30133  
    14791479static HRESULT APIENTRY vboxWddmDDevSetStreamSourceUm(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCEUM* pData, CONST VOID* pUMBuffer )
    14801480{
    1481     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    1482     AssertBreakpoint();
    1483     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    1484     return E_FAIL;
     1481    vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     1482    PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
     1483    Assert(pDevice);
     1484    Assert(pDevice->pDevice9If);
     1485    HRESULT hr = S_OK;
     1486//    IDirect3DVertexBuffer9 *pStreamData;
     1487//    UINT cbOffset;
     1488//    UINT cbStride;
     1489//    hr = pDevice->pDevice9If->GetStreamSource(pData->Stream, &pStreamData, &cbOffset, &cbStride);
     1490//    Assert(hr == S_OK);
     1491//    if (hr == S_OK)
     1492//    {
     1493//        if (pStreamData)
     1494//        {
     1495//            AssertBreakpoint();
     1496//            /* @todo: impl! */
     1497//        }
     1498//        else
     1499//        {
     1500            Assert(pData->Stream < RT_ELEMENTS(pDevice->aStreamSourceUm));
     1501            PVBOXWDDMDISP_STREAMSOURCEUM pStrSrcUm = &pDevice->aStreamSourceUm[pData->Stream];
     1502            pStrSrcUm->pvBuffer = pUMBuffer;
     1503            pStrSrcUm->cbStride = pData->Stride;
     1504//        }
     1505//    }
     1506    vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
     1507    return hr;
    14851508}
    14861509
     
    15031526static HRESULT APIENTRY vboxWddmDDevDrawPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWPRIMITIVE* pData, CONST UINT* pFlagBuffer)
    15041527{
    1505     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    1506     AssertBreakpoint();
    1507     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    1508     return E_FAIL;
     1528    vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     1529    PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
     1530    Assert(pDevice);
     1531    Assert(pDevice->pDevice9If);
     1532    Assert(!pFlagBuffer);
     1533    IDirect3DVertexDeclaration9* pDecl;
     1534    HRESULT hr = pDevice->pDevice9If->GetVertexDeclaration(&pDecl);
     1535    Assert(hr == S_OK);
     1536    if (hr == S_OK)
     1537    {
     1538        Assert(pDecl);
     1539        D3DVERTEXELEMENT9 aDecls9[MAXD3DDECLLENGTH];
     1540        UINT cDecls9 = 0;
     1541        hr = pDecl->GetDeclaration(aDecls9, &cDecls9);
     1542        Assert(hr == S_OK);
     1543        if (hr == S_OK)
     1544        {
     1545            Assert(cDecls9);
     1546            for (UINT i = 0; i < cDecls9 - 1 /* the last one is D3DDECL_END */; ++i)
     1547            {
     1548                D3DVERTEXELEMENT9 *pDecl9 = &aDecls9[i];
     1549                Assert(pDecl9->Stream < RT_ELEMENTS(pDevice->aStreamSourceUm) || pDecl9->Stream == 0xff);
     1550                if (pDecl9->Stream != 0xff)
     1551                {
     1552                    PVBOXWDDMDISP_STREAMSOURCEUM pStrSrc = &pDevice->aStreamSourceUm[pDecl9->Stream];
     1553                    if (pStrSrc->pvBuffer)
     1554                    {
     1555                        WORD iStream = pDecl9->Stream;
     1556                        D3DVERTEXELEMENT9 *pLastCDecl9 = pDecl9;
     1557                        for (UINT j = i+1; j < cDecls9 - 1 /* the last one is D3DDECL_END */; ++j)
     1558                        {
     1559                            pDecl9 = &aDecls9[j];
     1560                            if (iStream == pDecl9->Stream)
     1561                            {
     1562                                pDecl9->Stream = 0xff; /* mark as done */
     1563                                Assert(pDecl9->Offset != pLastCDecl9->Offset);
     1564                                if (pDecl9->Offset > pLastCDecl9->Offset)
     1565                                    pLastCDecl9 = pDecl9;
     1566                            }
     1567                        }
     1568                        /* vertex size is MAX(all Offset's) + sizeof (data_type with MAX offset) + stride*/
     1569                        UINT cbVertex = pLastCDecl9->Offset + pStrSrc->cbStride;
     1570                        UINT cbType;
     1571                        switch (pLastCDecl9->Type)
     1572                        {
     1573                            case D3DDECLTYPE_FLOAT1:
     1574                                cbType = sizeof (float);
     1575                                break;
     1576                            case D3DDECLTYPE_FLOAT2:
     1577                                cbType = sizeof (float) * 2;
     1578                                break;
     1579                            case D3DDECLTYPE_FLOAT3:
     1580                                cbType = sizeof (float) * 3;
     1581                                break;
     1582                            case D3DDECLTYPE_FLOAT4:
     1583                                cbType = sizeof (float) * 4;
     1584                                break;
     1585                            case D3DDECLTYPE_D3DCOLOR:
     1586                                cbType = 4;
     1587                                break;
     1588                            case D3DDECLTYPE_UBYTE4:
     1589                                cbType = 4;
     1590                                break;
     1591                            case D3DDECLTYPE_SHORT2:
     1592                                cbType = sizeof (short) * 2;
     1593                                break;
     1594                            case D3DDECLTYPE_SHORT4:
     1595                                cbType = sizeof (short) * 4;
     1596                                break;
     1597                            case D3DDECLTYPE_UBYTE4N:
     1598                                cbType = 4;
     1599                                break;
     1600                            case D3DDECLTYPE_SHORT2N:
     1601                                cbType = sizeof (short) * 2;
     1602                                break;
     1603                            case D3DDECLTYPE_SHORT4N:
     1604                                cbType = sizeof (short) * 4;
     1605                                break;
     1606                            case D3DDECLTYPE_USHORT2N:
     1607                                cbType = sizeof (short) * 2;
     1608                                break;
     1609                            case D3DDECLTYPE_USHORT4N:
     1610                                cbType = sizeof (short) * 4;
     1611                                break;
     1612                            case D3DDECLTYPE_UDEC3:
     1613                                cbType = sizeof (signed) * 3;
     1614                                break;
     1615                            case D3DDECLTYPE_DEC3N:
     1616                                cbType = sizeof (unsigned) * 3;
     1617                                break;
     1618                            case D3DDECLTYPE_FLOAT16_2:
     1619                                cbType = 2 * 2;
     1620                                break;
     1621                            case D3DDECLTYPE_FLOAT16_4:
     1622                                cbType = 2 * 4;
     1623                                break;
     1624                            default:
     1625                                AssertBreakpoint();
     1626                                cbType = 1;
     1627                        }
     1628                        cbVertex += cbType;
     1629
     1630                        UINT cVertexes;
     1631                        switch (pData->PrimitiveType)
     1632                        {
     1633                            case D3DPT_POINTLIST:
     1634                                cVertexes = pData->PrimitiveCount;
     1635                                break;
     1636                            case D3DPT_LINELIST:
     1637                                cVertexes = pData->PrimitiveCount * 2;
     1638                                break;
     1639                            case D3DPT_LINESTRIP:
     1640                                cVertexes = pData->PrimitiveCount + 1;
     1641                                break;
     1642                            case D3DPT_TRIANGLELIST:
     1643                                cVertexes = pData->PrimitiveCount * 3;
     1644                                break;
     1645                            case D3DPT_TRIANGLESTRIP:
     1646                                cVertexes = pData->PrimitiveCount + 2;
     1647                                break;
     1648                            case D3DPT_TRIANGLEFAN:
     1649                                cVertexes = pData->PrimitiveCount + 2;
     1650                                break;
     1651                            default:
     1652                                AssertBreakpoint();
     1653                                cVertexes = pData->PrimitiveCount;
     1654                        }
     1655                        UINT cbVertexes = cVertexes * cbVertex;
     1656                        IDirect3DVertexBuffer9 *pCurVb = NULL, *pVb = NULL;
     1657                        UINT cbOffset;
     1658                        UINT cbStride;
     1659                        hr = pDevice->pDevice9If->GetStreamSource(iStream, &pCurVb, &cbOffset, &cbStride);
     1660                        Assert(hr == S_OK);
     1661                        if (hr == S_OK)
     1662                        {
     1663                            if (pCurVb)
     1664                            {
     1665                                if (cbStride == pStrSrc->cbStride)
     1666                                {
     1667                                    /* ensure our data feets in the buffer */
     1668                                    D3DVERTEXBUFFER_DESC Desc;
     1669                                    hr = pCurVb->GetDesc(&Desc);
     1670                                    Assert(hr == S_OK);
     1671                                    if (hr == S_OK)
     1672                                    {
     1673                                        if (Desc.Size >= cbVertexes)
     1674                                            pVb = pCurVb;
     1675                                    }
     1676                                }
     1677                            }
     1678                        }
     1679                        else
     1680                        {
     1681                            pCurVb = NULL;
     1682                        }
     1683
     1684                        if (!pVb)
     1685                        {
     1686                            hr = pDevice->pDevice9If->CreateVertexBuffer(cbVertexes,
     1687                                    0, /* DWORD Usage */
     1688                                    0, /* DWORD FVF */
     1689                                    D3DPOOL_DEFAULT, /* D3DPOOL Pool */
     1690                                    &pVb,
     1691                                    NULL /*HANDLE* pSharedHandle*/);
     1692                            Assert(hr == S_OK);
     1693                            if (hr == S_OK)
     1694                            {
     1695                                hr = pDevice->pDevice9If->SetStreamSource(iStream, pVb, 0, pStrSrc->cbStride);
     1696                                Assert(hr == S_OK);
     1697                                if (hr == S_OK)
     1698                                {
     1699                                    if (pCurVb)
     1700                                        pCurVb->Release();
     1701                                }
     1702                                else
     1703                                {
     1704                                    pVb->Release();
     1705                                    pVb = NULL;
     1706                                }
     1707                            }
     1708                        }
     1709
     1710                        if (pVb)
     1711                        {
     1712                            Assert(hr == S_OK);
     1713                            VOID *pvData;
     1714                            hr = pVb->Lock(0, /* UINT OffsetToLock */
     1715                                    cbVertexes,
     1716                                    &pvData,
     1717                                    D3DLOCK_DISCARD);
     1718                            Assert(hr == S_OK);
     1719                            if (hr == S_OK)
     1720                            {
     1721                                memcpy (pvData, ((uint8_t*)pStrSrc->pvBuffer) + pData->VStart * cbVertex, cbVertexes);
     1722                                HRESULT tmpHr = pVb->Unlock();
     1723                                Assert(tmpHr == S_OK);
     1724                            }
     1725                        }
     1726                    }
     1727                }
     1728            }
     1729        }
     1730        if (hr == S_OK)
     1731        {
     1732            hr = pDevice->pDevice9If->DrawPrimitive(pData->PrimitiveType,
     1733                    0 /* <- since we use our owne StreamSource buffer which has data at the very beginning*/,
     1734                    pData->PrimitiveCount);
     1735            Assert(hr == S_OK);
     1736        }
     1737    }
     1738    vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
     1739    return hr;
    15091740}
    15101741
     
    25552786static HRESULT APIENTRY vboxWddmDDevPresent(HANDLE hDevice, CONST D3DDDIARG_PRESENT* pData)
    25562787{
    2557     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    2558     AssertBreakpoint();
    2559     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    2560     return E_FAIL;
     2788    vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     2789    PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
     2790    Assert(pDevice);
     2791    Assert(pDevice->pDevice9If);
     2792    HRESULT hr = pDevice->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */
     2793            NULL, /* CONST RECT * pDestRect */
     2794            NULL, /* HWND hDestWindowOverride */
     2795            NULL /*CONST RGNDATA * pDirtyRegion */
     2796            );
     2797    Assert(hr == S_OK);
     2798    vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
     2799    return hr;
    25612800}
    25622801static HRESULT APIENTRY vboxWddmDDevFlush(HANDLE hDevice)
    25632802{
    2564     vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    2565     AssertBreakpoint();
    2566     vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
    2567     return E_FAIL;
     2803    vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
     2804    PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
     2805    Assert(pDevice);
     2806    Assert(pDevice->pDevice9If);
     2807    HRESULT hr = pDevice->pDevice9If->Present(NULL, /* CONST RECT * pSourceRect */
     2808            NULL, /* CONST RECT * pDestRect */
     2809            NULL, /* HWND hDestWindowOverride */
     2810            NULL /*CONST RGNDATA * pDirtyRegion */
     2811            );
     2812    Assert(hr == S_OK);
     2813    vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
     2814    return hr;
    25682815}
    25692816
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h

    r30096 r30133  
    6262} VBOXWDDMDISP_CONTEXT, *PVBOXWDDMDISP_CONTEXT;
    6363
     64typedef struct VBOXWDDMDISP_STREAMSOURCEUM
     65{
     66    CONST VOID* pvBuffer;
     67    UINT cbStride;
     68} VBOXWDDMDISP_STREAMSOURCEUM, *PVBOXWDDMDISP_STREAMSOURCEUM;
     69
    6470typedef struct VBOXWDDMDISP_DEVICE
    6571{
     
    7379    D3DDDI_CREATEDEVICEFLAGS fFlags;
    7480    HWND hWnd;
     81    VBOXWDDMDISP_STREAMSOURCEUM aStreamSourceUm[16];
    7582    IDirect3DDevice9 *pDevice9If;
    7683    /* need to cache the ViewPort data because IDirect3DDevice9::SetViewport
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h

    r30038 r30133  
    3939#endif
    4040
    41 #ifndef DEBUG_misha
     41#if 0
    4242# ifdef Assert
    4343#  undef Assert
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette