VirtualBox

Changeset 49332 in vbox for trunk


Ignore:
Timestamp:
Oct 30, 2013 1:13:02 PM (11 years ago)
Author:
vboxsync
Message:

wddm: 1. switch to using common VBVA code 2.dx-based command submission - work in progress 3.some prototyping for getting 3D data for video recording/take snapshot

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxVideo.h

    r44529 r49332  
    14221422    VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_END,
    14231423    VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_COMPLETION,
     1424    VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRCONNECT,
    14241425    VBOXVDMACMD_CHROMIUM_CTL_TYPE_SIZEHACK = 0xfffffffe
    14251426} VBOXVDMACMD_CHROMIUM_CTL_TYPE;
     
    14421443} VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP, *PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP;
    14431444
     1445
    14441446typedef struct PDMIDISPLAYVBVACALLBACKS *HCRHGSMICMDCOMPLETION;
    14451447typedef DECLCALLBACK(int) FNCRHGSMICMDCOMPLETION(HCRHGSMICMDCOMPLETION hCompletion, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc);
     
    14521454    PFNCRHGSMICMDCOMPLETION pfnCompletion;
    14531455} VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_COMPLETION, *PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_COMPLETION;
     1456
     1457typedef struct VBOXCRCON_SERVER *HVBOXCRCON_SERVER;
     1458typedef struct PDMIDISPLAYVBVACALLBACKS* HVBOXCRCON_CLIENT;
     1459
     1460typedef struct VBOXCRCON_3DRGN_CLIENT* HVBOXCRCON_3DRGN_CLIENT;
     1461typedef struct VBOXCRCON_3DRGN_ASYNCCLIENT* HVBOXCRCON_3DRGN_ASYNCCLIENT;
     1462
     1463/* server callbacks */
     1464/* submit chromium cmd */
     1465typedef DECLCALLBACK(int) FNVBOXCRCON_SVR_CRCMD(HVBOXCRCON_SERVER hServer, PVBOXVDMACMD_CHROMIUM_CMD pCmd, uint32_t cbCmd);
     1466typedef FNVBOXCRCON_SVR_CRCMD *PFNVBOXCRCON_SVR_CRCMD;
     1467
     1468/* submit chromium control cmd */
     1469typedef DECLCALLBACK(int) FNVBOXCRCON_SVR_CRCTL(HVBOXCRCON_SERVER hServer, PVBOXVDMACMD_CHROMIUM_CTL pCtl, uint32_t cbCmd);
     1470typedef FNVBOXCRCON_SVR_CRCTL *PFNVBOXCRCON_SVR_CRCTL;
     1471
     1472/* request 3D data.
     1473 * The protocol is the following:
     1474 * 1. if there is no 3D data displayed on screen, returns VINF_EOF immediately w/o calling any PFNVBOXCRCON_3DRGN_XXX callbacks
     1475 * 2. otherwise calls PFNVBOXCRCON_3DRGN_ONSUBMIT, submits the "regions get" request to the CrOpenGL server to process it asynchronously and returns VINF_SUCCESS
     1476 * 2.a on "regions get" request processing calls PFNVBOXCRCON_3DRGN_BEGIN,
     1477 * 2.b then PFNVBOXCRCON_3DRGN_REPORT zero or more times for each 3D region,
     1478 * 2.c and then PFNVBOXCRCON_3DRGN_END
     1479 * 3. returns VERR_XXX code on failure
     1480 * */
     1481typedef DECLCALLBACK(int) FNVBOXCRCON_SVR_3DRGN_GET(HVBOXCRCON_SERVER hServer, HVBOXCRCON_3DRGN_CLIENT hRgnClient, uint32_t idScreen);
     1482typedef FNVBOXCRCON_SVR_3DRGN_GET *PFNVBOXCRCON_SVR_3DRGN_GET;
     1483
     1484/* 3D Regions Client callbacks */
     1485/* called from the PFNVBOXCRCON_SVR_3DRGN_GET callback in case server has 3D data and is going to process the request asynchronously,
     1486 * see comments for PFNVBOXCRCON_SVR_3DRGN_GET above */
     1487typedef DECLCALLBACK(int) FNVBOXCRCON_3DRGN_ONSUBMIT(HVBOXCRCON_3DRGN_CLIENT hRgnClient, uint32_t idScreen, HVBOXCRCON_3DRGN_ASYNCCLIENT *phRgnAsyncClient);
     1488typedef FNVBOXCRCON_3DRGN_ONSUBMIT *PFNVBOXCRCON_3DRGN_ONSUBMIT;
     1489
     1490/* called from the "regions get" command processing thread, to indicate that the "regions get" is started.
     1491 * see comments for PFNVBOXCRCON_SVR_3DRGN_GET above */
     1492typedef DECLCALLBACK(int) FNVBOXCRCON_3DRGN_BEGIN(HVBOXCRCON_3DRGN_ASYNCCLIENT hRgnAsyncClient, uint32_t idScreen);
     1493typedef FNVBOXCRCON_3DRGN_BEGIN *PFNVBOXCRCON_3DRGN_BEGIN;
     1494
     1495/* called from the "regions get" command processing thread, to report a 3D region.
     1496 * see comments for PFNVBOXCRCON_SVR_3DRGN_GET above */
     1497typedef DECLCALLBACK(int) FNVBOXCRCON_3DRGN_REPORT(HVBOXCRCON_3DRGN_ASYNCCLIENT hRgnAsyncClient, uint32_t idScreen, void *pvData, uint32_t cbStride, const RTRECT *pRect);
     1498typedef FNVBOXCRCON_3DRGN_REPORT *PFNVBOXCRCON_3DRGN_REPORT;
     1499
     1500/* called from the "regions get" command processing thread, to indicate that the "regions get" is completed.
     1501 * see comments for PFNVBOXCRCON_SVR_3DRGN_GET above */
     1502typedef DECLCALLBACK(int) FNVBOXCRCON_3DRGN_END(HVBOXCRCON_3DRGN_ASYNCCLIENT hRgnAsyncClient, uint32_t idScreen);
     1503typedef FNVBOXCRCON_3DRGN_END *PFNVBOXCRCON_3DRGN_END;
     1504
     1505
     1506/* client callbacks */
     1507/* complete chromium cmd */
     1508typedef DECLCALLBACK(int) FNVBOXCRCON_CLT_CRCTL_COMPLETE(HVBOXCRCON_CLIENT hClient, PVBOXVDMACMD_CHROMIUM_CTL pCtl, int rc);
     1509typedef FNVBOXCRCON_CLT_CRCTL_COMPLETE *PFNVBOXCRCON_CLT_CRCTL_COMPLETE;
     1510
     1511/* complete chromium control cmd */
     1512typedef DECLCALLBACK(int) FNVBOXCRCON_CLT_CRCMD_COMPLETE(HVBOXCRCON_CLIENT hClient, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc);
     1513typedef FNVBOXCRCON_CLT_CRCMD_COMPLETE *PFNVBOXCRCON_CLT_CRCMD_COMPLETE;
     1514
     1515typedef struct VBOXCRCON_SERVER_CALLBACKS
     1516{
     1517    HVBOXCRCON_SERVER hServer;
     1518    PFNVBOXCRCON_SVR_CRCMD pfnCrCmd;
     1519    PFNVBOXCRCON_SVR_CRCTL pfnCrCtl;
     1520    PFNVBOXCRCON_SVR_3DRGN_GET pfn3DRgnGet;
     1521} VBOXCRCON_SERVER_CALLBACKS, *PVBOXCRCON_SERVER_CALLBACKS;
     1522
     1523typedef struct VBOXCRCON_CLIENT_CALLBACKS
     1524{
     1525    HVBOXCRCON_CLIENT hClient;
     1526    PFNVBOXCRCON_CLT_CRCMD_COMPLETE pfnCrCmdComplete;
     1527    PFNVBOXCRCON_CLT_CRCTL_COMPLETE pfnCrCtlComplete;
     1528    PFNVBOXCRCON_3DRGN_ONSUBMIT pfn3DRgnOnSubmit;
     1529    PFNVBOXCRCON_3DRGN_BEGIN pfn3DRgnBegin;
     1530    PFNVBOXCRCON_3DRGN_REPORT pfn3DRgnReport;
     1531    PFNVBOXCRCON_3DRGN_END pfn3DRgnEnd;
     1532} VBOXCRCON_CLIENT_CALLBACKS, *PVBOXCRCON_CLIENT_CALLBACKS;
     1533
     1534/* issued by Main to establish connection between Main and CrOpenGL service */
     1535typedef struct VBOXVDMACMD_CHROMIUM_CTL_CRCONNECT
     1536{
     1537    VBOXVDMACMD_CHROMIUM_CTL Hdr;
     1538    /*input (filled by Client) :*/
     1539    /*class VMMDev*/void *pVMMDev;
     1540    VBOXCRCON_CLIENT_CALLBACKS ClientCallbacks;
     1541    /*output (filled by Server) :*/
     1542    VBOXCRCON_SERVER_CALLBACKS ServerCallbacks;
     1543} VBOXVDMACMD_CHROMIUM_CTL_CRCONNECT, *PVBOXVDMACMD_CHROMIUM_CTL_CRCONNECT;
     1544
    14541545# pragma pack()
     1546
    14551547#endif
    14561548
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxUhgsmiBase.cpp

    r43723 r49332  
    3333int vboxUhgsmiBaseBufferTerm(PVBOXUHGSMI_BUFFER_PRIVATE_ESC_BASE pBuffer)
    3434{
    35     PVBOXUHGSMI_PRIVATE_BASE pPrivate = VBOXUHGSMIBASE_GET(pBuffer->PrivateBase.pHgsmi);
     35    PVBOXUHGSMI_PRIVATE_BASE pPrivate = VBOXUHGSMIBASE_GET(pBuffer->BasePrivate.pHgsmi);
    3636    VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE DeallocInfo = {0};
    3737    DeallocInfo.EscapeHdr.escapeCode = VBOXESC_UHGSMI_DEALLOCATE;
     
    9898    pBuffer->Alloc = AllocInfo.Alloc;
    9999    Assert(pBuffer->Alloc.pvData);
    100     pBuffer->PrivateBase.pHgsmi = pPrivate;
    101     pBuffer->PrivateBase.Base.pfnLock = vboxUhgsmiBaseEscBufferLock;
    102     pBuffer->PrivateBase.Base.pfnUnlock = vboxUhgsmiBaseEscBufferUnlock;
    103     pBuffer->PrivateBase.Base.pfnDestroy = pfnDestroy;
    104     pBuffer->PrivateBase.Base.fType = fUhgsmiType;
    105     pBuffer->PrivateBase.Base.cbBuffer = AllocInfo.Alloc.cbData;
     100    pBuffer->BasePrivate.pHgsmi = pPrivate;
     101    pBuffer->BasePrivate.Base.pfnLock = vboxUhgsmiBaseEscBufferLock;
     102    pBuffer->BasePrivate.Base.pfnUnlock = vboxUhgsmiBaseEscBufferUnlock;
     103    pBuffer->BasePrivate.Base.pfnDestroy = pfnDestroy;
     104    pBuffer->BasePrivate.Base.fType = fUhgsmiType;
     105    pBuffer->BasePrivate.Base.cbBuffer = AllocInfo.Alloc.cbData;
    106106    pBuffer->hSynch = hSynch;
    107107    return VINF_SUCCESS;
     
    137137    if (RT_SUCCESS(rc))
    138138    {
    139         *ppBuf = &pBuffer->PrivateBase.Base;
     139        *ppBuf = &pBuffer->BasePrivate.Base;
    140140        return VINF_SUCCESS;
    141141    }
     
    182182        {
    183183            pSubmInfo->Info.offData = 0;
    184             pSubmInfo->Info.cbData = pBuf->PrivateBase.Base.cbBuffer;
     184            pSubmInfo->Info.cbData = pBuf->BasePrivate.Base.cbBuffer;
    185185        }
    186186        else
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxUhgsmiBase.h

    r44529 r49332  
    6868typedef struct VBOXUHGSMI_BUFFER_PRIVATE_ESC_BASE
    6969{
    70     VBOXUHGSMI_BUFFER_PRIVATE_BASE PrivateBase;
     70    VBOXUHGSMI_BUFFER_PRIVATE_BASE BasePrivate;
    7171    VBOXVIDEOCM_UM_ALLOC Alloc;
    7272    HANDLE hSynch;
     
    7575typedef struct VBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE
    7676{
    77     VBOXUHGSMI_BUFFER_PRIVATE_BASE PrivateBase;
     77    VBOXUHGSMI_BUFFER_PRIVATE_BASE BasePrivate;
    7878    D3DKMT_HANDLE hAllocation;
    7979    UINT aLockPageIndices[1];
     
    8484#define VBOXUHGSMIBASE_GET_BUFFER(_p) VBOXUHGSMIBASE_GET_PRIVATE(_p, VBOXUHGSMI_BUFFER_PRIVATE_BASE)
    8585
    86 #define VBOXUHGSMIPRIVATEBASE_GET_PRIVATE(_p, _t) ((_t*)(((uint8_t*)_p) - RT_OFFSETOF(_t, PrivateBase.Base)))
     86#define VBOXUHGSMIPRIVATEBASE_GET_PRIVATE(_p, _t) ((_t*)(((uint8_t*)_p) - RT_OFFSETOF(_t, BasePrivate.Base)))
    8787#define VBOXUHGSMIESCBASE_GET_BUFFER(_p) VBOXUHGSMIPRIVATEBASE_GET_PRIVATE(_p, VBOXUHGSMI_BUFFER_PRIVATE_ESC_BASE)
    8888#define VBOXUHGSMDXALLOCBASE_GET_BUFFER(_p) VBOXUHGSMIPRIVATEBASE_GET_PRIVATE(_p, VBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE)
    8989
    90 DECLINLINE(int) vboxUhgsmiBaseLockData(PVBOXUHGSMI_BUFFER pBuf, uint32_t offLock, uint32_t cbLock, VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags,
    91                                     D3DDDICB_LOCKFLAGS *pfFlags, UINT *pNumPages, UINT* pPages)
    92 {
     90DECLINLINE(int) vboxUhgsmiBaseDxLockData(PVBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE pPrivate, uint32_t offLock, uint32_t cbLock, VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags,
     91                                    D3DDDICB_LOCKFLAGS *pfFlags, UINT *pNumPages)
     92{
     93    PVBOXUHGSMI_BUFFER pBuf = &pPrivate->BasePrivate.Base;
    9394    D3DDDICB_LOCKFLAGS fLockFlags;
    9495    fLockFlags.Value = 0;
     
    127128            for (UINT i = 0, j = iFirstPage; i < cPages; ++i, ++j)
    128129            {
    129                 pPages[i] = j;
     130                pPrivate->aLockPageIndices[i] = j;
    130131            }
    131132        }
     
    141142}
    142143
    143 #if 0
    144 DECLINLINE(int) vboxUhgsmiBaseDmaFill(PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers,
     144DECLINLINE(int) vboxUhgsmiBaseDxDmaFill(PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers,
    145145        VOID* pCommandBuffer, UINT *pCommandBufferSize,
    146146        D3DDDI_ALLOCATIONLIST *pAllocationList, UINT AllocationListSize,
     
    170170    {
    171171        PVBOXUHGSMI_BUFFER_SUBMIT pBufInfo = &aBuffers[i];
    172         PVBOXUHGSMI_BUFFER_PRIVATE_BASE pBuffer = VBOXUHGSMIBASE_GET_BUFFER(pBufInfo->pBuf);
     172        PVBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE pBuffer = VBOXUHGSMDXALLOCBASE_GET_BUFFER(pBufInfo->pBuf);
    173173
    174174        memset(pAllocationList, 0, sizeof (D3DDDI_ALLOCATIONLIST));
     
    181181        {
    182182            pBufSubmInfo->offData = 0;
    183             pBufSubmInfo->cbData = pBuffer->Base.cbBuffer;
     183            pBufSubmInfo->cbData = pBuffer->BasePrivate.Base.cbBuffer;
    184184        }
    185185        else
     
    195195    return VINF_SUCCESS;
    196196}
    197 #endif
    198197
    199198DECLCALLBACK(int) vboxUhgsmiBaseEscBufferLock(PVBOXUHGSMI_BUFFER pBuf, uint32_t offLock, uint32_t cbLock, VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags, void**pvLock);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxUhgsmiDisp.cpp

    r44529 r49332  
    2222#define VBOXUHGSMID3D_GET(_p) VBOXUHGSMID3D_GET_PRIVATE(_p, VBOXUHGSMI_PRIVATE_D3D)
    2323
    24 #if 0
    25 #define VBOXUHGSMID3D_GET_BUFFER(_p) VBOXUHGSMID3D_GET_PRIVATE(_p, VBOXUHGSMI_BUFFER_PRIVATE_D3D)
    26 
    2724#include <iprt/mem.h>
    2825#include <iprt/err.h>
    2926
    30 typedef struct VBOXUHGSMI_BUFFER_PRIVATE_D3D
    31 {
    32     VBOXUHGSMI_BUFFER_PRIVATE_BASE BasePrivate;
    33     PVBOXWDDMDISP_DEVICE pDevice;
    34     UINT aLockPageIndices[1];
    35 } VBOXUHGSMI_BUFFER_PRIVATE_D3D, *PVBOXUHGSMI_BUFFER_PRIVATE_D3D;
    36 
    37 
    38 
    3927DECLCALLBACK(int) vboxUhgsmiD3DBufferDestroy(PVBOXUHGSMI_BUFFER pBuf)
    4028{
    41     PVBOXUHGSMI_BUFFER_PRIVATE_D3D pBuffer = VBOXUHGSMID3D_GET_BUFFER(pBuf);
     29    PVBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE pBuffer = VBOXUHGSMDXALLOCBASE_GET_BUFFER(pBuf);
     30    struct VBOXWDDMDISP_DEVICE *pDevice = VBOXUHGSMID3D_GET(pBuffer->BasePrivate.pHgsmi)->pDevice;
    4231    D3DDDICB_DEALLOCATE DdiDealloc;
    4332    DdiDealloc.hResource = 0;
    4433    DdiDealloc.NumAllocations = 1;
    45     DdiDealloc.HandleList = &pBuffer->BasePrivate.hAllocation;
    46     HRESULT hr = pBuffer->pDevice->RtCallbacks.pfnDeallocateCb(pBuffer->pDevice->hDevice, &DdiDealloc);
    47     Assert(hr == S_OK);
    48     if (hr == S_OK)
    49     {
    50         if (pBuffer->BasePrivate.hSynch)
    51             CloseHandle(pBuffer->BasePrivate.hSynch);
     34    DdiDealloc.HandleList = &pBuffer->hAllocation;
     35    HRESULT hr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &DdiDealloc);
     36    if (hr == S_OK)
     37    {
    5238        RTMemFree(pBuffer);
    5339        return VINF_SUCCESS;
    5440    }
    55     return VERR_GENERAL_FAILURE;
    56 }
    57 
     41
     42    WARN(("pfnDeallocateCb failed, hr %#x", hr));
     43    return VERR_GENERAL_FAILURE;
     44}
     45
     46/* typedef DECLCALLBACK(int) FNVBOXUHGSMI_BUFFER_LOCK(PVBOXUHGSMI_BUFFER pBuf, uint32_t offLock, uint32_t cbLock, VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags, void**pvLock); */
    5847DECLCALLBACK(int) vboxUhgsmiD3DBufferLock(PVBOXUHGSMI_BUFFER pBuf, uint32_t offLock, uint32_t cbLock, VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags, void**pvLock)
    5948{
    60     PVBOXUHGSMI_BUFFER_PRIVATE_D3D pBuffer = VBOXUHGSMID3D_GET_BUFFER(pBuf);
     49    PVBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE pBuffer = VBOXUHGSMDXALLOCBASE_GET_BUFFER(pBuf);
     50    struct VBOXWDDMDISP_DEVICE *pDevice = VBOXUHGSMID3D_GET(pBuffer->BasePrivate.pHgsmi)->pDevice;
    6151    D3DDDICB_LOCK DdiLock = {0};
    62     DdiLock.hAllocation = pBuffer->BasePrivate.hAllocation;
     52    DdiLock.hAllocation = pBuffer->hAllocation;
    6353    DdiLock.PrivateDriverData = 0;
    6454
    65     int rc = vboxUhgsmiBaseLockData(pBuf, offLock, cbLock, fFlags,
    66                                          &DdiLock.Flags, &DdiLock.NumPages, pBuffer->aLockPageIndices);
    67     AssertRC(rc);
    68     if (RT_FAILURE(rc))
     55    int rc = vboxUhgsmiBaseDxLockData(pBuffer, offLock, cbLock, fFlags,
     56                                         &DdiLock.Flags, &DdiLock.NumPages);
     57    if (!RT_SUCCESS(rc))
     58    {
     59        WARN(("vboxUhgsmiBaseDxLockData failed rc %d", rc));
    6960        return rc;
     61    }
    7062
    7163    if (DdiLock.NumPages)
     
    7466        DdiLock.pPages = NULL;
    7567
    76     HRESULT hr = pBuffer->pDevice->RtCallbacks.pfnLockCb(pBuffer->pDevice->hDevice, &DdiLock);
    77     Assert(hr == S_OK);
     68    HRESULT hr = pDevice->RtCallbacks.pfnLockCb(pDevice->hDevice, &DdiLock);
    7869    if (hr == S_OK)
    7970    {
     
    8172        return VINF_SUCCESS;
    8273    }
     74
     75    WARN(("pfnLockCb failed, hr %#x", hr));
    8376    return VERR_GENERAL_FAILURE;
    8477}
     
    8679DECLCALLBACK(int) vboxUhgsmiD3DBufferUnlock(PVBOXUHGSMI_BUFFER pBuf)
    8780{
    88     PVBOXUHGSMI_BUFFER_PRIVATE_D3D pBuffer = VBOXUHGSMID3D_GET_BUFFER(pBuf);
     81    PVBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE pBuffer = VBOXUHGSMDXALLOCBASE_GET_BUFFER(pBuf);
     82    struct VBOXWDDMDISP_DEVICE *pDevice = VBOXUHGSMID3D_GET(pBuffer->BasePrivate.pHgsmi)->pDevice;
    8983    D3DDDICB_UNLOCK DdiUnlock;
    9084    DdiUnlock.NumAllocations = 1;
    91     DdiUnlock.phAllocations = &pBuffer->BasePrivate.hAllocation;
    92     HRESULT hr = pBuffer->pDevice->RtCallbacks.pfnUnlockCb(pBuffer->pDevice->hDevice, &DdiUnlock);
    93     Assert(hr == S_OK);
    94     if (hr == S_OK)
    95         return VINF_SUCCESS;
    96     return VERR_GENERAL_FAILURE;
    97 }
    98 
    99 DECLCALLBACK(int) vboxUhgsmiD3DBufferCreate(PVBOXUHGSMI pHgsmi, uint32_t cbBuf, VBOXUHGSMI_BUFFER_TYPE_FLAGS fUhgsmiType, PVBOXUHGSMI_BUFFER* ppBuf)
    100 {
    101     HANDLE hSynch = NULL;
     85    DdiUnlock.phAllocations = &pBuffer->hAllocation;
     86    HRESULT hr = pDevice->RtCallbacks.pfnUnlockCb(pDevice->hDevice, &DdiUnlock);
     87    if (hr == S_OK)
     88        return VINF_SUCCESS;
     89
     90    WARN(("pfnUnlockCb failed, hr %#x", hr));
     91    return VERR_GENERAL_FAILURE;
     92}
     93
     94/*typedef DECLCALLBACK(int) FNVBOXUHGSMI_BUFFER_CREATE(PVBOXUHGSMI pHgsmi, uint32_t cbBuf, VBOXUHGSMI_BUFFER_TYPE_FLAGS fType, PVBOXUHGSMI_BUFFER* ppBuf);*/
     95DECLCALLBACK(int) vboxUhgsmiD3DBufferCreate(PVBOXUHGSMI pHgsmi, uint32_t cbBuf, VBOXUHGSMI_BUFFER_TYPE_FLAGS fType, PVBOXUHGSMI_BUFFER* ppBuf)
     96{
    10297    if (!cbBuf)
    10398        return VERR_INVALID_PARAMETER;
    10499
    105     int rc = vboxUhgsmiBaseEventChkCreate(fUhgsmiType, &hSynch);
    106     AssertRC(rc);
    107     if (RT_FAILURE(rc))
    108         return rc;
     100    int rc = VINF_SUCCESS;
    109101
    110102    cbBuf = VBOXWDDM_ROUNDBOUND(cbBuf, 0x1000);
     
    114106
    115107    PVBOXUHGSMI_PRIVATE_D3D pPrivate = VBOXUHGSMID3D_GET(pHgsmi);
    116     PVBOXUHGSMI_BUFFER_PRIVATE_D3D pBuf = (PVBOXUHGSMI_BUFFER_PRIVATE_D3D)RTMemAllocZ(RT_OFFSETOF(VBOXUHGSMI_BUFFER_PRIVATE_D3D, aLockPageIndices[cPages]));
    117     Assert(pBuf);
     108    PVBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE pBuf = (PVBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE)RTMemAllocZ(RT_OFFSETOF(VBOXUHGSMI_BUFFER_PRIVATE_DX_ALLOC_BASE, aLockPageIndices[cPages]));
    118109    if (pBuf)
    119110    {
    120         struct
    121         {
    122             D3DDDICB_ALLOCATE DdiAlloc;
    123             D3DDDI_ALLOCATIONINFO DdiAllocInfo;
    124             VBOXWDDM_ALLOCINFO AllocInfo;
    125         } Buf;
    126         memset(&Buf, 0, sizeof (Buf));
    127         Buf.DdiAlloc.hResource = NULL;
    128         Buf.DdiAlloc.hKMResource = NULL;
    129         Buf.DdiAlloc.NumAllocations = 1;
    130         Buf.DdiAlloc.pAllocationInfo = &Buf.DdiAllocInfo;
    131         Buf.DdiAllocInfo.pPrivateDriverData = &Buf.AllocInfo;
    132         Buf.DdiAllocInfo.PrivateDriverDataSize = sizeof (Buf.AllocInfo);
    133         Buf.AllocInfo.enmType = VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER;
    134         Buf.AllocInfo.cbBuffer = cbBuf;
    135         Buf.AllocInfo.hSynch = hSynch;
    136         Buf.AllocInfo.fUhgsmiType = fUhgsmiType;
    137 
    138         HRESULT hr = pPrivate->pDevice->RtCallbacks.pfnAllocateCb(pPrivate->pDevice->hDevice, &Buf.DdiAlloc);
    139         Assert(hr == S_OK);
     111        D3DDDICB_ALLOCATE DdiAlloc;
     112        D3DDDI_ALLOCATIONINFO DdiAllocInfo;
     113        VBOXWDDM_ALLOCINFO AllocInfo;
     114
     115        memset(&DdiAlloc, 0, sizeof (DdiAlloc));
     116        DdiAlloc.hResource = NULL;
     117        DdiAlloc.hKMResource = NULL;
     118        DdiAlloc.NumAllocations = 1;
     119        DdiAlloc.pAllocationInfo = &DdiAllocInfo;
     120        DdiAllocInfo.pPrivateDriverData = &AllocInfo;
     121        DdiAllocInfo.PrivateDriverDataSize = sizeof (AllocInfo);
     122        AllocInfo.enmType = VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER;
     123        AllocInfo.cbBuffer = cbBuf;
     124        AllocInfo.hSynch = 0;
     125        AllocInfo.fUhgsmiType = fType;
     126
     127        HRESULT hr = pPrivate->pDevice->RtCallbacks.pfnAllocateCb(pPrivate->pDevice->hDevice, &DdiAlloc);
    140128        if (hr == S_OK)
    141129        {
    142             Assert(Buf.DdiAllocInfo.hAllocation);
     130            Assert(DdiAllocInfo.hAllocation);
    143131            pBuf->BasePrivate.Base.pfnLock = vboxUhgsmiD3DBufferLock;
    144132            pBuf->BasePrivate.Base.pfnUnlock = vboxUhgsmiD3DBufferUnlock;
    145 //            pBuf->Base.pfnAdjustValidDataRange = vboxUhgsmiD3DBufferAdjustValidDataRange;
    146133            pBuf->BasePrivate.Base.pfnDestroy = vboxUhgsmiD3DBufferDestroy;
    147134
    148             pBuf->BasePrivate.Base.fType = fUhgsmiType;
     135            pBuf->BasePrivate.Base.fType = fType;
    149136            pBuf->BasePrivate.Base.cbBuffer = cbBuf;
    150137
    151             pBuf->pDevice = pPrivate->pDevice;
    152             pBuf->BasePrivate.hAllocation = Buf.DdiAllocInfo.hAllocation;
     138            pBuf->hAllocation = DdiAllocInfo.hAllocation;
    153139
    154140            *ppBuf = &pBuf->BasePrivate.Base;
     
    156142            return VINF_SUCCESS;
    157143        }
     144        else
     145        {
     146            WARN(("pfnAllocateCb failed hr %#x"));
     147            rc = VERR_GENERAL_FAILURE;
     148        }
    158149
    159150        RTMemFree(pBuf);
    160151    }
    161152    else
     153    {
     154        WARN(("RTMemAllocZ failed"));
    162155        rc = VERR_NO_MEMORY;
    163 
    164     if (hSynch)
    165         CloseHandle(hSynch);
     156    }
    166157
    167158    return rc;
    168159}
    169160
     161/* typedef DECLCALLBACK(int) FNVBOXUHGSMI_BUFFER_SUBMIT(PVBOXUHGSMI pHgsmi, PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers); */
    170162DECLCALLBACK(int) vboxUhgsmiD3DBufferSubmit(PVBOXUHGSMI pHgsmi, PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers)
    171163{
     
    173165    PVBOXWDDMDISP_DEVICE pDevice = pHg->pDevice;
    174166    UINT cbDmaCmd = pDevice->DefaultContext.ContextInfo.CommandBufferSize;
    175     int rc = vboxUhgsmiBaseDmaFill(aBuffers, cBuffers,
     167    int rc = vboxUhgsmiBaseDxDmaFill(aBuffers, cBuffers,
    176168            pDevice->DefaultContext.ContextInfo.pCommandBuffer, &cbDmaCmd,
    177169            pDevice->DefaultContext.ContextInfo.pAllocationList, pDevice->DefaultContext.ContextInfo.AllocationListSize,
    178170            pDevice->DefaultContext.ContextInfo.pPatchLocationList, pDevice->DefaultContext.ContextInfo.PatchLocationListSize);
    179     AssertRC(rc);
    180171    if (RT_FAILURE(rc))
     172    {
     173        WARN(("vboxUhgsmiBaseDxDmaFill failed, rc %d", rc));
    181174        return rc;
     175    }
    182176
    183177    D3DDDICB_RENDER DdiRender = {0};
     
    194188
    195189    HRESULT hr = pDevice->RtCallbacks.pfnRenderCb(pDevice->hDevice, &DdiRender);
    196     Assert(hr == S_OK);
    197190    if (hr == S_OK)
    198191    {
     
    207200    }
    208201
    209     return VERR_GENERAL_FAILURE;
    210 }
    211 
    212 HRESULT vboxUhgsmiD3DInit(PVBOXUHGSMI_PRIVATE_D3D pHgsmi, PVBOXWDDMDISP_DEVICE pDevice)
     202    WARN(("pfnRenderCb failed, hr %#x", hr));
     203    return VERR_GENERAL_FAILURE;
     204}
     205
     206void vboxUhgsmiD3DInit(PVBOXUHGSMI_PRIVATE_D3D pHgsmi, PVBOXWDDMDISP_DEVICE pDevice)
    213207{
    214208    pHgsmi->BasePrivate.Base.pfnBufferCreate = vboxUhgsmiD3DBufferCreate;
    215209    pHgsmi->BasePrivate.Base.pfnBufferSubmit = vboxUhgsmiD3DBufferSubmit;
     210    /* no escapes (for now) */
     211    pHgsmi->BasePrivate.pfnEscape = NULL;
    216212    pHgsmi->pDevice = pDevice;
    217     return S_OK;
    218 }
    219 #endif
     213}
    220214
    221215static DECLCALLBACK(int) vboxCrHhgsmiDispEscape(struct VBOXUHGSMI_PRIVATE_BASE *pHgsmi, void *pvData, uint32_t cbData, BOOL fHwAccess)
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxUhgsmiDisp.h

    r44529 r49332  
    2929} VBOXUHGSMI_PRIVATE_D3D, *PVBOXUHGSMI_PRIVATE_D3D;
    3030
    31 #if 0
    3231void vboxUhgsmiD3DInit(PVBOXUHGSMI_PRIVATE_D3D pHgsmi, struct VBOXWDDMDISP_DEVICE *pDevice);
    33 #endif
    3432
    3533void vboxUhgsmiD3DEscInit(PVBOXUHGSMI_PRIVATE_D3D pHgsmi, struct VBOXWDDMDISP_DEVICE *pDevice);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxUhgsmiKmt.cpp

    r44529 r49332  
    7171    EnterCriticalSection(&pBuffer->CritSect);
    7272
    73     int rc = vboxUhgsmiBaseLockData(pBuf, offLock, cbLock, fFlags,
    74                                          &DdiLock.Flags, &DdiLock.NumPages, pBuffer->aLockPageIndices);
     73    int rc = vboxUhgsmiBaseDxLockData(&pBuffer->BasePrivate, offLock, cbLock, fFlags,
     74                                         &DdiLock.Flags, &DdiLock.NumPages);
    7575    AssertRC(rc);
    7676    if (RT_FAILURE(rc))
     
    194194    PVBOXUHGSMI_PRIVATE_KMT pHg = VBOXUHGSMIKMT_GET(pHgsmi);
    195195    UINT cbDmaCmd = pHg->Context.CommandBufferSize;
    196     int rc = vboxUhgsmiBaseDmaFill(aBuffers, cBuffers,
     196    int rc = vboxUhgsmiBaseDxDmaFill(aBuffers, cBuffers,
    197197            pHg->Context.pCommandBuffer, &cbDmaCmd,
    198198            pHg->Context.pAllocationList, pHg->Context.AllocationListSize,
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/Makefile.kmk

    r48944 r49332  
    118118        common/VBoxMPVidModes.cpp \
    119119        $(PATH_ROOT)/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp \
     120        $(PATH_ROOT)/src/VBox/Additions/common/VBoxVideo/VBVABase.cpp \
    120121        $(PATH_ROOT)/src/VBox/Additions/common/VBoxVideo/Modesetting.cpp \
    121122        $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/util/vreg.cpp
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h

    r48070 r49332  
    208208#ifdef VBOXWDDM_RENDER_FROM_SHADOW
    209209    /* all memory layout info should be initialized */
    210     Assert(pDevExt->aSources[0].Vbva.offVBVA);
     210    Assert(pDevExt->aSources[0].Vbva.Vbva.offVRAMBuffer);
    211211    /* page aligned */
    212     Assert(!(pDevExt->aSources[0].Vbva.offVBVA & 0xfff));
    213 
    214     return (ULONG)(pDevExt->aSources[0].Vbva.offVBVA & ~0xfffULL);
     212    Assert(!(pDevExt->aSources[0].Vbva.Vbva.offVRAMBuffer & 0xfff));
     213
     214    return (ULONG)(pDevExt->aSources[0].Vbva.Vbva.offVRAMBuffer & ~0xfffULL);
    215215#else
    216216    /* all memory layout info should be initialized */
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVbva.cpp

    r44529 r49332  
    2020#include "common/VBoxMPCommon.h"
    2121
    22 static int vboxVBVAInformHost (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO * pVbva, BOOL bEnable)
    23 {
    24     int rc = VERR_NO_MEMORY;
    25     void *p = VBoxHGSMIBufferAlloc (&VBoxCommonFromDeviceExt(pDevExt)->guestCtx,
    26                                   sizeof (VBVAENABLE_EX),
    27                                   HGSMI_CH_VBVA,
    28                                   VBVA_ENABLE);
    29     Assert(p);
    30     if (!p)
    31     {
    32         LOGREL(("HGSMIHeapAlloc failed"));
    33         rc = VERR_NO_MEMORY;
    34     }
    35     else
    36     {
    37         VBVAENABLE_EX *pEnableEx = (VBVAENABLE_EX *)p;
    38         pEnableEx->u32ScreenId = pVbva->srcId;
    39 
    40         VBVAENABLE *pEnable = &pEnableEx->Base;
    41         pEnable->u32Flags  = bEnable? VBVA_F_ENABLE: VBVA_F_DISABLE;
    42         pEnable->u32Flags |= VBVA_F_EXTENDED | VBVA_F_ABSOFFSET;
    43         pEnable->u32Offset = (uint32_t)pVbva->offVBVA;
    44         pEnable->i32Result = VERR_NOT_SUPPORTED;
    45 
    46         VBoxHGSMIBufferSubmit (&VBoxCommonFromDeviceExt(pDevExt)->guestCtx, p);
    47 
    48         if (bEnable)
    49         {
    50             rc = pEnable->i32Result;
    51             AssertRC(rc);
    52         }
    53         else
    54             rc = VINF_SUCCESS;
    55 
    56         VBoxHGSMIBufferFree (&VBoxCommonFromDeviceExt(pDevExt)->guestCtx, p);
    57     }
    58     return rc;
    59 }
    60 
    6122/*
    6223 * Public hardware buffer methods.
     
    6425int vboxVbvaEnable (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
    6526{
    66         VBVABUFFER *pVBVA = pVbva->pVBVA;
     27    if (VBoxVBVAEnable(&pVbva->Vbva, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx,
     28            pVbva->Vbva.pVBVA, pVbva->srcId))
     29        return VINF_SUCCESS;
    6730
    68 //        DISPDBG((1, "VBoxDisp::vboxVbvaEnable screen %p vbva off 0x%x\n", ppdev->pjScreen, ppdev->layout.offVBVABuffer));
    69 
    70         pVBVA->hostFlags.u32HostEvents      = 0;
    71         pVBVA->hostFlags.u32SupportedOrders = 0;
    72         pVBVA->off32Data          = 0;
    73         pVBVA->off32Free          = 0;
    74         RtlZeroMemory (pVBVA->aRecords, sizeof (pVBVA->aRecords));
    75         pVBVA->indexRecordFirst   = 0;
    76         pVBVA->indexRecordFree    = 0;
    77         pVBVA->cbPartialWriteThreshold = 256;
    78         pVBVA->cbData             = pVbva->cbVBVA - sizeof (VBVABUFFER) + sizeof (pVBVA->au8Data);
    79 
    80         pVbva->fHwBufferOverflow = FALSE;
    81         pVbva->pRecord           = NULL;
    82 
    83         int rc = vboxVBVAInformHost (pDevExt, pVbva, TRUE);
    84         AssertRC(rc);
    85 
    86     if (!RT_SUCCESS(rc))
    87         vboxVbvaDisable (pDevExt, pVbva);
    88 
    89     return rc;
     31    WARN(("VBoxVBVAEnable failed!"));
     32    return VERR_GENERAL_FAILURE;
    9033}
    9134
    9235int vboxVbvaDisable (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
    9336{
    94 //    DISPDBG((1, "VBoxDisp::vbvaDisable called.\n"));
    95 
    96     pVbva->fHwBufferOverflow = FALSE;
    97     pVbva->pRecord           = NULL;
    98 //    ppdev->pVBVA             = NULL;
    99 
    100     return vboxVBVAInformHost (pDevExt, pVbva, FALSE);
     37    VBoxVBVADisable(&pVbva->Vbva, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx, pVbva->srcId);
     38    return VINF_SUCCESS;
    10139}
    10240
     
    10846
    10947    int rc = VBoxMPCmnMapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt),
    110                                        (void**)&pVbva->pVBVA,
     48                                       (void**)&pVbva->Vbva.pVBVA,
    11149                                       offBuffer,
    11250                                       cbBuffer);
     
    11452    if (RT_SUCCESS(rc))
    11553    {
    116         Assert(pVbva->pVBVA);
    117         pVbva->offVBVA = offBuffer;
    118         pVbva->cbVBVA = cbBuffer;
     54        Assert(pVbva->Vbva.pVBVA);
     55        VBoxVBVASetupBufferContext(&pVbva->Vbva, offBuffer, cbBuffer);
    11956        pVbva->srcId = srcId;
    12057    }
     
    12663{
    12764    int rc = VINF_SUCCESS;
    128     VBoxMPCmnUnmapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), (void**)&pVbva->pVBVA);
    129     memset(pVbva, 0, sizeof(VBOXVBVAINFO));
     65    VBoxMPCmnUnmapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), (void**)&pVbva->Vbva.pVBVA);
     66    memset(pVbva, 0, sizeof (VBOXVBVAINFO));
    13067    return rc;
    13168}
    13269
    133 /*
    134  * Private operations.
    135  */
    136 static uint32_t vboxHwBufferAvail (const VBVABUFFER *pVBVA)
    137 {
    138     int32_t i32Diff = pVBVA->off32Data - pVBVA->off32Free;
    139 
    140     return i32Diff > 0? i32Diff: pVBVA->cbData + i32Diff;
    141 }
    142 
    143 static void vboxHwBufferFlush (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
    144 {
    145     /* Issue the flush command. */
    146     void *p = VBoxHGSMIBufferAlloc (&VBoxCommonFromDeviceExt(pDevExt)->guestCtx,
    147                               sizeof (VBVAFLUSH),
    148                               HGSMI_CH_VBVA,
    149                               VBVA_FLUSH);
    150     Assert(p);
    151     if (!p)
    152     {
    153         LOGREL(("HGSMIHeapAlloc failed"));
    154     }
    155     else
    156     {
    157         VBVAFLUSH *pFlush = (VBVAFLUSH *)p;
    158 
    159         pFlush->u32Reserved = 0;
    160 
    161         VBoxHGSMIBufferSubmit (&VBoxCommonFromDeviceExt(pDevExt)->guestCtx, p);
    162 
    163         VBoxHGSMIBufferFree (&VBoxCommonFromDeviceExt(pDevExt)->guestCtx, p);
    164     }
    165 
    166     return;
    167 }
    168 
    169 static void vboxHwBufferPlaceDataAt (VBVABUFFER *pVBVA, const void *p, uint32_t cb, uint32_t offset)
    170 {
    171     uint32_t u32BytesTillBoundary = pVBVA->cbData - offset;
    172     uint8_t  *dst                 = &pVBVA->au8Data[offset];
    173     int32_t i32Diff               = cb - u32BytesTillBoundary;
    174 
    175     if (i32Diff <= 0)
    176     {
    177         /* Chunk will not cross buffer boundary. */
    178         memcpy (dst, p, cb);
    179     }
    180     else
    181     {
    182         /* Chunk crosses buffer boundary. */
    183         memcpy (dst, p, u32BytesTillBoundary);
    184         memcpy (&pVBVA->au8Data[0], (uint8_t *)p + u32BytesTillBoundary, i32Diff);
    185     }
    186 
    187     return;
    188 }
    189 
    190 BOOL vboxVbvaBufferBeginUpdate (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
    191 {
    192     BOOL bRc = FALSE;
    193 
    194     // DISPDBG((1, "VBoxDisp::vboxHwBufferBeginUpdate called flags = 0x%08X\n",
    195     //          ppdev->pVBVA? ppdev->pVBVA->u32HostEvents: -1));
    196 
    197     if (   pVbva->pVBVA
    198         && (pVbva->pVBVA->hostFlags.u32HostEvents & VBVA_F_MODE_ENABLED))
    199     {
    200         uint32_t indexRecordNext;
    201 
    202         Assert (!pVbva->fHwBufferOverflow);
    203         Assert (pVbva->pRecord == NULL);
    204 
    205         indexRecordNext = (pVbva->pVBVA->indexRecordFree + 1) % VBVA_MAX_RECORDS;
    206 
    207         if (indexRecordNext == pVbva->pVBVA->indexRecordFirst)
    208         {
    209             /* All slots in the records queue are used. */
    210             vboxHwBufferFlush (pDevExt, pVbva);
    211         }
    212 
    213         if (indexRecordNext == pVbva->pVBVA->indexRecordFirst)
    214         {
    215 //            /* Even after flush there is no place. Fail the request. */
    216 //            LOG(("no space in the queue of records!!! first %d, last %d",
    217 //                  ppdev->pVBVA->indexRecordFirst, ppdev->pVBVA->indexRecordFree));
    218         }
    219         else
    220         {
    221             /* Initialize the record. */
    222             VBVARECORD *pRecord = &pVbva->pVBVA->aRecords[pVbva->pVBVA->indexRecordFree];
    223 
    224             pRecord->cbRecord = VBVA_F_RECORD_PARTIAL;
    225 
    226             pVbva->pVBVA->indexRecordFree = indexRecordNext;
    227 
    228             // LOG(("indexRecordNext = %d\n", indexRecordNext));
    229 
    230             /* Remember which record we are using. */
    231             pVbva->pRecord = pRecord;
    232 
    233             bRc = TRUE;
    234         }
    235     }
    236 
    237     return bRc;
    238 }
    239 
    240 void vboxVbvaBufferEndUpdate (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
    241 {
    242     VBVARECORD *pRecord;
    243 
    244     // LOG(("VBoxDisp::vboxHwBufferEndUpdate called"));
    245 
    246     Assert(pVbva->pVBVA);
    247 
    248     pRecord = pVbva->pRecord;
    249     Assert (pRecord && (pRecord->cbRecord & VBVA_F_RECORD_PARTIAL));
    250 
    251     /* Mark the record completed. */
    252     pRecord->cbRecord &= ~VBVA_F_RECORD_PARTIAL;
    253 
    254     pVbva->fHwBufferOverflow = FALSE;
    255     pVbva->pRecord = NULL;
    256 
    257     return;
    258 }
    259 
    260 static int vboxHwBufferWrite (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva, const void *p, uint32_t cb)
    261 {
    262     VBVARECORD *pRecord;
    263     uint32_t cbHwBufferAvail;
    264 
    265     uint32_t cbWritten = 0;
    266 
    267     VBVABUFFER *pVBVA = pVbva->pVBVA;
    268     Assert(pVBVA);
    269 
    270     if (!pVBVA || pVbva->fHwBufferOverflow)
    271     {
    272         return VERR_INVALID_STATE;
    273     }
    274 
    275     Assert (pVBVA->indexRecordFirst != pVBVA->indexRecordFree);
    276 
    277     pRecord = pVbva->pRecord;
    278     Assert (pRecord && (pRecord->cbRecord & VBVA_F_RECORD_PARTIAL));
    279 
    280 //    LOGF(("VW %d", cb));
    281 
    282     cbHwBufferAvail = vboxHwBufferAvail (pVBVA);
    283 
    284     while (cb > 0)
    285     {
    286         uint32_t cbChunk = cb;
    287 
    288         // LOG(("pVBVA->off32Free %d, pRecord->cbRecord 0x%08X, cbHwBufferAvail %d, cb %d, cbWritten %d\n",
    289         //      pVBVA->off32Free, pRecord->cbRecord, cbHwBufferAvail, cb, cbWritten));
    290 
    291         if (cbChunk >= cbHwBufferAvail)
    292         {
    293             LOG(("1) avail %d, chunk %d", cbHwBufferAvail, cbChunk));
    294 
    295             vboxHwBufferFlush (pDevExt, pVbva);
    296 
    297             cbHwBufferAvail = vboxHwBufferAvail (pVBVA);
    298 
    299             if (cbChunk >= cbHwBufferAvail)
    300             {
    301                 LOG(("no place for %d bytes. Only %d bytes available after flush. Going to partial writes.",
    302                      cb, cbHwBufferAvail));
    303 
    304                 if (cbHwBufferAvail <= pVBVA->cbPartialWriteThreshold)
    305                 {
    306                     LOGREL(("Buffer overflow!!!"));
    307                     pVbva->fHwBufferOverflow = TRUE;
    308                     Assert(FALSE);
    309                     return VERR_NO_MEMORY;
    310                 }
    311 
    312                 cbChunk = cbHwBufferAvail - pVBVA->cbPartialWriteThreshold;
    313             }
    314         }
    315 
    316         Assert(cbChunk <= cb);
    317         Assert(cbChunk <= vboxHwBufferAvail (pVBVA));
    318 
    319         vboxHwBufferPlaceDataAt (pVbva->pVBVA, (uint8_t *)p + cbWritten, cbChunk, pVBVA->off32Free);
    320 
    321         pVBVA->off32Free   = (pVBVA->off32Free + cbChunk) % pVBVA->cbData;
    322         pRecord->cbRecord += cbChunk;
    323         cbHwBufferAvail -= cbChunk;
    324 
    325         cb        -= cbChunk;
    326         cbWritten += cbChunk;
    327     }
    328 
    329     return VINF_SUCCESS;
    330 }
    331 
    332 /*
    333  * Public writer to the hardware buffer.
    334  */
    335 int vboxWrite (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva, const void *pv, uint32_t cb)
    336 {
    337     return vboxHwBufferWrite (pDevExt, pVbva, pv, cb);
    338 }
    339 
    340 
    34170int vboxVbvaReportDirtyRect (PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SOURCE pSrc, RECT *pRectOrig)
    34271{
    343         VBVACMDHDR hdr;
     72    VBVACMDHDR hdr;
    34473
    345         RECT rect = *pRectOrig;
     74    RECT rect = *pRectOrig;
    34675
    34776//        if (rect.left < 0) rect.left = 0;
     
    35079//        if (rect.bottom > (int)ppdev->cyScreen) rect.bottom = ppdev->cyScreen;
    35180
    352         hdr.x = (int16_t)rect.left;
    353         hdr.y = (int16_t)rect.top;
    354         hdr.w = (uint16_t)(rect.right - rect.left);
    355         hdr.h = (uint16_t)(rect.bottom - rect.top);
     81    hdr.x = (int16_t)rect.left;
     82    hdr.y = (int16_t)rect.top;
     83    hdr.w = (uint16_t)(rect.right - rect.left);
     84    hdr.h = (uint16_t)(rect.bottom - rect.top);
    35685
    357         hdr.x += (int16_t)pSrc->VScreenPos.x;
    358         hdr.y += (int16_t)pSrc->VScreenPos.y;
     86    hdr.x += (int16_t)pSrc->VScreenPos.x;
     87    hdr.y += (int16_t)pSrc->VScreenPos.y;
    35988
    360         return vboxWrite (pDevExt, &pSrc->Vbva, &hdr, sizeof(hdr));
     89    if (VBoxVBVAWrite(&pSrc->Vbva.Vbva, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx, &hdr, sizeof(hdr)))
     90        return VINF_SUCCESS;
     91
     92    WARN(("VBoxVBVAWrite failed"));
     93    return VERR_GENERAL_FAILURE;
    36194}
    36295
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVbva.h

    r37626 r49332  
    2222typedef struct VBOXVBVAINFO
    2323{
    24     VBOXVIDEOOFFSET offVBVA;
    25     uint32_t cbVBVA;
    26     VBVABUFFER *pVBVA;
    27     BOOL  fHwBufferOverflow;
    28     VBVARECORD *pRecord;
     24    VBVABUFFERCONTEXT Vbva;
    2925    D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId;
    3026    KSPIN_LOCK Lock;
     
    3733int vboxVbvaReportCmdOffset(PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva, uint32_t offCmd);
    3834int vboxVbvaReportDirtyRect(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_SOURCE *pSrc, RECT *pRectOrig);
    39 BOOL vboxVbvaBufferBeginUpdate(PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva);
    40 void vboxVbvaBufferEndUpdate(PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva);
    4135
    4236#define VBOXVBVA_OP(_op, _pdext, _psrc, _arg) \
    4337        do { \
    44             if (vboxVbvaBufferBeginUpdate(_pdext, &(_psrc)->Vbva)) \
     38            if (VBoxVBVABufferBeginUpdate(&(_psrc)->Vbva.Vbva, &VBoxCommonFromDeviceExt(_pdext)->guestCtx)) \
    4539            { \
    4640                vboxVbva##_op(_pdext, _psrc, _arg); \
    47                 vboxVbvaBufferEndUpdate(_pdext, &(_psrc)->Vbva); \
     41                VBoxVBVABufferEndUpdate(&(_psrc)->Vbva.Vbva); \
    4842            } \
    4943        } while (0)
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