VirtualBox

Changeset 80876 in vbox for trunk


Ignore:
Timestamp:
Sep 18, 2019 6:09:19 AM (5 years ago)
Author:
vboxsync
Message:

Additions/WINNT/Graphics,include: remove obsolete Chromium code. bugref:9529

Location:
trunk
Files:
9 edited

Legend:

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

    r80872 r80876  
    14071407} VBOXVDMA_CTL;
    14081408
    1409 typedef struct VBOXVDMA_RECTL
    1410 {
    1411     int16_t left;
    1412     int16_t top;
    1413     uint16_t width;
    1414     uint16_t height;
    1415 } VBOXVDMA_RECTL, *PVBOXVDMA_RECTL;
    1416 
    1417 typedef enum
    1418 {
    1419     VBOXVDMA_PIXEL_FORMAT_UNKNOWN      =  0,
    1420     VBOXVDMA_PIXEL_FORMAT_R8G8B8       = 20,
    1421     VBOXVDMA_PIXEL_FORMAT_A8R8G8B8     = 21,
    1422     VBOXVDMA_PIXEL_FORMAT_X8R8G8B8     = 22,
    1423     VBOXVDMA_PIXEL_FORMAT_R5G6B5       = 23,
    1424     VBOXVDMA_PIXEL_FORMAT_X1R5G5B5     = 24,
    1425     VBOXVDMA_PIXEL_FORMAT_A1R5G5B5     = 25,
    1426     VBOXVDMA_PIXEL_FORMAT_A4R4G4B4     = 26,
    1427     VBOXVDMA_PIXEL_FORMAT_R3G3B2       = 27,
    1428     VBOXVDMA_PIXEL_FORMAT_A8           = 28,
    1429     VBOXVDMA_PIXEL_FORMAT_A8R3G3B2     = 29,
    1430     VBOXVDMA_PIXEL_FORMAT_X4R4G4B4     = 30,
    1431     VBOXVDMA_PIXEL_FORMAT_A2B10G10R10  = 31,
    1432     VBOXVDMA_PIXEL_FORMAT_A8B8G8R8     = 32,
    1433     VBOXVDMA_PIXEL_FORMAT_X8B8G8R8     = 33,
    1434     VBOXVDMA_PIXEL_FORMAT_G16R16       = 34,
    1435     VBOXVDMA_PIXEL_FORMAT_A2R10G10B10  = 35,
    1436     VBOXVDMA_PIXEL_FORMAT_A16B16G16R16 = 36,
    1437     VBOXVDMA_PIXEL_FORMAT_A8P8         = 40,
    1438     VBOXVDMA_PIXEL_FORMAT_P8           = 41,
    1439     VBOXVDMA_PIXEL_FORMAT_L8           = 50,
    1440     VBOXVDMA_PIXEL_FORMAT_A8L8         = 51,
    1441     VBOXVDMA_PIXEL_FORMAT_A4L4         = 52,
    1442     VBOXVDMA_PIXEL_FORMAT_V8U8         = 60,
    1443     VBOXVDMA_PIXEL_FORMAT_L6V5U5       = 61,
    1444     VBOXVDMA_PIXEL_FORMAT_X8L8V8U8     = 62,
    1445     VBOXVDMA_PIXEL_FORMAT_Q8W8V8U8     = 63,
    1446     VBOXVDMA_PIXEL_FORMAT_V16U16       = 64,
    1447     VBOXVDMA_PIXEL_FORMAT_W11V11U10    = 65,
    1448     VBOXVDMA_PIXEL_FORMAT_A2W10V10U10  = 67
    1449 } VBOXVDMA_PIXEL_FORMAT;
    1450 
    1451 typedef struct VBOXVDMA_SURF_DESC
    1452 {
    1453     uint32_t width;
    1454     uint32_t height;
    1455     VBOXVDMA_PIXEL_FORMAT format;
    1456     uint32_t bpp;
    1457     uint32_t pitch;
    1458     uint32_t fFlags;
    1459 } VBOXVDMA_SURF_DESC, *PVBOXVDMA_SURF_DESC;
    1460 
    1461 /*typedef uint64_t VBOXVDMAPHADDRESS;*/
    1462 typedef uint64_t VBOXVDMASURFHANDLE;
    1463 
    1464 /* region specified as a rectangle, otherwize it is a size of memory pointed to by phys address */
    1465 #define VBOXVDMAOPERAND_FLAGS_RECTL       0x1
    1466 /* Surface handle is valid */
    1467 #define VBOXVDMAOPERAND_FLAGS_PRIMARY        0x2
    1468 /* address is offset in VRAM */
    1469 #define VBOXVDMAOPERAND_FLAGS_VRAMOFFSET  0x4
    1470 
    1471 
    14721409/* VBOXVDMACBUF_DR::phBuf specifies offset in VRAM */
    14731410#define VBOXVDMACBUF_FLAG_BUF_VRAM_OFFSET 0x00000001
     
    15211458#define VBOXVDMACMD_BODY_FIELD_OFFSET(_ot, _t, _f)  ( (_ot)(uintptr_t)( VBOXVDMACMD_BODY(0, uint8_t) + RT_UOFFSETOF_DYN(_t, _f) ) )
    15221459
    1523 typedef struct VBOXVDMACMD_DMA_PRESENT_BLT
    1524 {
    1525     VBOXVIDEOOFFSET offSrc;
    1526     VBOXVIDEOOFFSET offDst;
    1527     VBOXVDMA_SURF_DESC srcDesc;
    1528     VBOXVDMA_SURF_DESC dstDesc;
    1529     VBOXVDMA_RECTL srcRectl;
    1530     VBOXVDMA_RECTL dstRectl;
    1531     uint32_t u32Reserved;
    1532     uint32_t cDstSubRects;
    1533     VBOXVDMA_RECTL aDstSubRects[1];
    1534 } VBOXVDMACMD_DMA_PRESENT_BLT, *PVBOXVDMACMD_DMA_PRESENT_BLT;
    1535 
    1536 typedef struct VBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY
    1537 {
    1538     VBOXVDMA_RECTL Rect;
    1539 } VBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY, *PVBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY;
    1540 
    1541 
    1542 #define VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET 0x00000001
    1543 #define VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET 0x00000002
    1544 
    1545 typedef struct VBOXVDMACMD_DMA_BPB_TRANSFER
    1546 {
    1547     uint32_t cbTransferSize;
    1548     uint32_t fFlags;
    1549     union
    1550     {
    1551         uint64_t phBuf;
    1552         VBOXVIDEOOFFSET offVramBuf;
    1553     } Src;
    1554     union
    1555     {
    1556         uint64_t phBuf;
    1557         VBOXVIDEOOFFSET offVramBuf;
    1558     } Dst;
    1559 } VBOXVDMACMD_DMA_BPB_TRANSFER, *PVBOXVDMACMD_DMA_BPB_TRANSFER;
    1560 
    1561 #define VBOXVDMACMD_SYSMEMEL_F_PAGELIST 0x00000001
    1562 
    1563 typedef struct VBOXVDMACMD_SYSMEMEL
    1564 {
    1565     uint32_t cPages;
    1566     uint32_t fFlags;
    1567     uint64_t phBuf[1];
    1568 } VBOXVDMACMD_SYSMEMEL, *PVBOXVDMACMD_SYSMEMEL;
    1569 
    1570 #define VBOXVDMACMD_SYSMEMEL_NEXT(_pEl) ( ((_pEl)->fFlags & VBOXVDMACMD_SYSMEMEL_F_PAGELIST) \
    1571         ? ((PVBOXVDMACMD_SYSMEMEL)(((uint8_t*)(_pEl)) + RT_UOFFSETOF_DYN(VBOXVDMACMD_SYSMEMEL, phBuf[(_pEl)->cPages]))) \
    1572         : ((_pEl) + 1) )
    1573 
    1574 #define VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM 0x00000001
    1575 
    1576 typedef struct VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS
    1577 {
    1578     uint32_t cTransferPages;
    1579     uint32_t fFlags;
    1580     VBOXVIDEOOFFSET offVramBuf;
    1581     VBOXVDMACMD_SYSMEMEL FirstEl;
    1582 } VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS, *PVBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS;
    1583 
    1584 typedef struct VBOXVDMACMD_DMA_BPB_FILL
    1585 {
    1586     VBOXVIDEOOFFSET offSurf;
    1587     uint32_t cbFillSize;
    1588     uint32_t u32FillPattern;
    1589 } VBOXVDMACMD_DMA_BPB_FILL, *PVBOXVDMACMD_DMA_BPB_FILL;
     1460# pragma pack()
     1461#endif /* #ifdef VBOX_WITH_VDMA */
     1462
    15901463
    15911464#define VBOXVDMA_CHILD_STATUS_F_CONNECTED    0x01
     
    16111484} VBOXVDMACMD_CHILD_STATUS_IRQ, *PVBOXVDMACMD_CHILD_STATUS_IRQ;
    16121485
    1613 # pragma pack()
    1614 #endif /* #ifdef VBOX_WITH_VDMA */
    1615 
    16161486#define VBOXCMDVBVA_SCREENMAP_SIZE(_elType) ((VBOX_VIDEO_MAX_SCREENS + sizeof (_elType) - 1) / sizeof (_elType))
    16171487#define VBOXCMDVBVA_SCREENMAP_DECL(_elType, _name) _elType _name[VBOXCMDVBVA_SCREENMAP_SIZE(_elType)]
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/shared/Makefile.kmk

    r80372 r80876  
    2626VBoxDispMpLogger_TEMPLATE    = VBoxGuestR3Lib
    2727VBoxDispMpLogger_SDKS        = ReorderCompilerIncs $(VBOX_WINDDK_GST_WLH)
    28 VBoxDispMpLogger_DEFS        = UNICODE _UNICODE VBOX_WITH_WDDM VBOX_WITH_VDMA VBOX_WITH_HGCM
     28VBoxDispMpLogger_DEFS        = UNICODE _UNICODE VBOX_WITH_WDDM VBOX_WITH_HGCM
    2929VBoxDispMpLogger_INCS        = \
    3030        $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/shared \
     
    4949VBoxWddmUmKmt_TEMPLATE    = VBoxGuestR3Lib
    5050VBoxWddmUmKmt_SDKS        = ReorderCompilerIncs $(VBOX_WINDDK_GST_WLH)
    51 VBoxWddmUmKmt_DEFS        = UNICODE _UNICODE VBOX_WITH_WDDM VBOX_WITH_VDMA VBOX_WITH_HGCM
     51VBoxWddmUmKmt_DEFS        = UNICODE _UNICODE VBOX_WITH_WDDM VBOX_WITH_HGCM
    5252VBoxWddmUmKmt_INCS        = \
    5353        $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/shared \
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/Makefile.kmk

    r80487 r80876  
    8989  endif
    9090 endif
    91  ifdef VBOX_WITH_VDMA
    92   VBoxWddm_DEFS           += VBOX_WITH_VDMA
    93  endif
    9491 VBoxWddm_DEFS            += LOG_TO_BACKDOOR
    9592 VBoxWddm_DEFS            += VBOX_SVN_REV=$(VBOX_SVN_REV)
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h

    r80488 r80876  
    132132   /* hgsmi allocation manager */
    133133   VBOXVIDEOCM_ALLOC_MGR AllocMgr;
    134    VBOXVDMADDI_NODE aNodes[VBOXWDDM_NUM_NODES];
    135    LIST_ENTRY DpcCmdQueue;
    136134   /* mutex for context list operations */
    137135   KSPIN_LOCK ContextLock;
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h

    r80488 r80876  
    5252#define VBOXWDDM_C_POINTER_MAX_WIDTH  64
    5353#define VBOXWDDM_C_POINTER_MAX_HEIGHT 64
    54 
    55 #ifdef VBOX_WITH_VDMA
    56 #define VBOXWDDM_C_VDMA_BUFFER_SIZE   (64*_1K)
    57 #endif
    58 
    59 #ifndef VBOXWDDM_RENDER_FROM_SHADOW
    60 # ifndef VBOX_WITH_VDMA
    61 #  error "VBOX_WITH_VDMA must be defined!!!"
    62 # endif
    63 #endif
    6454
    6555#define VBOXWDDM_POINTER_ATTRIBUTES_SIZE VBOXWDDM_ROUNDBOUND( \
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVModes.cpp

    r76553 r80876  
    547547}
    548548
    549 #ifdef VBOX_WDDM_MONITOR_REPLUG_IRQ
    550 typedef struct VBOXWDDMCHILDSTATUSCB
    551 {
    552     PVBOXVDMACBUF_DR pDr;
    553     PKEVENT pEvent;
    554 } VBOXWDDMCHILDSTATUSCB, *PVBOXWDDMCHILDSTATUSCB;
    555 
    556 static DECLCALLBACK(VOID) vboxWddmChildStatusReportCompletion(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext)
    557 {
    558     /* we should be called from our DPC routine */
    559     Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
    560 
    561     PVBOXWDDMCHILDSTATUSCB pCtx = (PVBOXWDDMCHILDSTATUSCB)pvContext;
    562     PVBOXVDMACBUF_DR pDr = pCtx->pDr;
    563     VBOXVDMACMD                  RT_UNTRUSTED_VOLATILE_HOST *pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
    564     VBOXVDMACMD_CHILD_STATUS_IRQ RT_UNTRUSTED_VOLATILE_HOST *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHILD_STATUS_IRQ);
    565 
    566     vboxWddmChildStatusHandleRequest(pDevExt, pBody);
    567 
    568     vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
    569 
    570     if (pCtx->pEvent)
    571     {
    572         KeSetEvent(pCtx->pEvent, 0, FALSE);
    573     }
    574 }
    575 #endif
    576 
    577549NTSTATUS VBoxWddmChildStatusReportReconnected(PVBOXMP_DEVEXT pDevExt, uint32_t iChild)
    578550{
    579 #ifdef VBOX_WDDM_MONITOR_REPLUG_IRQ
    580     NTSTATUS Status = STATUS_UNSUCCESSFUL;
    581     UINT cbCmd = VBOXVDMACMD_SIZE_FROMBODYSIZE(sizeof (VBOXVDMACMD_CHILD_STATUS_IRQ));
    582 
    583     PVBOXVDMACBUF_DR pDr = vboxVdmaCBufDrCreate(&pDevExt->u.primary.Vdma, cbCmd);
    584     if (pDr)
    585     {
    586         // vboxVdmaCBufDrCreate zero initializes the pDr
    587         /* the command data follows the descriptor */
    588         pDr->fFlags = VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR;
    589         pDr->cbBuf = cbCmd;
    590         pDr->rc = VERR_NOT_IMPLEMENTED;
    591 
    592         VBOXVDMACMD RT_UNTRUSTED_VOLATILE_HOST *pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
    593         pHdr->enmType = VBOXVDMACMD_TYPE_CHILD_STATUS_IRQ;
    594         pHdr->u32CmdSpecific = 0;
    595 
    596         VBOXVDMACMD_CHILD_STATUS_IRQ RT_UNTRUSTED_VOLATILE_HOST *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHILD_STATUS_IRQ);
    597         pBody->cInfos = 1;
    598         if (iChild == D3DDDI_ID_ALL)
    599         {
    600             pBody->fFlags |= VBOXVDMACMD_CHILD_STATUS_IRQ_F_APPLY_TO_ALL;
    601         }
    602         pBody->aInfos[0].iChild = iChild;
    603         pBody->aInfos[0].fFlags = VBOXVDMA_CHILD_STATUS_F_DISCONNECTED | VBOXVDMA_CHILD_STATUS_F_CONNECTED;
    604         /* we're going to KeWaitForSingleObject */
    605         Assert(KeGetCurrentIrql() < DISPATCH_LEVEL);
    606 
    607         PVBOXVDMADDI_CMD pDdiCmd = VBOXVDMADDI_CMD_FROM_BUF_DR(pDr);
    608         VBOXWDDMCHILDSTATUSCB Ctx;
    609         KEVENT Event;
    610         KeInitializeEvent(&Event, NotificationEvent, FALSE);
    611         Ctx.pDr = pDr;
    612         Ctx.pEvent = &Event;
    613         vboxVdmaDdiCmdInit(pDdiCmd, 0, 0, vboxWddmChildStatusReportCompletion, &Ctx);
    614         /* mark command as submitted & invisible for the dx runtime since dx did not originate it */
    615         vboxVdmaDdiCmdSubmittedNotDx(pDdiCmd);
    616         int rc = vboxVdmaCBufDrSubmit(pDevExt, &pDevExt->u.primary.Vdma, pDr);
    617         Assert(rc == VINF_SUCCESS);
    618         if (RT_SUCCESS(rc))
    619         {
    620             Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
    621             AssertNtStatusSuccess(Status);
    622             return STATUS_SUCCESS;
    623         }
    624 
    625         Status = STATUS_UNSUCCESSFUL;
    626 
    627         vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
    628     }
    629     else
    630     {
    631         /** @todo try flushing.. */
    632         WARN(("vboxVdmaCBufDrCreate returned NULL"));
    633         Status = STATUS_INSUFFICIENT_RESOURCES;
    634     }
    635 
    636     return Status;
    637 #else
    638551    VBOXVDMACMD_CHILD_STATUS_IRQ Body = {0};
    639552    Body.cInfos = 1;
     
    646559    Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
    647560    return vboxWddmChildStatusHandleRequest(pDevExt, &Body);
    648 #endif
    649561}
    650562
    651563NTSTATUS VBoxWddmChildStatusConnect(PVBOXMP_DEVEXT pDevExt, uint32_t iChild, BOOLEAN fConnect)
    652564{
    653 #ifdef VBOX_WDDM_MONITOR_REPLUG_IRQ
    654 # error "port me!"
    655 #else
    656565    Assert(iChild < (uint32_t)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
    657566    NTSTATUS Status = STATUS_SUCCESS;
     
    666575
    667576    return Status;
    668 #endif
    669 }
     577}
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp

    r80748 r80876  
    119119
    120120
    121 #ifdef VBOX_WITH_VDMA
    122 /*
    123  * This is currently used by VDMA. It is invisible for Vdma API clients since
    124  * Vdma transport may change if we choose to use another (e.g. more light-weight)
    125  * transport for DMA commands submission
    126  */
    127 
    128 static int vboxWddmVdmaSubmitHgsmi(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, HGSMIOFFSET offDr)
    129 {
    130     RT_NOREF(pInfo);
    131     VBVO_PORT_WRITE_U32(VBoxCommonFromDeviceExt(pDevExt)->guestCtx.port, offDr);
    132     /* Make the compiler aware that the host has changed memory. */
    133     ASMCompilerBarrier();
    134     return VINF_SUCCESS;
    135 }
    136 #define vboxWddmVdmaSubmit vboxWddmVdmaSubmitHgsmi
    137 
    138 static int vboxVdmaInformHost(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, VBOXVDMA_CTL_TYPE enmCtl)
    139 {
    140     int rc = VINF_SUCCESS;
    141 
    142     VBOXVDMA_CTL RT_UNTRUSTED_VOLATILE_HOST *pCmd =
    143         (VBOXVDMA_CTL RT_UNTRUSTED_VOLATILE_HOST *)VBoxSHGSMICommandAlloc(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx,
    144                                                                            sizeof(VBOXVDMA_CTL), HGSMI_CH_VBVA, VBVA_VDMA_CTL);
    145     if (pCmd)
    146     {
    147         pCmd->enmCtl = enmCtl;
    148         pCmd->u32Offset = pInfo->CmdHeap.Heap.area.offBase;
    149         pCmd->i32Result = VERR_NOT_SUPPORTED;
    150 
    151         const VBOXSHGSMIHEADER RT_UNTRUSTED_VOLATILE_HOST *pHdr = VBoxSHGSMICommandPrepSynch(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx,
    152                                                                                              pCmd);
    153         Assert(pHdr);
    154         if (pHdr)
    155         {
    156             do
    157             {
    158                 HGSMIOFFSET offCmd = VBoxSHGSMICommandOffset(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx, pHdr);
    159                 Assert(offCmd != HGSMIOFFSET_VOID);
    160                 if (offCmd != HGSMIOFFSET_VOID)
    161                 {
    162                     rc = vboxWddmVdmaSubmit(pDevExt, pInfo, offCmd);
    163                     AssertRC(rc);
    164                     if (RT_SUCCESS(rc))
    165                     {
    166                         rc = VBoxSHGSMICommandDoneSynch(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx, pHdr);
    167                         AssertRC(rc);
    168                         if (RT_SUCCESS(rc))
    169                         {
    170                             rc = pCmd->i32Result;
    171                             AssertRC(rc);
    172                         }
    173                         break;
    174                     }
    175                 }
    176                 else
    177                     rc = VERR_INVALID_PARAMETER;
    178                 /* fail to submit, cancel it */
    179                 VBoxSHGSMICommandCancelSynch(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx, pHdr);
    180             } while (0);
    181         }
    182 
    183         VBoxSHGSMICommandFree(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx, pCmd);
    184     }
    185     else
    186     {
    187         LOGREL(("HGSMIHeapAlloc failed"));
    188         rc = VERR_OUT_OF_RESOURCES;
    189     }
    190 
    191     return rc;
    192 }
    193 #endif
    194 
    195121static DECLCALLBACK(void *) hgsmiEnvAlloc(void *pvEnv, HGSMISIZE cb)
    196122{
     
    214140/* create a DMACommand buffer */
    215141int vboxVdmaCreate(PVBOXMP_DEVEXT pDevExt, VBOXVDMAINFO *pInfo
    216 #ifdef VBOX_WITH_VDMA
    217         , ULONG offBuffer, ULONG cbBuffer
    218 #endif
    219142        )
    220143{
     144    RT_NOREF(pDevExt);
    221145    pInfo->fEnabled           = FALSE;
    222146
    223 #ifdef VBOX_WITH_VDMA
    224     int rc;
    225     Assert((offBuffer & 0xfff) == 0);
    226     Assert((cbBuffer & 0xfff) == 0);
    227     Assert(offBuffer);
    228     Assert(cbBuffer);
    229 
    230     if((offBuffer & 0xfff)
    231             || (cbBuffer & 0xfff)
    232             || !offBuffer
    233             || !cbBuffer)
    234     {
    235         LOGREL(("invalid parameters: offBuffer(0x%x), cbBuffer(0x%x)", offBuffer, cbBuffer));
    236         return VERR_INVALID_PARAMETER;
    237     }
    238     PVOID pvBuffer;
    239 
    240     rc = VBoxMPCmnMapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt),
    241                                    &pvBuffer,
    242                                    offBuffer,
    243                                    cbBuffer);
    244     Assert(RT_SUCCESS(rc));
    245     if (RT_SUCCESS(rc))
    246     {
    247         /* Setup a HGSMI heap within the adapter information area. */
    248         rc = VBoxSHGSMIInit(&pInfo->CmdHeap,
    249                              pvBuffer,
    250                              cbBuffer,
    251                              offBuffer,
    252                              &g_hgsmiEnvVdma);
    253         Assert(RT_SUCCESS(rc));
    254         if (RT_SUCCESS(rc))
    255             return VINF_SUCCESS;
    256         else
    257             LOGREL(("HGSMIHeapSetup failed rc = 0x%x", rc));
    258 
    259         VBoxMPCmnUnmapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), &pvBuffer);
    260     }
    261     else
    262         LOGREL(("VBoxMapAdapterMemory failed rc = 0x%x\n", rc));
    263     return rc;
    264 #else
    265147    return VINF_SUCCESS;
    266 #endif
    267148}
    268149
    269150int vboxVdmaDisable (PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo)
    270151{
     152    RT_NOREF(pDevExt);
    271153    Assert(pInfo->fEnabled);
    272154    if (!pInfo->fEnabled)
     
    275157    /* ensure nothing else is submitted */
    276158    pInfo->fEnabled        = FALSE;
    277 #ifdef VBOX_WITH_VDMA
    278     int rc = vboxVdmaInformHost (pDevExt, pInfo, VBOXVDMA_CTL_TYPE_DISABLE);
    279     AssertRC(rc);
    280     return rc;
    281 #else
    282159    return VINF_SUCCESS;
    283 #endif
    284160}
    285161
    286162int vboxVdmaEnable (PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo)
    287163{
     164    RT_NOREF(pDevExt);
    288165    Assert(!pInfo->fEnabled);
    289166    if (pInfo->fEnabled)
    290167        return VINF_ALREADY_INITIALIZED;
    291 #ifdef VBOX_WITH_VDMA
    292     int rc = vboxVdmaInformHost (pDevExt, pInfo, VBOXVDMA_CTL_TYPE_ENABLE);
    293     Assert(RT_SUCCESS(rc));
    294     if (RT_SUCCESS(rc))
    295         pInfo->fEnabled        = TRUE;
    296 
    297     return rc;
    298 #else
    299168    return VINF_SUCCESS;
    300 #endif
    301169}
    302 
    303 #ifdef VBOX_WITH_VDMA
    304 int vboxVdmaFlush (PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo)
    305 {
    306     Assert(pInfo->fEnabled);
    307     if (!pInfo->fEnabled)
    308         return VINF_ALREADY_INITIALIZED;
    309 
    310     int rc = vboxVdmaInformHost (pDevExt, pInfo, VBOXVDMA_CTL_TYPE_FLUSH);
    311     Assert(RT_SUCCESS(rc));
    312 
    313     return rc;
    314 }
    315 #endif
    316170
    317171int vboxVdmaDestroy (PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo)
     
    321175    if (pInfo->fEnabled)
    322176        rc = vboxVdmaDisable (pDevExt, pInfo);
    323 #ifdef VBOX_WITH_VDMA
    324     VBoxSHGSMITerm(&pInfo->CmdHeap);
    325     VBoxMPCmnUnmapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), (void**)&pInfo->CmdHeap.Heap.area.pu8Base);
    326 #endif
    327177    return rc;
    328178}
    329 
    330 #ifdef VBOX_WITH_VDMA
    331 void vboxVdmaCBufDrFree(PVBOXVDMAINFO pInfo, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr)
    332 {
    333     VBoxSHGSMICommandFree(&pInfo->CmdHeap, pDr);
    334 }
    335 
    336 VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *vboxVdmaCBufDrCreate(PVBOXVDMAINFO pInfo, uint32_t cbTrailingData)
    337 {
    338     uint32_t cbDr = VBOXVDMACBUF_DR_SIZE(cbTrailingData);
    339     VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr =
    340         (VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *)VBoxSHGSMICommandAlloc(&pInfo->CmdHeap, cbDr, HGSMI_CH_VBVA, VBVA_VDMA_CMD);
    341     Assert(pDr);
    342     if (pDr)
    343         memset((void *)pDr, 0, cbDr);
    344     else
    345         LOGREL(("VBoxSHGSMICommandAlloc returned NULL"));
    346 
    347     return pDr;
    348 }
    349 
    350 static DECLCALLBACK(void) vboxVdmaCBufDrCompletion(PVBOXSHGSMI pHeap, void *pvCmd, void *pvContext)
    351 {
    352     RT_NOREF(pHeap);
    353     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)pvContext;
    354     PVBOXVDMAINFO pInfo = &pDevExt->u.primary.Vdma;
    355 
    356     vboxVdmaCBufDrFree(pInfo, (PVBOXVDMACBUF_DR)pvCmd);
    357 }
    358 
    359 /** @callback_method_impl{FNVBOXSHGSMICMDCOMPLETION_IRQ} */
    360 static DECLCALLBACK(PFNVBOXSHGSMICMDCOMPLETION)
    361 vboxVdmaCBufDrCompletionIrq(PVBOXSHGSMI pHeap, void RT_UNTRUSTED_VOLATILE_HOST *pvCmd, void *pvContext, void **ppvCompletion)
    362 {
    363     RT_NOREF(pHeap, ppvCompletion);
    364     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)pvContext;
    365     VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr = (VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *)pvCmd;
    366 
    367     DXGK_INTERRUPT_TYPE enmComplType;
    368 
    369     if (RT_SUCCESS(pDr->rc))
    370     {
    371         enmComplType = DXGK_INTERRUPT_DMA_COMPLETED;
    372     }
    373     else if (pDr->rc == VERR_INTERRUPTED)
    374     {
    375         AssertFailed();
    376         enmComplType = DXGK_INTERRUPT_DMA_PREEMPTED;
    377     }
    378     else
    379     {
    380         AssertFailed();
    381         enmComplType = DXGK_INTERRUPT_DMA_FAULTED;
    382     }
    383 
    384     if (vboxVdmaDdiCmdCompletedIrq(pDevExt, VBOXVDMADDI_CMD_FROM_BUF_DR(pDr), enmComplType))
    385     {
    386         pDevExt->bNotifyDxDpc = TRUE;
    387     }
    388 
    389     /* inform SHGSMI we DO NOT want to be called at DPC later */
    390     return NULL;
    391 //    *ppvCompletion = pvContext;
    392 }
    393 
    394 int vboxVdmaCBufDrSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr)
    395 {
    396     const VBOXSHGSMIHEADER RT_UNTRUSTED_VOLATILE_HOST *pHdr =
    397         VBoxSHGSMICommandPrepAsynchIrq(&pInfo->CmdHeap, pDr, vboxVdmaCBufDrCompletionIrq, pDevExt, VBOXSHGSMI_FLAG_GH_ASYNCH_FORCE);
    398     Assert(pHdr);
    399     int rc = VERR_GENERAL_FAILURE;
    400     if (pHdr)
    401     {
    402         do
    403         {
    404             HGSMIOFFSET offCmd = VBoxSHGSMICommandOffset(&pInfo->CmdHeap, pHdr);
    405             Assert(offCmd != HGSMIOFFSET_VOID);
    406             if (offCmd != HGSMIOFFSET_VOID)
    407             {
    408                 rc = vboxWddmVdmaSubmit(pDevExt, pInfo, offCmd);
    409                 AssertRC(rc);
    410                 if (RT_SUCCESS(rc))
    411                 {
    412                     VBoxSHGSMICommandDoneAsynch(&pInfo->CmdHeap, pHdr);
    413                     AssertRC(rc);
    414                     break;
    415                 }
    416             }
    417             else
    418                 rc = VERR_INVALID_PARAMETER;
    419             /* fail to submit, cancel it */
    420             VBoxSHGSMICommandCancelAsynch(&pInfo->CmdHeap, pHdr);
    421         } while (0);
    422     }
    423     else
    424         rc = VERR_INVALID_PARAMETER;
    425     return rc;
    426 }
    427 
    428 int vboxVdmaCBufDrSubmitSynch(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr)
    429 {
    430     const VBOXSHGSMIHEADER RT_UNTRUSTED_VOLATILE_HOST *pHdr = VBoxSHGSMICommandPrepAsynch(&pInfo->CmdHeap, pDr, NULL,
    431                                                                                           NULL, VBOXSHGSMI_FLAG_GH_SYNCH);
    432     Assert(pHdr);
    433     int rc = VERR_GENERAL_FAILURE;
    434     if (pHdr)
    435     {
    436         do
    437         {
    438             HGSMIOFFSET offCmd = VBoxSHGSMICommandOffset(&pInfo->CmdHeap, pHdr);
    439             Assert(offCmd != HGSMIOFFSET_VOID);
    440             if (offCmd != HGSMIOFFSET_VOID)
    441             {
    442                 rc = vboxWddmVdmaSubmit(pDevExt, pInfo, offCmd);
    443                 AssertRC(rc);
    444                 if (RT_SUCCESS(rc))
    445                 {
    446                     VBoxSHGSMICommandDoneAsynch(&pInfo->CmdHeap, pHdr);
    447                     AssertRC(rc);
    448                     break;
    449                 }
    450             }
    451             else
    452                 rc = VERR_INVALID_PARAMETER;
    453             /* fail to submit, cancel it */
    454             VBoxSHGSMICommandCancelAsynch(&pInfo->CmdHeap, pHdr);
    455         } while (0);
    456     }
    457     else
    458         rc = VERR_INVALID_PARAMETER;
    459     return rc;
    460 }
    461 #endif
    462 
    463 
    464 /* ddi dma command queue */
    465 
    466 VOID vboxVdmaDdiCmdGetCompletedListIsr(PVBOXMP_DEVEXT pDevExt, LIST_ENTRY *pList)
    467 {
    468     vboxVideoLeDetach(&pDevExt->DpcCmdQueue, pList);
    469 }
    470 
    471 BOOLEAN vboxVdmaDdiCmdIsCompletedListEmptyIsr(PVBOXMP_DEVEXT pDevExt)
    472 {
    473     return IsListEmpty(&pDevExt->DpcCmdQueue);
    474 }
    475 
    476 DECLINLINE(BOOLEAN) vboxVdmaDdiCmdCanComplete(PVBOXMP_DEVEXT pDevExt, UINT u32NodeOrdinal)
    477 {
    478     PVBOXVDMADDI_CMD_QUEUE pQueue = &pDevExt->aNodes[u32NodeOrdinal].CmdQueue;
    479     return ASMAtomicUoReadU32(&pQueue->cQueuedCmds) == 0;
    480 }
    481 
    482 DECLCALLBACK(VOID) vboxVdmaDdiCmdCompletionCbFree(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext)
    483 {
    484     RT_NOREF(pDevExt, pvContext);
    485     vboxWddmMemFree(pCmd);
    486 }
    487 
    488 static VOID vboxVdmaDdiCmdNotifyCompletedIrq(PVBOXMP_DEVEXT pDevExt, UINT u32NodeOrdinal, UINT u32FenceId, DXGK_INTERRUPT_TYPE enmComplType)
    489 {
    490     PVBOXVDMADDI_NODE pNode = &pDevExt->aNodes[u32NodeOrdinal];
    491     DXGKARGCB_NOTIFY_INTERRUPT_DATA notify;
    492     memset(&notify, 0, sizeof(DXGKARGCB_NOTIFY_INTERRUPT_DATA));
    493     switch (enmComplType)
    494     {
    495         case DXGK_INTERRUPT_DMA_COMPLETED:
    496             notify.InterruptType = DXGK_INTERRUPT_DMA_COMPLETED;
    497             notify.DmaCompleted.SubmissionFenceId = u32FenceId;
    498             notify.DmaCompleted.NodeOrdinal = u32NodeOrdinal;
    499             pNode->uLastCompletedFenceId = u32FenceId;
    500             break;
    501 
    502         case DXGK_INTERRUPT_DMA_PREEMPTED:
    503             Assert(0);
    504             notify.InterruptType = DXGK_INTERRUPT_DMA_PREEMPTED;
    505             notify.DmaPreempted.PreemptionFenceId = u32FenceId;
    506             notify.DmaPreempted.NodeOrdinal = u32NodeOrdinal;
    507             notify.DmaPreempted.LastCompletedFenceId = pNode->uLastCompletedFenceId;
    508             break;
    509 
    510         case DXGK_INTERRUPT_DMA_FAULTED:
    511             Assert(0);
    512             notify.InterruptType = DXGK_INTERRUPT_DMA_FAULTED;
    513             notify.DmaFaulted.FaultedFenceId = u32FenceId;
    514             notify.DmaFaulted.Status = STATUS_UNSUCCESSFUL; /** @todo better status ? */
    515             notify.DmaFaulted.NodeOrdinal = u32NodeOrdinal;
    516             break;
    517 
    518         default:
    519             Assert(0);
    520             break;
    521     }
    522 
    523     pDevExt->u.primary.DxgkInterface.DxgkCbNotifyInterrupt(pDevExt->u.primary.DxgkInterface.DeviceHandle, &notify);
    524 }
    525 
    526 static VOID vboxVdmaDdiCmdProcessCompletedIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType)
    527 {
    528     vboxVdmaDdiCmdNotifyCompletedIrq(pDevExt, pCmd->u32NodeOrdinal, pCmd->u32FenceId, enmComplType);
    529     switch (enmComplType)
    530     {
    531         case DXGK_INTERRUPT_DMA_COMPLETED:
    532             InsertTailList(&pDevExt->DpcCmdQueue, &pCmd->QueueEntry);
    533             break;
    534         default:
    535             AssertFailed();
    536             break;
    537     }
    538 }
    539 
    540 DECLINLINE(VOID) vboxVdmaDdiCmdDequeueIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd)
    541 {
    542     PVBOXVDMADDI_CMD_QUEUE pQueue = &pDevExt->aNodes[pCmd->u32NodeOrdinal].CmdQueue;
    543     ASMAtomicDecU32(&pQueue->cQueuedCmds);
    544     RemoveEntryList(&pCmd->QueueEntry);
    545 }
    546 
    547 DECLINLINE(VOID) vboxVdmaDdiCmdEnqueueIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd)
    548 {
    549     PVBOXVDMADDI_CMD_QUEUE pQueue = &pDevExt->aNodes[pCmd->u32NodeOrdinal].CmdQueue;
    550     ASMAtomicIncU32(&pQueue->cQueuedCmds);
    551     InsertTailList(&pQueue->CmdQueue, &pCmd->QueueEntry);
    552 }
    553 
    554 VOID vboxVdmaDdiNodesInit(PVBOXMP_DEVEXT pDevExt)
    555 {
    556     for (UINT i = 0; i < RT_ELEMENTS(pDevExt->aNodes); ++i)
    557     {
    558         pDevExt->aNodes[i].uLastCompletedFenceId = 0;
    559         PVBOXVDMADDI_CMD_QUEUE pQueue = &pDevExt->aNodes[i].CmdQueue;
    560         pQueue->cQueuedCmds = 0;
    561         InitializeListHead(&pQueue->CmdQueue);
    562     }
    563     InitializeListHead(&pDevExt->DpcCmdQueue);
    564 }
    565 
    566 BOOLEAN vboxVdmaDdiCmdCompletedIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType)
    567 {
    568     if (VBOXVDMADDI_STATE_NOT_DX_CMD == pCmd->enmState)
    569     {
    570         InsertTailList(&pDevExt->DpcCmdQueue, &pCmd->QueueEntry);
    571         return FALSE;
    572     }
    573 
    574     PVBOXVDMADDI_CMD_QUEUE pQueue = &pDevExt->aNodes[pCmd->u32NodeOrdinal].CmdQueue;
    575     BOOLEAN bQueued = pCmd->enmState > VBOXVDMADDI_STATE_NOT_QUEUED;
    576     BOOLEAN bComplete = FALSE;
    577     Assert(!bQueued || pQueue->cQueuedCmds);
    578     Assert(!bQueued || !IsListEmpty(&pQueue->CmdQueue));
    579     pCmd->enmState = VBOXVDMADDI_STATE_COMPLETED;
    580     if (bQueued)
    581     {
    582         if (pQueue->CmdQueue.Flink == &pCmd->QueueEntry)
    583         {
    584             vboxVdmaDdiCmdDequeueIrq(pDevExt, pCmd);
    585             bComplete = TRUE;
    586         }
    587     }
    588     else if (IsListEmpty(&pQueue->CmdQueue))
    589     {
    590         bComplete = TRUE;
    591     }
    592     else
    593     {
    594         vboxVdmaDdiCmdEnqueueIrq(pDevExt, pCmd);
    595     }
    596 
    597     if (bComplete)
    598     {
    599         vboxVdmaDdiCmdProcessCompletedIrq(pDevExt, pCmd, enmComplType);
    600 
    601         while (!IsListEmpty(&pQueue->CmdQueue))
    602         {
    603             pCmd = VBOXVDMADDI_CMD_FROM_ENTRY(pQueue->CmdQueue.Flink);
    604             if (pCmd->enmState == VBOXVDMADDI_STATE_COMPLETED)
    605             {
    606                 vboxVdmaDdiCmdDequeueIrq(pDevExt, pCmd);
    607                 vboxVdmaDdiCmdProcessCompletedIrq(pDevExt, pCmd, pCmd->enmComplType);
    608             }
    609             else
    610                 break;
    611         }
    612     }
    613     else
    614     {
    615         pCmd->enmState = VBOXVDMADDI_STATE_COMPLETED;
    616         pCmd->enmComplType = enmComplType;
    617     }
    618 
    619     return bComplete;
    620 }
    621 
    622 VOID vboxVdmaDdiCmdSubmittedIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd)
    623 {
    624     BOOLEAN bQueued = pCmd->enmState >= VBOXVDMADDI_STATE_PENDING;
    625     Assert(pCmd->enmState < VBOXVDMADDI_STATE_SUBMITTED);
    626     pCmd->enmState = VBOXVDMADDI_STATE_SUBMITTED;
    627     if (!bQueued)
    628         vboxVdmaDdiCmdEnqueueIrq(pDevExt, pCmd);
    629 }
    630 
    631 typedef struct VBOXVDMADDI_CMD_COMPLETED_CB
    632 {
    633     PVBOXMP_DEVEXT pDevExt;
    634     PVBOXVDMADDI_CMD pCmd;
    635     DXGK_INTERRUPT_TYPE enmComplType;
    636 } VBOXVDMADDI_CMD_COMPLETED_CB, *PVBOXVDMADDI_CMD_COMPLETED_CB;
    637 
    638 static BOOLEAN vboxVdmaDdiCmdCompletedCb(PVOID Context)
    639 {
    640     PVBOXVDMADDI_CMD_COMPLETED_CB pdc = (PVBOXVDMADDI_CMD_COMPLETED_CB)Context;
    641     PVBOXMP_DEVEXT pDevExt = pdc->pDevExt;
    642     BOOLEAN bNeedDpc = vboxVdmaDdiCmdCompletedIrq(pDevExt, pdc->pCmd, pdc->enmComplType);
    643     pDevExt->bNotifyDxDpc |= bNeedDpc;
    644 
    645     if (bNeedDpc)
    646     {
    647         pDevExt->u.primary.DxgkInterface.DxgkCbQueueDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    648     }
    649 
    650     return bNeedDpc;
    651 }
    652 
    653 NTSTATUS vboxVdmaDdiCmdCompleted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType)
    654 {
    655     VBOXVDMADDI_CMD_COMPLETED_CB context;
    656     context.pDevExt = pDevExt;
    657     context.pCmd = pCmd;
    658     context.enmComplType = enmComplType;
    659     BOOLEAN bNeedDps;
    660     NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
    661             pDevExt->u.primary.DxgkInterface.DeviceHandle,
    662             vboxVdmaDdiCmdCompletedCb,
    663             &context,
    664             0, /* IN ULONG MessageNumber */
    665             &bNeedDps);
    666     AssertNtStatusSuccess(Status);
    667     return Status;
    668 }
    669 
    670 typedef struct VBOXVDMADDI_CMD_SUBMITTED_CB
    671 {
    672     PVBOXMP_DEVEXT pDevExt;
    673     PVBOXVDMADDI_CMD pCmd;
    674 } VBOXVDMADDI_CMD_SUBMITTED_CB, *PVBOXVDMADDI_CMD_SUBMITTED_CB;
    675 
    676 static BOOLEAN vboxVdmaDdiCmdSubmittedCb(PVOID Context)
    677 {
    678     PVBOXVDMADDI_CMD_SUBMITTED_CB pdc = (PVBOXVDMADDI_CMD_SUBMITTED_CB)Context;
    679     vboxVdmaDdiCmdSubmittedIrq(pdc->pDevExt, pdc->pCmd);
    680 
    681     return FALSE;
    682 }
    683 
    684 NTSTATUS vboxVdmaDdiCmdSubmitted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd)
    685 {
    686     VBOXVDMADDI_CMD_SUBMITTED_CB context;
    687     context.pDevExt = pDevExt;
    688     context.pCmd = pCmd;
    689     BOOLEAN bRc;
    690     NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
    691             pDevExt->u.primary.DxgkInterface.DeviceHandle,
    692             vboxVdmaDdiCmdSubmittedCb,
    693             &context,
    694             0, /* IN ULONG MessageNumber */
    695             &bRc);
    696     AssertNtStatusSuccess(Status);
    697     return Status;
    698 }
    699 
    700 typedef struct VBOXVDMADDI_CMD_COMPLETE_CB
    701 {
    702     PVBOXMP_DEVEXT pDevExt;
    703     UINT u32NodeOrdinal;
    704     uint32_t u32FenceId;
    705 } VBOXVDMADDI_CMD_COMPLETE_CB, *PVBOXVDMADDI_CMD_COMPLETE_CB;
    706 
    707 static BOOLEAN vboxVdmaDdiCmdFenceCompleteCb(PVOID Context)
    708 {
    709     PVBOXVDMADDI_CMD_COMPLETE_CB pdc = (PVBOXVDMADDI_CMD_COMPLETE_CB)Context;
    710     PVBOXMP_DEVEXT pDevExt = pdc->pDevExt;
    711 
    712     vboxVdmaDdiCmdNotifyCompletedIrq(pDevExt, pdc->u32NodeOrdinal, pdc->u32FenceId, DXGK_INTERRUPT_DMA_COMPLETED);
    713 
    714     pDevExt->bNotifyDxDpc = TRUE;
    715     pDevExt->u.primary.DxgkInterface.DxgkCbQueueDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    716 
    717     return TRUE;
    718 }
    719 
    720 static NTSTATUS vboxVdmaDdiCmdFenceNotifyComplete(PVBOXMP_DEVEXT pDevExt, uint32_t u32NodeOrdinal, uint32_t u32FenceId)
    721 {
    722     VBOXVDMADDI_CMD_COMPLETE_CB context;
    723     context.pDevExt = pDevExt;
    724     context.u32NodeOrdinal = u32NodeOrdinal;
    725     context.u32FenceId = u32FenceId;
    726     BOOLEAN bRet;
    727     NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
    728             pDevExt->u.primary.DxgkInterface.DeviceHandle,
    729             vboxVdmaDdiCmdFenceCompleteCb,
    730             &context,
    731             0, /* IN ULONG MessageNumber */
    732             &bRet);
    733     AssertNtStatusSuccess(Status);
    734     return Status;
    735 }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h

    r80487 r80876  
    2929typedef struct _VBOXMP_DEVEXT *PVBOXMP_DEVEXT;
    3030
    31 /* ddi dma command queue handling */
    32 typedef enum
    33 {
    34     VBOXVDMADDI_STATE_UNCKNOWN = 0,
    35     VBOXVDMADDI_STATE_NOT_DX_CMD,
    36     VBOXVDMADDI_STATE_NOT_QUEUED,
    37     VBOXVDMADDI_STATE_PENDING,
    38     VBOXVDMADDI_STATE_SUBMITTED,
    39     VBOXVDMADDI_STATE_COMPLETED
    40 } VBOXVDMADDI_STATE;
    41 
    42 typedef struct VBOXVDMADDI_CMD *PVBOXVDMADDI_CMD;
    43 typedef DECLCALLBACK(VOID) FNVBOXVDMADDICMDCOMPLETE_DPC(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
    44 typedef FNVBOXVDMADDICMDCOMPLETE_DPC *PFNVBOXVDMADDICMDCOMPLETE_DPC;
    45 
    46 typedef struct VBOXVDMADDI_CMD
    47 {
    48     LIST_ENTRY QueueEntry;
    49     VBOXVDMADDI_STATE enmState;
    50     uint32_t u32NodeOrdinal;
    51     uint32_t u32FenceId;
    52     DXGK_INTERRUPT_TYPE enmComplType;
    53     PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete;
    54     PVOID pvComplete;
    55 } VBOXVDMADDI_CMD, *PVBOXVDMADDI_CMD;
    56 
    57 typedef struct VBOXVDMADDI_CMD_QUEUE
    58 {
    59     volatile uint32_t cQueuedCmds;
    60     LIST_ENTRY CmdQueue;
    61 } VBOXVDMADDI_CMD_QUEUE, *PVBOXVDMADDI_CMD_QUEUE;
    62 
    63 typedef struct VBOXVDMADDI_NODE
    64 {
    65     VBOXVDMADDI_CMD_QUEUE CmdQueue;
    66     UINT uLastCompletedFenceId;
    67 } VBOXVDMADDI_NODE, *PVBOXVDMADDI_NODE;
    68 
    69 VOID vboxVdmaDdiNodesInit(PVBOXMP_DEVEXT pDevExt);
    70 BOOLEAN vboxVdmaDdiCmdCompletedIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
    71 VOID vboxVdmaDdiCmdSubmittedIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd);
    72 
    73 NTSTATUS vboxVdmaDdiCmdCompleted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
    74 NTSTATUS vboxVdmaDdiCmdSubmitted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd);
    75 
    76 DECLINLINE(VOID) vboxVdmaDdiCmdInit(PVBOXVDMADDI_CMD pCmd, uint32_t u32NodeOrdinal, uint32_t u32FenceId,
    77                                     PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete, PVOID pvComplete)
    78 {
    79     pCmd->QueueEntry.Blink = NULL;
    80     pCmd->QueueEntry.Flink = NULL;
    81     pCmd->enmState = VBOXVDMADDI_STATE_NOT_QUEUED;
    82     pCmd->u32NodeOrdinal = u32NodeOrdinal;
    83     pCmd->u32FenceId = u32FenceId;
    84     pCmd->pfnComplete = pfnComplete;
    85     pCmd->pvComplete = pvComplete;
    86 }
    87 
    88 /* marks the command a submitted in a way that it is invisible for dx runtime,
    89  * i.e. the dx runtime won't be notified about the command completion
    90  * this is used to submit commands initiated by the driver, but not by the dx runtime */
    91 DECLINLINE(VOID) vboxVdmaDdiCmdSubmittedNotDx(PVBOXVDMADDI_CMD pCmd)
    92 {
    93     Assert(pCmd->enmState == VBOXVDMADDI_STATE_NOT_QUEUED);
    94     pCmd->enmState = VBOXVDMADDI_STATE_NOT_DX_CMD;
    95 }
    96 
    97 DECLCALLBACK(VOID) vboxVdmaDdiCmdCompletionCbFree(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
    98 
    99 VOID vboxVdmaDdiCmdGetCompletedListIsr(PVBOXMP_DEVEXT pDevExt, LIST_ENTRY *pList);
    100 
    101 BOOLEAN vboxVdmaDdiCmdIsCompletedListEmptyIsr(PVBOXMP_DEVEXT pDevExt);
    102 
    103 #define VBOXVDMADDI_CMD_FROM_ENTRY(_pEntry) ((PVBOXVDMADDI_CMD)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVDMADDI_CMD, QueueEntry)))
    104 
    105 DECLINLINE(VOID) vboxVdmaDdiCmdHandleCompletedList(PVBOXMP_DEVEXT pDevExt, LIST_ENTRY *pList)
    106 {
    107     LIST_ENTRY *pEntry = pList->Flink;
    108     while (pEntry != pList)
    109     {
    110         PVBOXVDMADDI_CMD pCmd = VBOXVDMADDI_CMD_FROM_ENTRY(pEntry);
    111         pEntry = pEntry->Flink;
    112         if (pCmd->pfnComplete)
    113             pCmd->pfnComplete(pDevExt, pCmd, pCmd->pvComplete);
    114     }
    115 }
    116 
    11731/* DMA commands are currently submitted over HGSMI */
    11832typedef struct VBOXVDMAINFO
    11933{
    120 #ifdef VBOX_WITH_VDMA
    121     VBOXSHGSMI CmdHeap;
    122 #endif
    123     UINT      uLastCompletedPagingBufferCmdFenceId;
    12434    BOOL      fEnabled;
    12535} VBOXVDMAINFO, *PVBOXVDMAINFO;
    12636
    12737int vboxVdmaCreate (PVBOXMP_DEVEXT pDevExt, VBOXVDMAINFO *pInfo
    128 #ifdef VBOX_WITH_VDMA
    129         , ULONG offBuffer, ULONG cbBuffer
    130 #endif
    131 #if 0
    132         , PFNVBOXVDMASUBMIT pfnSubmit, PVOID pvContext
    133 #endif
    13438        );
    13539int vboxVdmaDisable(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
     
    13741int vboxVdmaDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
    13842
    139 #ifdef VBOX_WITH_VDMA
    140 int vboxVdmaFlush(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
    141 DECLINLINE(HGSMIOFFSET) vboxVdmaCBufDrPtrOffset(const PVBOXVDMAINFO pInfo, const void RT_UNTRUSTED_VOLATILE_HOST *pvPtr)
    142 {
    143     return VBoxSHGSMICommandPtrOffset(&pInfo->CmdHeap, pvPtr);
    144 }
    145 int vboxVdmaCBufDrSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr);
    146 int vboxVdmaCBufDrSubmitSynch(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr);
    147 struct VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *vboxVdmaCBufDrCreate(PVBOXVDMAINFO pInfo, uint32_t cbTrailingData);
    148 void vboxVdmaCBufDrFree(PVBOXVDMAINFO pInfo, struct VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr);
    149 
    150 #define VBOXVDMACBUF_DR_DATA_OFFSET() (sizeof (VBOXVDMACBUF_DR))
    151 #define VBOXVDMACBUF_DR_SIZE(_cbData) (VBOXVDMACBUF_DR_DATA_OFFSET() + (_cbData))
    152 #define VBOXVDMACBUF_DR_DATA(_pDr) ( ((uint8_t*)(_pDr)) + VBOXVDMACBUF_DR_DATA_OFFSET() )
    153 
    154 AssertCompile(sizeof (VBOXVDMADDI_CMD) <= RT_SIZEOFMEMB(VBOXVDMACBUF_DR, aGuestData));
    155 #define VBOXVDMADDI_CMD_FROM_BUF_DR(_pDr) ((PVBOXVDMADDI_CMD)(_pDr)->aGuestData)
    156 #define VBOXVDMACBUF_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMACBUF_DR)(((uint8_t*)(_pCmd)) - RT_UOFFSETOF(VBOXVDMACBUF_DR, aGuestData)))
    157 
    158 #endif
    159 
    16043NTSTATUS vboxVdmaGgDmaBltPerform(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_ALLOC_DATA * pSrcAlloc, RECT* pSrcRect,
    16144        struct VBOXWDDM_ALLOC_DATA *pDstAlloc, RECT* pDstRect);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r80748 r80876  
    627627PVBOXSHGSMI vboxWddmHgsmiGetHeapFromCmdOffset(PVBOXMP_DEVEXT pDevExt, HGSMIOFFSET offCmd)
    628628{
    629 #ifdef VBOX_WITH_VDMA
    630     if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.Heap.area, offCmd))
    631         return &pDevExt->u.primary.Vdma.CmdHeap;
    632 #endif
    633629    if (HGSMIAreaContainsOffset(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx.Heap.area, offCmd))
    634630        return &VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx;
     
    640636    VBOXWDDM_HGSMICMD_TYPE_UNDEFINED = 0,
    641637    VBOXWDDM_HGSMICMD_TYPE_CTL       = 1,
    642 #ifdef VBOX_WITH_VDMA
    643     VBOXWDDM_HGSMICMD_TYPE_DMACMD    = 2
    644 #endif
    645638} VBOXWDDM_HGSMICMD_TYPE;
    646639
    647640VBOXWDDM_HGSMICMD_TYPE vboxWddmHgsmiGetCmdTypeFromOffset(PVBOXMP_DEVEXT pDevExt, HGSMIOFFSET offCmd)
    648641{
    649 #ifdef VBOX_WITH_VDMA
    650     if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.Heap.area, offCmd))
    651         return VBOXWDDM_HGSMICMD_TYPE_DMACMD;
    652 #endif
    653642    if (HGSMIAreaContainsOffset(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx.Heap.area, offCmd))
    654643        return VBOXWDDM_HGSMICMD_TYPE_CTL;
     
    801790        ULONG ulSize;
    802791        ULONG offset;
    803 #ifdef VBOX_WITH_VDMA
    804         ulSize = ulAvailable / 2;
    805         if (ulSize > VBOXWDDM_C_VDMA_BUFFER_SIZE)
    806             ulSize = VBOXWDDM_C_VDMA_BUFFER_SIZE;
    807 
    808         /* Align down to 4096 bytes. */
    809         ulSize &= ~0xFFF;
    810         offset = ulAvailable - ulSize;
    811 
    812         Assert(!(offset & 0xFFF));
    813 #else
    814792        offset = ulAvailable;
    815 #endif
    816793        rc = vboxVdmaCreate (pDevExt, &pDevExt->u.primary.Vdma
    817 #ifdef VBOX_WITH_VDMA
    818                 , offset, ulSize
    819 #endif
    820794                );
    821795        AssertRC(rc);
     
    11101084                    LOG(("sources(%d), children(%d)", *NumberOfVideoPresentSources, *NumberOfChildren));
    11111085
    1112                     vboxVdmaDdiNodesInit(pDevExt);
    11131086                    vboxVideoCmInit(&pDevExt->CmMgr);
    11141087                    vboxVideoCmInit(&pDevExt->SeamlessCtxMgr);
     
    14461419    {
    14471420        VBOXVTLIST CtlList;
    1448 #ifdef VBOX_WITH_VDMA
    1449         VBOXVTLIST DmaCmdList;
    1450 #endif
    14511421        vboxVtListInit(&CtlList);
    1452 #ifdef VBOX_WITH_VDMA
    1453         vboxVtListInit(&DmaCmdList);
    1454 #endif
    14551422
    14561423#ifdef VBOX_WITH_VIDEOHWACCEL
     
    14791446                    switch (enmType)
    14801447                    {
    1481 #ifdef VBOX_WITH_VDMA
    1482                         case VBOXWDDM_HGSMICMD_TYPE_DMACMD:
    1483                             pList = &DmaCmdList;
    1484                             pHeap = &pDevExt->u.primary.Vdma.CmdHeap;
    1485                             break;
    1486 #endif
    14871448                        case VBOXWDDM_HGSMICMD_TYPE_CTL:
    14881449                            pList = &CtlList;
     
    15061467                            switch (chInfo)
    15071468                            {
    1508 #ifdef VBOX_WITH_VDMA
    1509                                 case VBVA_VDMA_CMD:
    1510                                 case VBVA_VDMA_CTL:
    1511                                 {
    1512                                     int rc = VBoxSHGSMICommandProcessCompletion(pHeap, (VBOXSHGSMIHEADER*)pvCmd,
    1513                                                                                 TRUE /*bool bIrq*/ , pList);
    1514                                     AssertRC(rc);
    1515                                     break;
    1516                                 }
    1517 #endif
    15181469#ifdef VBOX_WITH_VIDEOHWACCEL
    15191470                                case VBVA_VHWA_CMD:
     
    15461497            bNeedDpc = TRUE;
    15471498        }
    1548 #ifdef VBOX_WITH_VDMA
    1549         if (!vboxVtListIsEmpty(&DmaCmdList))
    1550         {
    1551             vboxVtListCat(&pDevExt->DmaCmdList, &DmaCmdList);
    1552             bNeedDpc = TRUE;
    1553         }
    1554 #endif
    15551499#ifdef VBOX_WITH_VIDEOHWACCEL
    15561500        if (!vboxVtListIsEmpty(&VhwaCmdList))
     
    15601504        }
    15611505#endif
    1562         bNeedDpc |= !vboxVdmaDdiCmdIsCompletedListEmptyIsr(pDevExt);
    15631506
    15641507        if (pDevExt->bNotifyDxDpc)
     
    16161559{
    16171560    VBOXVTLIST CtlList;
    1618 #ifdef VBOX_WITH_VDMA
    1619     VBOXVTLIST DmaCmdList;
    1620 #endif
    16211561#ifdef VBOX_WITH_VIDEOHWACCEL
    16221562    VBOXVTLIST VhwaCmdList;
     
    16371577    PVBOXMP_DEVEXT pDevExt = pdc->pDevExt;
    16381578    vboxVtListDetach2List(&pDevExt->CtlList, &pdc->data.CtlList);
    1639 #ifdef VBOX_WITH_VDMA
    1640     vboxVtListDetach2List(&pDevExt->DmaCmdList, &pdc->data.DmaCmdList);
    1641 #endif
    16421579#ifdef VBOX_WITH_VIDEOHWACCEL
    16431580    vboxVtListDetach2List(&pDevExt->VhwaCmdList, &pdc->data.VhwaCmdList);
    16441581#endif
    1645     if (!pDevExt->fCmdVbvaEnabled)
    1646     {
    1647         vboxVdmaDdiCmdGetCompletedListIsr(pDevExt, &pdc->data.CompletedDdiCmdQueue);
    1648     }
    16491582
    16501583    pdc->data.bNotifyDpc = pDevExt->bNotifyDxDpc;
     
    16881621        AssertRC(rc);
    16891622    }
    1690 #ifdef VBOX_WITH_VDMA
    1691     if (!vboxVtListIsEmpty(&context.data.DmaCmdList))
    1692     {
    1693         int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.Vdma.CmdHeap, &context.data.DmaCmdList);
    1694         AssertRC(rc);
    1695     }
    1696 #endif
    16971623#ifdef VBOX_WITH_VIDEOHWACCEL
    16981624    if (!vboxVtListIsEmpty(&context.data.VhwaCmdList))
     
    17011627    }
    17021628#endif
    1703 
    1704     vboxVdmaDdiCmdHandleCompletedList(pDevExt, &context.data.CompletedDdiCmdQueue);
    17051629
    17061630//    LOGF(("LEAVE, context(0x%p)", MiniportDeviceContext));
     
    43224246#define VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE() (VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_PRESENT_BLT))
    43234247#define VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(_c) (VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects[_c]))
    4324 
    4325 #ifdef VBOX_WITH_VDMA
    4326 DECLINLINE(VOID) vboxWddmRectlFromRect(const RECT *pRect, PVBOXVDMA_RECTL pRectl)
    4327 {
    4328     pRectl->left = (int16_t)pRect->left;
    4329     pRectl->width = (uint16_t)(pRect->right - pRect->left);
    4330     pRectl->top = (int16_t)pRect->top;
    4331     pRectl->height = (uint16_t)(pRect->bottom - pRect->top);
    4332 }
    4333 
    4334 DECLINLINE(VBOXVDMA_PIXEL_FORMAT) vboxWddmFromPixFormat(D3DDDIFORMAT format)
    4335 {
    4336     return (VBOXVDMA_PIXEL_FORMAT)format;
    4337 }
    4338 
    4339 DECLINLINE(VOID) vboxWddmSurfDescFromAllocation(PVBOXWDDM_ALLOCATION pAllocation, PVBOXVDMA_SURF_DESC pDesc)
    4340 {
    4341     pDesc->width = pAllocation->AllocData.SurfDesc.width;
    4342     pDesc->height = pAllocation->AllocData.SurfDesc.height;
    4343     pDesc->format = vboxWddmFromPixFormat(pAllocation->AllocData.SurfDesc.format);
    4344     pDesc->bpp = pAllocation->AllocData.SurfDesc.bpp;
    4345     pDesc->pitch = pAllocation->AllocData.SurfDesc.pitch;
    4346     pDesc->fFlags = 0;
    4347 }
    4348 #endif
    43494248
    43504249DECLINLINE(BOOLEAN) vboxWddmPixFormatConversionSupported(D3DDDIFORMAT From, D3DDDIFORMAT To)
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