VirtualBox

Changeset 80422 in vbox


Ignore:
Timestamp:
Aug 26, 2019 1:56:24 PM (5 years ago)
Author:
vboxsync
Message:

WDDM: remove old chromium based 3D code from the miniport driver. bugref:9529

Location:
trunk/src/VBox/Additions/WINNT
Files:
3 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/common/VBoxVideoLog.h

    r76563 r80422  
    6666#endif
    6767
    68 #ifdef DEBUG_misha
     68#ifdef DEBUG_sunlover
    6969# define BP_WARN() AssertFailed()
    7070#else
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/common/wddm/VBoxMPIf.h

    r76563 r80422  
    254254    VBOXWDDM_CONTEXT_TYPE_SYSTEM,
    255255    /* context created by the D3D User-mode driver when crogl IS available */
    256     VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D,
     256    obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D,
    257257    /* context created by the D3D User-mode driver when crogl is NOT available or for ddraw overlay acceleration */
    258     VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D,
     258    obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D,
    259259    /* contexts created by the cromium HGSMI transport for HGSMI commands submission */
    260     VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D,
    261     VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL,
     260    obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D,
     261    obsolete_VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL,
    262262    /* context created by the kernel->user communication mechanism for visible rects reporting, etc.  */
    263263    VBOXWDDM_CONTEXT_TYPE_CUSTOM_SESSION,
     
    475475} VBOXVIDEOCM_UM_ALLOC, *PVBOXVIDEOCM_UM_ALLOC;
    476476
    477 typedef struct VBOXDISPIFESCAPE_UHGSMI_ALLOCATE
    478 {
    479     VBOXDISPIFESCAPE EscapeHdr;
    480     VBOXVIDEOCM_UM_ALLOC Alloc;
    481 } VBOXDISPIFESCAPE_UHGSMI_ALLOCATE, *PVBOXDISPIFESCAPE_UHGSMI_ALLOCATE;
    482 
    483 typedef struct VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE
    484 {
    485     VBOXDISPIFESCAPE EscapeHdr;
    486     VBOXDISP_KMHANDLE hAlloc;
    487 } VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE, *PVBOXDISPIFESCAPE_UHGSMI_DEALLOCATE;
    488 
    489 typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE
    490 {
    491     VBOXDISP_KMHANDLE hAlloc;
    492     VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO Info;
    493 } VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE, *PVBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE;
    494 
    495 typedef struct VBOXDISPIFESCAPE_UHGSMI_SUBMIT
    496 {
    497     VBOXDISPIFESCAPE EscapeHdr;
    498     VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE aBuffers[1];
    499 } VBOXDISPIFESCAPE_UHGSMI_SUBMIT, *PVBOXDISPIFESCAPE_UHGSMI_SUBMIT;
    500 
    501477typedef struct VBOXDISPIFESCAPE_SHRC_REF
    502478{
     
    513489
    514490} VBOXDISPIFESCAPE_SETALLOCHOSTID, *PVBOXDISPIFESCAPE_SETALLOCHOSTID;
    515 
    516 typedef struct VBOXDISPIFESCAPE_CRHGSMICTLCON_CALL
    517 {
    518     VBOXDISPIFESCAPE EscapeHdr;
    519     VBGLIOCHGCMCALL CallInfo;
    520 } VBOXDISPIFESCAPE_CRHGSMICTLCON_CALL, *PVBOXDISPIFESCAPE_CRHGSMICTLCON_CALL;
    521491
    522492#ifdef VBOX_WITH_MESA3D
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/shared/VBoxDispKmt.cpp

    r76553 r80422  
    368368}
    369369
     370/// @todo Used for resize and seamless. Drop crVersion* params.
    370371HRESULT vboxDispKmtCreateContext(PVBOXDISPKMT_DEVICE pDevice, PVBOXDISPKMT_CONTEXT pContext,
    371372                                    VBOXWDDM_CONTEXT_TYPE enmType,
     
    386387    ContextData.pPrivateDriverData = &Info;
    387388    ContextData.PrivateDriverDataSize = sizeof (Info);
    388     ContextData.ClientHint = enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL ? D3DKMT_CLIENTHINT_OPENGL : D3DKMT_CLIENTHINT_DX9;
     389    ContextData.ClientHint = D3DKMT_CLIENTHINT_DX9;
    389390    NTSTATUS Status = pDevice->pAdapter->pCallbacks->pfnD3DKMTCreateContext(&ContextData);
    390391    Assert(!Status);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/Makefile.kmk

    r80405 r80422  
    9292  VBoxWddm_DEFS           += VBOX_WITH_VDMA
    9393 endif
    94  ifdef VBOX_WITH_CRHGSMI
    95   VBoxWddm_DEFS           += VBOX_WITH_CRHGSMI
    96  endif
    9794 VBoxWddm_DEFS            += LOG_TO_BACKDOOR
    9895 VBoxWddm_DEFS            += VBOX_SVN_REV=$(VBOX_SVN_REV)
     
    104101        .. \
    105102        . \
    106         $(VBOX_PATH_CROGL_INCLUDE) \
    107         $(VBOX_PATH_CROGL_GENFILES) \
    108         $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/packer \
    109103        $(VBOX_GRAPHICS_INCS)
    110104
     
    112106 VBoxWddm_LDFLAGS.amd64   += /Entry:DriverEntry
    113107
    114  VBoxWddm_INTERMEDIATES = \
    115         $(VBOX_PATH_CROGL_GENFILES)/cr_packfunctions.h \
    116         $(VBOX_PATH_CROGL_GENFILES)/cr_opcodes.h \
    117         $(VBOX_PATH_CROGL_GENFILES)/state/cr_currentpointers.h \
    118         $(VBOX_PATH_CROGL_GENFILES)/cr_packfunctions.h
    119108 VBoxWddm_SOURCES          = \
    120109        wddm/VBoxMPWddm.cpp \
     
    123112        wddm/VBoxMPShgsmi.cpp \
    124113        wddm/VBoxMPCm.cpp \
    125         wddm/VBoxMPCr.cpp \
    126114        wddm/VBoxMPSa.cpp \
    127115        wddm/VBoxMPMisc.cpp \
     
    139127
    140128 if defined(VBOX_WITH_CROGL)
    141    VBoxWddm_SOURCES       += \
    142         $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/util/vreg.cpp \
    143         $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c \
    144         $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/packer/pack_bounds.c \
    145         $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c \
    146         $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/packer/pack_misc.c \
    147         $(VBOX_PATH_CROGL_GENFILES)/packer.c \
    148         wddm/VBoxMPCrUtil.cpp
    149129   VBoxWddm_DEFS          += VBOX_WITH_CROGL
    150130 endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPDevExt.h

    r76563 r80422  
    146146
    147147   DWORD dwDrvCfgFlags;
    148 #ifdef VBOX_WITH_CROGL
     148
    149149   BOOLEAN f3DEnabled;
    150    BOOLEAN fTexPresentEnabled;
    151150   BOOLEAN fCmdVbvaEnabled;
    152151   BOOLEAN fComplexTopologiesEnabled;
    153152
    154    uint32_t u32CrConDefaultClientID;
    155 
    156153   VBOXCMDVBVA CmdVbva;
    157154
    158    VBOXMP_CRCTLCON CrCtlCon;
    159    VBOXMP_CRSHGSMITRANSPORT CrHgsmiTransport;
    160 #endif
    161155   VBOXWDDM_GLOBAL_POINTER_INFO PointerInfo;
    162156
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.cpp

    r76553 r80422  
    179179    return NULL;
    180180}
    181 #ifdef VBOX_WITH_CROGL
    182 PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainCreate(UINT w, UINT h)
    183 {
    184     PVBOXWDDM_SWAPCHAIN pSwapchain = (PVBOXWDDM_SWAPCHAIN)vboxWddmMemAllocZero(sizeof (VBOXWDDM_SWAPCHAIN));
    185     Assert(pSwapchain);
    186     if (pSwapchain)
    187     {
    188         InitializeListHead(&pSwapchain->AllocList);
    189         pSwapchain->enmState = VBOXWDDM_OBJSTATE_TYPE_INITIALIZED;
    190         pSwapchain->cRefs = 1;
    191         /* init to some invalid value so that the pos get submitted */
    192         pSwapchain->Pos.x = pSwapchain->Pos.y = VBOXWDDM_INVALID_COORD;
    193         pSwapchain->width = w;
    194         pSwapchain->height = h;
    195         VBoxVrListInit(&pSwapchain->VisibleRegions);
    196     }
    197     return pSwapchain;
    198 }
    199 
    200 DECLINLINE(BOOLEAN) vboxWddmSwapchainRetainLocked(PVBOXWDDM_SWAPCHAIN pSwapchain)
    201 {
    202     if (pSwapchain->enmState == VBOXWDDM_OBJSTATE_TYPE_INITIALIZED)
    203     {
    204         ASMAtomicIncU32(&pSwapchain->cRefs);
    205         return TRUE;
    206     }
    207     return FALSE;
    208 }
    209 
    210 BOOLEAN vboxWddmSwapchainRetain(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain)
    211 {
    212     KIRQL OldIrql;
    213     BOOLEAN bRc;
    214     KeAcquireSpinLock(&pDevExt->SynchLock, &OldIrql);
    215     bRc = vboxWddmSwapchainRetainLocked(pSwapchain);
    216     KeReleaseSpinLock(&pDevExt->SynchLock, OldIrql);
    217     return bRc;
    218 }
    219 
    220 VOID vboxWddmSwapchainRelease(PVBOXWDDM_SWAPCHAIN pSwapchain)
    221 {
    222     const uint32_t cRefs = ASMAtomicDecU32(&pSwapchain->cRefs);
    223     Assert(cRefs < UINT32_MAX/2);
    224     if (!cRefs)
    225     {
    226         VBoxVrListClear(&pSwapchain->VisibleRegions);
    227         vboxWddmMemFree(pSwapchain);
    228     }
    229 }
    230 
    231 PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainRetainByAllocData(PVBOXMP_DEVEXT pDevExt, const struct VBOXWDDM_ALLOC_DATA *pAllocData)
    232 {
    233     KIRQL OldIrql;
    234     PVBOXWDDM_SWAPCHAIN pSwapchain;
    235     KeAcquireSpinLock(&pDevExt->SynchLock, &OldIrql);
    236     pSwapchain = pAllocData->pSwapchain;
    237     if (pSwapchain && !vboxWddmSwapchainRetainLocked(pSwapchain))
    238         pSwapchain = NULL;
    239     KeReleaseSpinLock(&pDevExt->SynchLock, OldIrql);
    240     return pSwapchain;
    241 }
    242 
    243 PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainRetainByAlloc(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOCATION *pAlloc)
    244 {
    245     return vboxWddmSwapchainRetainByAllocData(pDevExt, &pAlloc->AllocData);
    246 }
    247 
    248 VOID vboxWddmSwapchainAllocRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc)
    249 {
    250     KIRQL OldIrql;
    251     KeAcquireSpinLock(&pDevExt->SynchLock, &OldIrql);
    252     Assert(pAlloc->AllocData.pSwapchain == pSwapchain);
    253     pAlloc->AllocData.pSwapchain = NULL;
    254     RemoveEntryList(&pAlloc->SwapchainEntry);
    255     KeReleaseSpinLock(&pDevExt->SynchLock, OldIrql);
    256     vboxWddmSwapchainRelease(pSwapchain);
    257 }
    258 
    259 BOOLEAN vboxWddmSwapchainAllocAdd(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc)
    260 {
    261     KIRQL OldIrql;
    262     BOOLEAN bRc;
    263     Assert(!pAlloc->AllocData.pSwapchain);
    264     KeAcquireSpinLock(&pDevExt->SynchLock, &OldIrql);
    265     bRc = vboxWddmSwapchainRetainLocked(pSwapchain);
    266     if (bRc)
    267     {
    268         if (pAlloc->AllocData.pSwapchain)
    269         {
    270             RemoveEntryList(&pAlloc->SwapchainEntry);
    271         }
    272         InsertTailList(&pSwapchain->AllocList, &pAlloc->SwapchainEntry);
    273         pAlloc->AllocData.pSwapchain = pSwapchain;
    274     }
    275     KeReleaseSpinLock(&pDevExt->SynchLock, OldIrql);
    276     return bRc;
    277 }
    278 
    279 #define VBOXSCENTRY_2_ALLOC(_pE) ((PVBOXWDDM_ALLOCATION)((uint8_t*)(_pE) - RT_UOFFSETOF(VBOXWDDM_ALLOCATION, SwapchainEntry)))
    280 
    281 static VOID vboxWddmSwapchainAllocRemoveAllInternal(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, BOOLEAN bOnDestroy)
    282 {
    283     KIRQL OldIrql;
    284     UINT cRemoved = 0;
    285     KeAcquireSpinLock(&pDevExt->SynchLock, &OldIrql);
    286     PLIST_ENTRY pEntry = pSwapchain->AllocList.Flink;
    287     do
    288     {
    289         if (pEntry != &pSwapchain->AllocList)
    290         {
    291             PVBOXWDDM_ALLOCATION pAlloc = VBOXSCENTRY_2_ALLOC(pEntry);
    292             pEntry = pEntry->Flink;
    293             Assert(pAlloc->AllocData.pSwapchain == pSwapchain);
    294             pAlloc->AllocData.pSwapchain = NULL;
    295             RemoveEntryList(&pAlloc->SwapchainEntry);
    296             ++cRemoved;
    297         }
    298         else
    299             break;
    300     } while (1);
    301 
    302     if (bOnDestroy)
    303         pSwapchain->enmState = VBOXWDDM_OBJSTATE_TYPE_TERMINATED;
    304     KeReleaseSpinLock(&pDevExt->SynchLock, OldIrql);
    305 
    306     for (UINT i = 0; i < cRemoved; ++i)
    307         vboxWddmSwapchainRelease(pSwapchain);
    308 }
    309 
    310 VOID vboxWddmSwapchainAllocRemoveAll(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain)
    311 {
    312     vboxWddmSwapchainAllocRemoveAllInternal(pDevExt, pSwapchain, FALSE);
    313 }
    314 
    315 VOID vboxWddmSwapchainDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain)
    316 {
    317     vboxWddmSwapchainAllocRemoveAllInternal(pDevExt, pSwapchain, TRUE);
    318 
    319     vboxWddmSwapchainRelease(pSwapchain);
    320 }
    321 
    322 static BOOLEAN vboxWddmSwapchainCtxAddLocked(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXWDDM_SWAPCHAIN pSwapchain)
    323 {
    324     if (vboxWddmSwapchainRetain(pDevExt, pSwapchain))
    325     {
    326         Assert(!pSwapchain->hSwapchainKm);
    327         Assert(!pSwapchain->pContext);
    328         pSwapchain->pContext = pContext;
    329         pSwapchain->hSwapchainKm = vboxWddmHTablePut(&pContext->Swapchains, pSwapchain);
    330         InsertHeadList(&pDevExt->SwapchainList3D, &pSwapchain->DevExtListEntry);
    331         return TRUE;
    332     }
    333     return FALSE;
    334 }
    335 
    336 static VOID vboxWddmSwapchainCtxRemoveLocked(PVBOXWDDM_CONTEXT pContext, PVBOXWDDM_SWAPCHAIN pSwapchain)
    337 {
    338     Assert(pSwapchain->hSwapchainKm);
    339     Assert(pSwapchain->pContext);
    340     void *pvTst = vboxWddmHTableRemove(&pContext->Swapchains, pSwapchain->hSwapchainKm);
    341     Assert((PVBOXWDDM_SWAPCHAIN)pvTst == pSwapchain); NOREF(pvTst);
    342     RemoveEntryList(&pSwapchain->DevExtListEntry);
    343     pSwapchain->hSwapchainKm = NULL;
    344     VBoxVrListClear(&pSwapchain->VisibleRegions);
    345     vboxWddmSwapchainRelease(pSwapchain);
    346 }
    347 
    348 /* adds the given swapchain to the context's swapchain list
    349  * @return true on success */
    350 BOOLEAN vboxWddmSwapchainCtxAdd(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXWDDM_SWAPCHAIN pSwapchain)
    351 {
    352     BOOLEAN bRc;
    353     VBOXWDDM_CTXLOCK_DATA
    354     VBOXWDDM_CTXLOCK_LOCK(pDevExt);
    355     bRc = vboxWddmSwapchainCtxAddLocked(pDevExt, pContext, pSwapchain);
    356     VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    357     return bRc;
    358 }
    359 
    360 /* removes the given swapchain from the context's swapchain list
    361  * */
    362 VOID vboxWddmSwapchainCtxRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXWDDM_SWAPCHAIN pSwapchain)
    363 {
    364     VBOXWDDM_CTXLOCK_DATA
    365     VBOXWDDM_CTXLOCK_LOCK(pDevExt);
    366     vboxWddmSwapchainCtxRemoveLocked(pContext, pSwapchain);
    367     VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    368 }
    369 
    370 /* destroys all swapchains for the given context
    371  * */
    372 VOID vboxWddmSwapchainCtxDestroyAll(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext)
    373 {
    374     VBOXWDDM_HTABLE_ITERATOR Iter;
    375     VBOXWDDM_CTXLOCK_DATA
    376     do
    377     {
    378         VBOXWDDM_CTXLOCK_LOCK(pDevExt);
    379         vboxWddmHTableIterInit(&pContext->Swapchains, &Iter);
    380         PVBOXWDDM_SWAPCHAIN pSwapchain = (PVBOXWDDM_SWAPCHAIN)vboxWddmHTableIterNext(&Iter, NULL);
    381         if (!pSwapchain)
    382             break;
    383 
    384         /* yes, we can call remove locked even when using iterator */
    385         vboxWddmSwapchainCtxRemoveLocked(pContext, pSwapchain);
    386 
    387         VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    388         /* we must not do vboxWddmSwapchainDestroy inside a context mutex */
    389         vboxWddmSwapchainDestroy(pDevExt, pSwapchain);
    390         /* start from the very beginning, we will quit the loop when no swapchains left */
    391     } while (1);
    392 
    393     /* no swapchains left, we exiteed the while loop via the "break", and we still owning the mutex */
    394     VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    395 }
    396 
    397 /* process the swapchain info passed from user-mode display driver & synchronizes the driver state with it */
    398 NTSTATUS vboxWddmSwapchainCtxEscape(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext,
    399                                     PVBOXDISPIFESCAPE_SWAPCHAININFO pSwapchainInfo, UINT cbSize)
    400 {
    401     if (cbSize < RT_UOFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[0]))
    402     {
    403         WARN(("invalid cbSize1 %d", cbSize));
    404         return STATUS_INVALID_PARAMETER;
    405     }
    406 
    407     if (cbSize < RT_UOFFSETOF_DYN(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[pSwapchainInfo->SwapchainInfo.cAllocs]))
    408     {
    409         WARN(("invalid cbSize2 %d", cbSize));
    410         return STATUS_INVALID_PARAMETER;
    411     }
    412 
    413     if (!pSwapchainInfo->SwapchainInfo.winHostID)
    414     {
    415         WARN(("Zero winHostID specified!"));
    416         return STATUS_INVALID_PARAMETER;
    417     }
    418 
    419     if (!pContext)
    420     {
    421         WARN(("vboxWddmSwapchainCtxEscape: no context specified"));
    422         return STATUS_INVALID_PARAMETER;
    423     }
    424 
    425     PVBOXWDDM_SWAPCHAIN pSwapchain = NULL;
    426     PVBOXWDDM_ALLOCATION *apAlloc = NULL;
    427     Assert(KeGetCurrentIrql() == PASSIVE_LEVEL);
    428     NTSTATUS Status = STATUS_SUCCESS;
    429     VBOXWDDM_CTXLOCK_DATA
    430 
    431     do {
    432         if (pSwapchainInfo->SwapchainInfo.cAllocs)
    433         {
    434             /* ensure we do not overflow the 32bit buffer size value */
    435             if (VBOXWDDM_ARRAY_MAXELEMENTSU32(VBOXWDDM_ALLOCATION) < pSwapchainInfo->SwapchainInfo.cAllocs)
    436             {
    437                 WARN(("number of allocations passed in too big (%d), max is (%d)",
    438                       pSwapchainInfo->SwapchainInfo.cAllocs, VBOXWDDM_ARRAY_MAXELEMENTSU32(VBOXWDDM_ALLOCATION)));
    439                 Status = STATUS_INVALID_PARAMETER;
    440                 break;
    441             }
    442 
    443             apAlloc = (PVBOXWDDM_ALLOCATION *)vboxWddmMemAlloc(  sizeof(PVBOXWDDM_ALLOCATION)
    444                                                                * pSwapchainInfo->SwapchainInfo.cAllocs);
    445             Assert(apAlloc);
    446             if (!apAlloc)
    447             {
    448                 Status = STATUS_NO_MEMORY;
    449                 break;
    450             }
    451             for (UINT i = 0; i < pSwapchainInfo->SwapchainInfo.cAllocs; ++i)
    452             {
    453                 DXGKARGCB_GETHANDLEDATA GhData;
    454                 GhData.hObject = pSwapchainInfo->SwapchainInfo.ahAllocs[i];
    455                 GhData.Type = DXGK_HANDLE_ALLOCATION;
    456                 GhData.Flags.Value = 0;
    457                 PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pDevExt->u.primary.DxgkInterface.DxgkCbGetHandleData(&GhData);
    458                 Assert(pAlloc);
    459                 if (!pAlloc)
    460                 {
    461                     Status = STATUS_INVALID_PARAMETER;
    462                     break;
    463                 }
    464                 apAlloc[i] = pAlloc;
    465             }
    466 
    467             if (!NT_SUCCESS(Status))
    468                 break;
    469         }
    470 
    471         if (pSwapchainInfo->SwapchainInfo.hSwapchainKm)
    472         {
    473             VBOXWDDM_CTXLOCK_LOCK(pDevExt);
    474             pSwapchain = (PVBOXWDDM_SWAPCHAIN)vboxWddmHTableGet(&pContext->Swapchains,
    475                                                                 (VBOXWDDM_HANDLE)pSwapchainInfo->SwapchainInfo.hSwapchainKm);
    476             Assert(pSwapchain);
    477             if (!pSwapchain)
    478             {
    479                 VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    480                 Status = STATUS_INVALID_PARAMETER;
    481                 break;
    482             }
    483             Assert(pSwapchain->hSwapchainKm == pSwapchainInfo->SwapchainInfo.hSwapchainKm);
    484             Assert(pSwapchain->pContext == pContext);
    485             if (pSwapchain->pContext != pContext)
    486             {
    487                 VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    488                 Status = STATUS_INVALID_PARAMETER;
    489                 break;
    490             }
    491         }
    492         else if (pSwapchainInfo->SwapchainInfo.cAllocs)
    493         {
    494             pSwapchain = vboxWddmSwapchainCreate(apAlloc[0]->AllocData.SurfDesc.width, apAlloc[0]->AllocData.SurfDesc.height);
    495             if (!pSwapchain)
    496             {
    497                 Status = STATUS_NO_MEMORY;
    498                 break;
    499             }
    500 
    501             VBOXWDDM_CTXLOCK_LOCK(pDevExt);
    502             BOOLEAN fRc = vboxWddmSwapchainCtxAddLocked(pDevExt, pContext, pSwapchain);
    503             Assert(fRc); NOREF(fRc);
    504         }
    505         else
    506         {
    507             Status = STATUS_INVALID_PARAMETER;
    508             break;
    509         }
    510 
    511         /* do not zero up the view rect since it may still be valid */
    512 //        memset(&pSwapchain->ViewRect, 0, sizeof (pSwapchain->ViewRect));
    513         /** @todo do we really need to zero this up here ? */
    514         VBoxVrListClear(&pSwapchain->VisibleRegions);
    515 
    516         vboxWddmSwapchainAllocRemoveAll(pDevExt, pSwapchain);
    517 
    518         if (pSwapchainInfo->SwapchainInfo.cAllocs)
    519         {
    520             for (UINT i = 0; i < pSwapchainInfo->SwapchainInfo.cAllocs; ++i)
    521             {
    522                 vboxWddmSwapchainAllocAdd(pDevExt, pSwapchain, apAlloc[i]);
    523             }
    524             pSwapchain->hSwapchainUm = pSwapchainInfo->SwapchainInfo.hSwapchainUm;
    525             if (pSwapchain->winHostID != pSwapchainInfo->SwapchainInfo.winHostID)
    526             {
    527                 pSwapchain->fExposed = FALSE;
    528                 pSwapchain->winHostID = pSwapchainInfo->SwapchainInfo.winHostID;
    529             }
    530         }
    531         else
    532         {
    533             vboxWddmSwapchainCtxRemoveLocked(pContext, pSwapchain);
    534         }
    535 
    536         VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    537 
    538         if (pSwapchainInfo->SwapchainInfo.cAllocs)
    539         {
    540             Assert(pSwapchain->pContext);
    541             Assert(pSwapchain->hSwapchainKm);
    542             pSwapchainInfo->SwapchainInfo.hSwapchainKm = pSwapchain->hSwapchainKm;
    543         }
    544         else
    545         {
    546             vboxWddmSwapchainDestroy(pDevExt, pSwapchain);
    547             pSwapchainInfo->SwapchainInfo.hSwapchainKm = 0;
    548         }
    549 
    550         AssertNtStatusSuccess(Status);
    551     } while (0);
    552 
    553     /* cleanup */
    554     if (apAlloc)
    555         vboxWddmMemFree(apAlloc);
    556 
    557     return Status;
    558 }
    559 
    560 NTSTATUS vboxWddmSwapchainCtxInit(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext)
    561 {
    562     RT_NOREF(pDevExt);
    563     NTSTATUS Status = vboxWddmHTableCreate(&pContext->Swapchains, 4);
    564     if (!NT_SUCCESS(Status))
    565     {
    566         WARN(("vboxWddmHTableCreate failes, Status (x%x)", Status));
    567         return Status;
    568     }
    569 
    570     return STATUS_SUCCESS;
    571 }
    572 
    573 VOID vboxWddmSwapchainCtxTerm(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext)
    574 {
    575     vboxWddmSwapchainCtxDestroyAll(pDevExt, pContext);
    576     vboxWddmHTableDestroy(&pContext->Swapchains);
    577 }
    578 #endif
     181
    579182NTSTATUS vboxWddmRegQueryDrvKeyName(PVBOXMP_DEVEXT pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult)
    580183{
     
    1355958}
    1356959
    1357 #ifdef VBOX_WITH_CRHGSMI
    1358 static DECLCALLBACK(VOID) vboxVideoAMgrAllocSubmitCompletion(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext)
    1359 {
    1360     RT_NOREF(pCmd);
    1361     /* we should be called from our DPC routine */
    1362     Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
    1363 
    1364     PVBOXVDMACBUF_DR pDr = (PVBOXVDMACBUF_DR)pvContext;
    1365     VBOXVDMACMD              RT_UNTRUSTED_VOLATILE_HOST *pHdr  = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
    1366     VBOXVDMACMD_CHROMIUM_CMD RT_UNTRUSTED_VOLATILE_HOST *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHROMIUM_CMD);
    1367     UINT cBufs = pBody->cBuffers;
    1368     for (UINT i = 0; i < cBufs; ++i)
    1369     {
    1370         VBOXVDMACMD_CHROMIUM_BUFFER RT_UNTRUSTED_VOLATILE_HOST *pBufCmd = &pBody->aBuffers[i];
    1371         PVBOXVIDEOCM_ALLOC_REF pRef = (PVBOXVIDEOCM_ALLOC_REF)pBufCmd->u64GuestData;
    1372         if (!pBufCmd->u32GuestData)
    1373         {
    1374             /* signal completion */
    1375             if (pRef->pSynchEvent)
    1376                 KeSetEvent(pRef->pSynchEvent, 3, FALSE);
    1377         }
    1378 
    1379         vboxVideoAMgrCtxAllocRefRelease(pRef);
    1380     }
    1381 
    1382     vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
    1383 }
    1384 
    1385 /* submits a set of chromium uhgsmi buffers to host for processing */
    1386 NTSTATUS vboxVideoAMgrCtxAllocSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_CONTEXT pContext, UINT cBuffers,
    1387                                      VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *paBuffers)
    1388 {
    1389     /* ensure we do not overflow the 32bit buffer size value */
    1390     if (VBOXWDDM_TRAILARRAY_MAXELEMENTSU32(VBOXVDMACMD_CHROMIUM_CMD, aBuffers) < cBuffers)
    1391     {
    1392         WARN(("number of buffers passed too big (%d), max is (%d)",
    1393               cBuffers, VBOXWDDM_TRAILARRAY_MAXELEMENTSU32(VBOXVDMACMD_CHROMIUM_CMD, aBuffers)));
    1394         return STATUS_INVALID_PARAMETER;
    1395     }
    1396 
    1397     NTSTATUS Status = STATUS_SUCCESS;
    1398     UINT cbCmd = VBOXVDMACMD_SIZE_FROMBODYSIZE(RT_UOFFSETOF_DYN(VBOXVDMACMD_CHROMIUM_CMD, aBuffers[cBuffers]));
    1399 
    1400     VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr = vboxVdmaCBufDrCreate(&pDevExt->u.primary.Vdma, cbCmd);
    1401     if (pDr)
    1402     {
    1403         // vboxVdmaCBufDrCreate zero initializes the pDr
    1404         pDr->fFlags = VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR;
    1405         pDr->cbBuf = cbCmd;
    1406         pDr->rc = VERR_NOT_IMPLEMENTED;
    1407 
    1408         VBOXVDMACMD RT_UNTRUSTED_VOLATILE_HOST *pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
    1409         pHdr->enmType = VBOXVDMACMD_TYPE_CHROMIUM_CMD;
    1410         pHdr->u32CmdSpecific = 0;
    1411 
    1412         VBOXVDMACMD_CHROMIUM_CMD RT_UNTRUSTED_VOLATILE_HOST *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHROMIUM_CMD);
    1413         pBody->cBuffers = cBuffers;
    1414         for (UINT i = 0; i < cBuffers; ++i)
    1415         {
    1416             VBOXVDMACMD_CHROMIUM_BUFFER RT_UNTRUSTED_VOLATILE_HOST *pBufCmd = &pBody->aBuffers[i];
    1417             VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *pBufInfo = &paBuffers[i];
    1418             PVBOXVIDEOCM_ALLOC_REF pRef = vboxVideoAMgrCtxAllocRefAcquire(pContext, pBufInfo->hAlloc);
    1419             if (pRef)
    1420             {
    1421 #ifdef DEBUG_misha
    1422                 Assert(pRef->cRefs == 2);
    1423 #endif
    1424                 pBufCmd->offBuffer = pRef->pAlloc->offData + pBufInfo->Info.offData;
    1425                 pBufCmd->cbBuffer = pBufInfo->Info.cbData;
    1426                 pBufCmd->u32GuestData = 0;
    1427                 pBufCmd->u64GuestData = (uintptr_t)pRef;
    1428             }
    1429             else
    1430             {
    1431                 WARN(("vboxVideoAMgrCtxAllocRefAcquire failed for hAlloc(0x%x)\n", pBufInfo->hAlloc));
    1432                 /* release all previously acquired aloc references */
    1433                 for (UINT j = 0; j < i; ++j)
    1434                 {
    1435                     VBOXVDMACMD_CHROMIUM_BUFFER RT_UNTRUSTED_VOLATILE_HOST *pBufCmdJ = &pBody->aBuffers[j];
    1436                     PVBOXVIDEOCM_ALLOC_REF pRefJ = (PVBOXVIDEOCM_ALLOC_REF)pBufCmdJ;
    1437                     vboxVideoAMgrCtxAllocRefRelease(pRefJ);
    1438                 }
    1439                 Status = STATUS_INVALID_PARAMETER;
    1440                 break;
    1441             }
    1442         }
    1443 
    1444         if (Status == STATUS_SUCCESS)
    1445         {
    1446             PVBOXVDMADDI_CMD pDdiCmd = VBOXVDMADDI_CMD_FROM_BUF_DR(pDr);
    1447             vboxVdmaDdiCmdInit(pDdiCmd, 0, 0, vboxVideoAMgrAllocSubmitCompletion, (void *)pDr);
    1448             /* mark command as submitted & invisible for the dx runtime since dx did not originate it */
    1449             vboxVdmaDdiCmdSubmittedNotDx(pDdiCmd);
    1450             int rc = vboxVdmaCBufDrSubmit(pDevExt, &pDevExt->u.primary.Vdma, pDr);
    1451             if (RT_SUCCESS(rc))
    1452             {
    1453                 return STATUS_SUCCESS;
    1454             }
    1455 
    1456             WARN(("vboxVdmaCBufDrSubmit failed with rc (%d)\n", rc));
    1457 
    1458             /* failure branch */
    1459             /* release all previously acquired aloc references */
    1460             for (UINT i = 0; i < cBuffers; ++i)
    1461             {
    1462                 VBOXVDMACMD_CHROMIUM_BUFFER RT_UNTRUSTED_VOLATILE_HOST *pBufCmd = &pBody->aBuffers[i];
    1463                 PVBOXVIDEOCM_ALLOC_REF pRef = (PVBOXVIDEOCM_ALLOC_REF)pBufCmd;
    1464                 vboxVideoAMgrCtxAllocRefRelease(pRef);
    1465             }
    1466         }
    1467 
    1468         vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
    1469     }
    1470     else
    1471     {
    1472         Assert(0);
    1473         /** @todo try flushing.. */
    1474         LOGREL(("vboxVdmaCBufDrCreate returned NULL"));
    1475         Status = STATUS_INSUFFICIENT_RESOURCES;
    1476     }
    1477 
    1478     return Status;
    1479 }
    1480 #endif
    1481 
    1482960NTSTATUS vboxVideoAMgrCreate(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr, uint32_t offData, uint32_t cbData)
    1483961{
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.h

    r76563 r80422  
    7272PVOID vboxWddmHTableGet(PVBOXWDDM_HTABLE pTbl, VBOXWDDM_HANDLE hHandle);
    7373
    74 #ifdef VBOX_WITH_CROGL
    75 PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainCreate();
    76 BOOLEAN vboxWddmSwapchainRetain(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
    77 VOID vboxWddmSwapchainRelease(PVBOXWDDM_SWAPCHAIN pSwapchain);
    78 PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainRetainByAlloc(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOCATION *pAlloc);
    79 PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainRetainByAllocData(PVBOXMP_DEVEXT pDevExt, const struct VBOXWDDM_ALLOC_DATA *pAllocData);
    80 VOID vboxWddmSwapchainAllocRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc);
    81 BOOLEAN vboxWddmSwapchainAllocAdd(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc);
    82 VOID vboxWddmSwapchainAllocRemoveAll(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
    83 VOID vboxWddmSwapchainDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
    84 VOID vboxWddmSwapchainCtxDestroyAll(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext);
    85 NTSTATUS vboxWddmSwapchainCtxEscape(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXDISPIFESCAPE_SWAPCHAININFO pSwapchainInfo, UINT cbSize);
    86 NTSTATUS vboxWddmSwapchainCtxInit(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext);
    87 VOID vboxWddmSwapchainCtxTerm(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_CONTEXT pContext);
    88 #endif
    89 
    90 
    9174NTSTATUS vboxWddmRegQueryDisplaySettingsKeyName(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
    9275        ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
     
    155138NTSTATUS vboxVideoAMgrCtxAllocDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, VBOXDISP_KMHANDLE hSesionHandle);
    156139
    157 #ifdef VBOX_WITH_CRHGSMI
    158 NTSTATUS vboxVideoAMgrCtxAllocSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_CONTEXT pContext, UINT cBuffers, VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *paBuffers);
    159 #endif
    160 
    161140VOID vboxWddmSleep(uint32_t u32Val);
    162141VOID vboxWddmCounterU32Wait(uint32_t volatile * pu32, uint32_t u32Val);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPSa.cpp

    r78190 r80422  
    1717 */
    1818
    19 #include <cr_error.h>
     19#include "common/VBoxMPUtils.h"
    2020#include <iprt/err.h>
    2121#include <iprt/mem.h>
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h

    r79746 r80422  
    3535#include "VBoxMPShgsmi.h"
    3636#include "VBoxMPVbva.h"
    37 #include "VBoxMPCr.h"
    3837#include "VBoxMPSa.h"
    3938#include "VBoxMPVModes.h"
    40 
    41 #ifdef VBOX_WITH_CROGL
    42 #include <cr_vreg.h>
    43 #endif
    4439
    4540#if 0
     
    136131    BOOLEAN bVisible;
    137132    BOOLEAN bBlankedByPowerOff;
    138 #ifdef VBOX_WITH_CROGL
    139     /* specifies whether the source has 3D overlay data visible */
    140     BOOLEAN fHas3DVrs;
    141     VBOXVR_LIST VrList;
    142 #endif
    143133    VBOXVBVAINFO Vbva;
    144134#ifdef VBOX_WITH_VIDEOHWACCEL
     
    250240#define VBOXWDDM_INVALID_COORD ((LONG)((~0UL) >> 1))
    251241
    252 #ifdef VBOX_WITH_CROGL
    253 typedef struct VBOXWDDM_SWAPCHAIN
    254 {
    255     LIST_ENTRY DevExtListEntry;
    256     LIST_ENTRY AllocList;
    257     struct VBOXWDDM_CONTEXT *pContext;
    258     VBOXWDDM_OBJSTATE_TYPE enmState;
    259     volatile uint32_t cRefs;
    260     VBOXDISP_UMHANDLE hSwapchainUm;
    261     VBOXDISP_KMHANDLE hSwapchainKm;
    262     int32_t winHostID;
    263     BOOLEAN fExposed;
    264     POINT Pos;
    265     UINT width;
    266     UINT height;
    267     VBOXVR_LIST VisibleRegions;
    268 }VBOXWDDM_SWAPCHAIN, *PVBOXWDDM_SWAPCHAIN;
    269 #endif
    270 
    271242typedef struct VBOXWDDM_CONTEXT
    272243{
     
    277248    UINT  EngineAffinity;
    278249    BOOLEAN fRenderFromShadowDisabled;
    279 #ifdef VBOX_WITH_CROGL
    280     int32_t hostID;
    281     uint32_t u32CrConClientID;
    282     VBOXMP_CRPACKER CrPacker;
    283     VBOXWDDM_HTABLE Swapchains;
    284 #endif
    285250    VBOXVIDEOCM_CTX CmContext;
    286251    VBOXVIDEOCM_ALLOC_CONTEXT AllocContext;
     
    329294    uint32_t bDoNotSignalCompletion;
    330295} VBOXWDDM_UHGSMI_BUFFER_SUBMIT_INFO, *PVBOXWDDM_UHGSMI_BUFFER_SUBMIT_INFO;
    331 
    332 typedef struct VBOXWDDM_DMA_PRIVATEDATA_CHROMIUM_CMD
    333 {
    334     VBOXWDDM_DMA_PRIVATEDATA_BASEHDR Base;
    335     VBOXWDDM_UHGSMI_BUFFER_SUBMIT_INFO aBufInfos[1];
    336 } VBOXWDDM_DMA_PRIVATEDATA_CHROMIUM_CMD, *PVBOXWDDM_DMA_PRIVATEDATA_CHROMIUM_CMD;
    337296
    338297typedef struct VBOXWDDM_DMA_PRIVATEDATA_ALLOCINFO_ON_SUBMIT
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVbva.cpp

    r76553 r80422  
    763763
    764764    pDevExt->u.primary.DxgkInterface.DxgkCbNotifyInterrupt(pDevExt->u.primary.DxgkInterface.DeviceHandle, &notify);
    765 }
    766 
    767 typedef struct VBOXCMDVBVA_NOTIFYPREEMPT_CB
    768 {
    769     PVBOXMP_DEVEXT pDevExt;
    770     VBOXCMDVBVA *pVbva;
    771     int rc;
    772     UINT u32SubmitFenceId;
    773     UINT u32PreemptFenceId;
    774 } VBOXCMDVBVA_NOTIFYPREEMPT_CB;
    775 
    776 static BOOLEAN vboxCmdVbvaDdiNotifyPreemptCb(PVOID pvContext)
    777 {
    778     VBOXCMDVBVA_NOTIFYPREEMPT_CB* pData = (VBOXCMDVBVA_NOTIFYPREEMPT_CB*)pvContext;
    779     PVBOXMP_DEVEXT pDevExt = pData->pDevExt;
    780     VBOXCMDVBVA *pVbva = pData->pVbva;
    781     Assert(pVbva->u32FenceProcessed >= pVbva->u32FenceCompleted);
    782     if (!pData->u32SubmitFenceId || pVbva->u32FenceProcessed == pData->u32SubmitFenceId)
    783     {
    784         vboxCmdVbvaDdiNotifyCompleteIrq(pDevExt, pVbva, pData->u32PreemptFenceId, DXGK_INTERRUPT_DMA_PREEMPTED);
    785 
    786         pDevExt->u.primary.DxgkInterface.DxgkCbQueueDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    787     }
    788     else
    789     {
    790         Assert(pVbva->u32FenceProcessed < pData->u32SubmitFenceId);
    791         Assert(pVbva->cPreempt <= VBOXCMDVBVA_PREEMPT_EL_SIZE);
    792         if (pVbva->cPreempt == VBOXCMDVBVA_PREEMPT_EL_SIZE)
    793         {
    794             WARN(("no more free elements in preempt map"));
    795             pData->rc = VERR_BUFFER_OVERFLOW;
    796             return FALSE;
    797         }
    798         uint32_t iNewEl = (pVbva->iCurPreempt + pVbva->cPreempt) % VBOXCMDVBVA_PREEMPT_EL_SIZE;
    799         Assert(iNewEl < VBOXCMDVBVA_PREEMPT_EL_SIZE);
    800         pVbva->aPreempt[iNewEl].u32SubmitFence = pData->u32SubmitFenceId;
    801         pVbva->aPreempt[iNewEl].u32PreemptFence = pData->u32PreemptFenceId;
    802         ++pVbva->cPreempt;
    803     }
    804 
    805     pData->rc = VINF_SUCCESS;
    806     return TRUE;
    807 }
    808 
    809 static int vboxCmdVbvaDdiNotifyPreempt(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, UINT u32SubmitFenceId, UINT u32PreemptFenceId)
    810 {
    811     VBOXCMDVBVA_NOTIFYPREEMPT_CB Data;
    812     Data.pDevExt = pDevExt;
    813     Data.pVbva = pVbva;
    814     Data.rc = VERR_INTERNAL_ERROR;
    815     Data.u32SubmitFenceId = u32SubmitFenceId;
    816     Data.u32PreemptFenceId = u32PreemptFenceId;
    817     BOOLEAN bDummy;
    818     NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
    819             pDevExt->u.primary.DxgkInterface.DeviceHandle,
    820             vboxCmdVbvaDdiNotifyPreemptCb,
    821             &Data,
    822             0, /* IN ULONG MessageNumber */
    823             &bDummy);
    824     if (!NT_SUCCESS(Status))
    825     {
    826         WARN(("DxgkCbSynchronizeExecution failed Status %#x", Status));
    827         return VERR_GENERAL_FAILURE;
    828     }
    829 
    830     if (!RT_SUCCESS(Data.rc))
    831     {
    832         WARN(("vboxCmdVbvaDdiNotifyPreemptCb failed rc %d", Data.rc));
    833         return Data.rc;
    834     }
    835 
    836     return VINF_SUCCESS;
    837765}
    838766
     
    1058986}
    1059987
    1060 bool VBoxCmdVbvaPreempt(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, uint32_t u32FenceID)
    1061 {
    1062     VBVAEXBUFFERBACKWARDITER Iter;
    1063     VBoxVBVAExBIterInit(&pVbva->Vbva, &Iter);
    1064 
    1065     uint32_t cbBuffer;
    1066     bool fProcessed;
    1067     uint8_t* pu8Cmd;
    1068     uint32_t u32SubmitFence = 0;
    1069 
    1070     /* we can do it right here */
    1071     while ((pu8Cmd = (uint8_t*)VBoxVBVAExBIterNext(&Iter, &cbBuffer, &fProcessed)) != NULL)
    1072     {
    1073         if (*pu8Cmd == VBOXCMDVBVA_OPTYPE_NOP)
    1074             continue;
    1075 
    1076         VBOXCMDVBVA_HDR *pCmd = (VBOXCMDVBVA_HDR*)pu8Cmd;
    1077 
    1078         if (ASMAtomicCmpXchgU8(&pCmd->u8State, VBOXCMDVBVA_STATE_CANCELLED, VBOXCMDVBVA_STATE_SUBMITTED)
    1079                 || pCmd->u8State == VBOXCMDVBVA_STATE_CANCELLED)
    1080             continue;
    1081 
    1082         Assert(pCmd->u8State == VBOXCMDVBVA_STATE_IN_PROGRESS);
    1083 
    1084         u32SubmitFence = pCmd->u2.u32FenceID;
    1085         break;
    1086     }
    1087 
    1088     vboxCmdVbvaDdiNotifyPreempt(pDevExt, pVbva, u32SubmitFence, u32FenceID);
    1089 
    1090     return false;
    1091 }
    1092 
    1093988bool VBoxCmdVbvaCheckCompletedIrq(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva)
    1094989{
     
    11641059}
    11651060
    1166 uint32_t VBoxCmdVbvaCheckCompleted(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, bool fPingHost, uint32_t *pu32FenceSubmitted, uint32_t *pu32FenceProcessed)
    1167 {
    1168     return vboxCmdVbvaCheckCompleted(pDevExt, pVbva, fPingHost, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx, false /* fBufferOverflow */, pu32FenceSubmitted, pu32FenceProcessed);
    1169 }
    1170 
    11711061#if 0
    11721062static uint32_t vboxCVDdiSysMemElBuild(VBOXCMDVBVA_SYSMEMEL *pEl, PMDL pMdl, uint32_t iPfn, uint32_t cPages)
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVbva.h

    r76563 r80422  
    212212void VBoxCmdVbvaSubmitUnlock(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, VBOXCMDVBVA_HDR* pCmd, uint32_t u32FenceID);
    213213VBOXCMDVBVA_HDR* VBoxCmdVbvaSubmitLock(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, uint32_t cbCmd);
    214 bool VBoxCmdVbvaPreempt(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, uint32_t u32FenceID);
    215 uint32_t VBoxCmdVbvaCheckCompleted(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, bool fPingHost, uint32_t *pu32FenceSubmitted, uint32_t *pu32FenceProcessed);
    216214bool VBoxCmdVbvaCheckCompletedIrq(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva);
    217215
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.cpp

    r76553 r80422  
    2121#include "VBoxMPVhwa.h"
    2222#include <iprt/asm.h>
    23 #include "VBoxMPCr.h"
    2423#include <iprt/mem.h>
    25 
    26 #ifdef VBOX_WITH_CROGL
    27 # include <packer.h>
    28 #endif
    2924
    3025static NTSTATUS vboxVdmaCrCtlGetDefaultClientId(PVBOXMP_DEVEXT pDevExt, uint32_t *pu32ClienID);
     
    266261    return true;
    267262}
    268 #ifdef VBOX_WITH_CROGL
    269 NTSTATUS vboxVdmaPostHideSwapchain(PVBOXWDDM_SWAPCHAIN pSwapchain)
    270 {
    271     Assert(KeGetCurrentIrql() < DISPATCH_LEVEL);
    272     uint32_t cbCmdInternal = VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(0);
    273     PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal =
    274             (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)vboxVideoCmCmdCreate(&pSwapchain->pContext->CmContext, cbCmdInternal);
    275     Assert(pCmdInternal);
    276     if (pCmdInternal)
    277     {
    278         pCmdInternal->hSwapchainUm = pSwapchain->hSwapchainUm;
    279         pCmdInternal->Cmd.fFlags.Value = 0;
    280         pCmdInternal->Cmd.fFlags.bAddHiddenRects = 1;
    281         pCmdInternal->Cmd.fFlags.bHide = 1;
    282         pCmdInternal->Cmd.RectsInfo.cRects = 0;
    283         vboxVideoCmCmdSubmit(pCmdInternal, VBOXVIDEOCM_SUBMITSIZE_DEFAULT);
    284         return STATUS_SUCCESS;
    285     }
    286     return STATUS_NO_MEMORY;
    287 }
    288 #endif
     263
    289264static VOID vboxWddmBltPipeRectsTranslate(VBOXVDMAPIPE_RECTS *pRects, int x, int y)
    290265{
     
    309284    return pDup;
    310285}
    311 #ifdef VBOX_WITH_CROGL
    312 typedef struct VBOXMP_VDMACR_WRITECOMPLETION
    313 {
    314     void *pvBufferToFree;
    315 } VBOXMP_VDMACR_WRITECOMPLETION, *PVBOXMP_VDMACR_WRITECOMPLETION;
    316 
    317 static DECLCALLBACK(void) vboxVdmaCrWriteCompletion(PVBOXMP_CRSHGSMITRANSPORT pCon, int rc, void RT_UNTRUSTED_VOLATILE_HOST *pvCtx)
    318 {
    319     RT_NOREF(rc);
    320     PVBOXMP_VDMACR_WRITECOMPLETION pData = (PVBOXMP_VDMACR_WRITECOMPLETION)pvCtx;
    321     void *pvBufferToFree = pData->pvBufferToFree;
    322     if (pvBufferToFree)
    323         VBoxMpCrShgsmiTransportBufFree(pCon, pvBufferToFree);
    324 
    325     VBoxMpCrShgsmiTransportCmdTermWriteAsync(pCon, pvCtx);
    326 }
    327 
    328 typedef struct VBOXMP_VDMACR_WRITEREADCOMPLETION
    329 {
    330     void RT_UNTRUSTED_VOLATILE_HOST *pvBufferToFree;
    331     void RT_UNTRUSTED_VOLATILE_HOST *pvContext;
    332 } VBOXMP_VDMACR_WRITEREADCOMPLETION, *PVBOXMP_VDMACR_WRITEREADCOMPLETION;
    333 
    334 void vboxVdmaCrSubmitWriteReadAsyncGenericCompletion(PVBOXMP_CRSHGSMITRANSPORT pCon, void RT_UNTRUSTED_VOLATILE_HOST *pvCtx)
    335 {
    336     VBOXMP_VDMACR_WRITEREADCOMPLETION RT_UNTRUSTED_VOLATILE_HOST *pData
    337         = (VBOXMP_VDMACR_WRITEREADCOMPLETION RT_UNTRUSTED_VOLATILE_HOST *)pvCtx;
    338     void RT_UNTRUSTED_VOLATILE_HOST *pvBufferToFree = pData->pvBufferToFree;
    339     if (pvBufferToFree)
    340         VBoxMpCrShgsmiTransportBufFree(pCon, pvBufferToFree);
    341 
    342     VBoxMpCrShgsmiTransportCmdTermWriteReadAsync(pCon, pvCtx);
    343 }
    344 
    345 static NTSTATUS vboxVdmaCrSubmitWriteReadAsync(PVBOXMP_DEVEXT pDevExt, VBOXMP_CRPACKER *pCrPacker, uint32_t u32CrConClientID,
    346                                                PFNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEREADASYNC_COMPLETION pfnCompletion,
    347                                                void RT_UNTRUSTED_VOLATILE_HOST *pvCompletion)
    348 {
    349     Assert(u32CrConClientID);
    350     NTSTATUS Status = STATUS_SUCCESS;
    351     uint32_t cbBuffer;
    352     void * pvPackBuffer;
    353     void * pvBuffer = VBoxMpCrPackerTxBufferComplete(pCrPacker, &cbBuffer, &pvPackBuffer);
    354     if (pvBuffer)
    355     {
    356         VBOXMP_VDMACR_WRITEREADCOMPLETION RT_UNTRUSTED_VOLATILE_HOST *pCompletionData
    357             = (VBOXMP_VDMACR_WRITEREADCOMPLETION RT_UNTRUSTED_VOLATILE_HOST  *)
    358               VBoxMpCrShgsmiTransportCmdCreateWriteReadAsync(&pDevExt->CrHgsmiTransport, u32CrConClientID, pvBuffer, cbBuffer,
    359                                                              pfnCompletion, sizeof(*pCompletionData));
    360         if (pCompletionData)
    361         {
    362             pCompletionData->pvBufferToFree = pvPackBuffer;
    363             pCompletionData->pvContext = pvCompletion;
    364             int rc = VBoxMpCrShgsmiTransportCmdSubmitWriteReadAsync(&pDevExt->CrHgsmiTransport, pCompletionData);
    365             if (RT_SUCCESS(rc))
    366             {
    367                 return STATUS_SUCCESS;
    368             }
    369             WARN(("VBoxMpCrShgsmiTransportCmdSubmitWriteReadAsync failed, rc %d", rc));
    370             Status = STATUS_UNSUCCESSFUL;
    371             VBoxMpCrShgsmiTransportCmdTermWriteReadAsync(&pDevExt->CrHgsmiTransport, pCompletionData);
    372         }
    373         else
    374         {
    375             WARN(("VBoxMpCrShgsmiTransportCmdCreateWriteReadAsync failed"));
    376             Status = STATUS_INSUFFICIENT_RESOURCES;
    377         }
    378     }
    379 
    380     return Status;
    381 }
    382 
    383 NTSTATUS vboxVdmaCrSubmitWriteAsync(PVBOXMP_DEVEXT pDevExt, VBOXMP_CRPACKER *pCrPacker, uint32_t u32CrConClientID)
    384 {
    385     Assert(u32CrConClientID);
    386     NTSTATUS Status = STATUS_SUCCESS;
    387     uint32_t cbBuffer;
    388     void * pvPackBuffer;
    389     void * pvBuffer = VBoxMpCrPackerTxBufferComplete(pCrPacker, &cbBuffer, &pvPackBuffer);
    390     if (pvBuffer)
    391     {
    392         VBOXMP_VDMACR_WRITECOMPLETION RT_UNTRUSTED_VOLATILE_HOST *pCompletionData
    393             = (VBOXMP_VDMACR_WRITECOMPLETION RT_UNTRUSTED_VOLATILE_HOST *)
    394               VBoxMpCrShgsmiTransportCmdCreateWriteAsync(&pDevExt->CrHgsmiTransport, u32CrConClientID, pvBuffer, cbBuffer,
    395                                                          vboxVdmaCrWriteCompletion, sizeof(*pCompletionData));
    396         if (pCompletionData)
    397         {
    398             pCompletionData->pvBufferToFree = pvPackBuffer;
    399             int rc = VBoxMpCrShgsmiTransportCmdSubmitWriteAsync(&pDevExt->CrHgsmiTransport, pCompletionData);
    400             if (RT_SUCCESS(rc))
    401             {
    402                 return STATUS_SUCCESS;
    403             }
    404             WARN(("VBoxMpCrShgsmiTransportCmdSubmitWriteAsync failed, rc %d", rc));
    405             Status = STATUS_UNSUCCESSFUL;
    406             VBoxMpCrShgsmiTransportCmdTermWriteAsync(&pDevExt->CrHgsmiTransport, pCompletionData);
    407         }
    408         else
    409         {
    410             WARN(("VBoxMpCrShgsmiTransportCmdCreateWriteAsync failed"));
    411             Status = STATUS_INSUFFICIENT_RESOURCES;
    412         }
    413     }
    414 
    415     return Status;
    416 }
    417 
    418 static NTSTATUS vboxVdmaVRegGet(PVBOXWDDM_SWAPCHAIN pSwapchain, const RTRECT *pCtxRect, uint32_t *pcVRects, RTRECT **ppVRectsBuff, uint32_t *pcVRectsBuff)
    419 {
    420     RTRECT *pVRectsBuff = *ppVRectsBuff;
    421     uint32_t cVRectsBuff = *pcVRectsBuff;
    422     uint32_t cVRects = VBoxVrListRectsCount(&pSwapchain->VisibleRegions);
    423     if (cVRectsBuff < cVRects)
    424     {
    425         if (pVRectsBuff)
    426             vboxWddmMemFree(pVRectsBuff);
    427         pVRectsBuff = (RTRECT*)vboxWddmMemAlloc(cVRects * sizeof (pVRectsBuff[0]));
    428         if (!pVRectsBuff)
    429         {
    430             WARN(("vboxWddmMemAlloc failed"));
    431             *pcVRectsBuff = 0;
    432             *ppVRectsBuff = NULL;
    433             *pcVRects = NULL;
    434             return STATUS_NO_MEMORY;
    435         }
    436 
    437         cVRectsBuff = cVRects;
    438         *pcVRectsBuff = cVRectsBuff;
    439         *ppVRectsBuff = pVRectsBuff;
    440     }
    441 
    442     int rc = VBoxVrListRectsGet(&pSwapchain->VisibleRegions, cVRects, pVRectsBuff);
    443     AssertRC(rc);
    444     if (pCtxRect->xLeft || pCtxRect->yTop)
    445     {
    446         for (UINT i = 0; i < cVRects; ++i)
    447         {
    448             VBoxRectTranslate(&pVRectsBuff[i], -pCtxRect->xLeft, -pCtxRect->yTop);
    449         }
    450     }
    451 
    452     *pcVRects = cVRects;
    453     return STATUS_SUCCESS;
    454 }
    455 
    456 
    457 /**
    458  * @param pDevExt
    459  */
    460 static NTSTATUS vboxVdmaProcessVRegCmdLegacy(PVBOXMP_DEVEXT pDevExt,
    461         VBOXMP_CRPACKER *pCrPacker,
    462         uint32_t u32CrConClientID,
    463         PVBOXWDDM_SOURCE pSource,
    464         PVBOXWDDM_SWAPCHAIN pSwapchain,
    465         const RECT *pSrcRect,
    466         const VBOXVDMAPIPE_RECTS *pContextRects)
    467 {
    468     VBOXVDMAPIPE_RECTS *pRectsToFree = NULL;
    469     POINT pos = pSource->VScreenPos;
    470     if (pos.x || pos.y)
    471     {
    472         pRectsToFree = vboxWddmBltPipeRectsDup(pContextRects);
    473         /* note: do NOT translate the src rect since it is used for screen pos calculation */
    474         vboxWddmBltPipeRectsTranslate(pRectsToFree, pos.x, pos.y);
    475         pContextRects = pRectsToFree;
    476     }
    477     const VBOXWDDM_RECTS_INFO *pRects = &pContextRects->UpdateRects;
    478     NTSTATUS Status = STATUS_SUCCESS;
    479     int rc;
    480     bool fCurChanged = FALSE;
    481     bool fCurRectChanged = FALSE;
    482     POINT CurPos = { 0, 0 }; /* MSC is confused (me too), maybe used uninitialized. */
    483     RTRECT *pVRectsBuff = NULL;
    484     uint32_t cVRectsBuff = 0;
    485     VBOXWDDM_CTXLOCK_DATA
    486 
    487     VBOXWDDM_CTXLOCK_LOCK(pDevExt);
    488 
    489     if (pSwapchain)
    490     {
    491         CurPos.x = pContextRects->ContextRect.left - pSrcRect->left;
    492         CurPos.y = pContextRects->ContextRect.top - pSrcRect->top;
    493 
    494         if (CurPos.x != pSwapchain->Pos.x || CurPos.y != pSwapchain->Pos.y)
    495         {
    496 #if 0
    497             if (pSwapchain->Pos.x != VBOXWDDM_INVALID_COORD)
    498                 VBoxVrListTranslate(&pSwapchain->VisibleRegions, pSwapchain->Pos.x - CurPos.x, pSwapchain->Pos.y - CurPos.y);
    499             else
    500 #endif
    501                 VBoxVrListClear(&pSwapchain->VisibleRegions);
    502             fCurRectChanged = TRUE;
    503             pSwapchain->Pos = CurPos;
    504         }
    505 
    506         rc = VBoxVrListRectsAdd(&pSwapchain->VisibleRegions, pRects->cRects, (const RTRECT*)pRects->aRects, &fCurChanged);
    507         if (!RT_SUCCESS(rc))
    508         {
    509             WARN(("VBoxWddmVrListRectsAdd failed, rc %d!", rc));
    510             Status = STATUS_UNSUCCESSFUL;
    511             goto done;
    512         }
    513 
    514 
    515         /* visible rects of different windows do not intersect,
    516          * so if the given window visible rects did not increase, others have not changed either */
    517         if (!fCurChanged && !fCurRectChanged)
    518             goto done;
    519     }
    520 
    521     /* before posting the add visible rects diff, we need to first hide rects for other windows */
    522 
    523     for (PLIST_ENTRY pCur = pDevExt->SwapchainList3D.Flink; pCur != &pDevExt->SwapchainList3D; pCur = pCur->Flink)
    524     {
    525         if (pCur != &pSwapchain->DevExtListEntry)
    526         {
    527             PVBOXWDDM_SWAPCHAIN pCurSwapchain = VBOXWDDMENTRY_2_SWAPCHAIN(pCur);
    528             PVBOXWDDM_CONTEXT pCurContext = pCurSwapchain->pContext;
    529             PVBOXMP_CRPACKER pCurPacker = &pCurContext->CrPacker;
    530             bool fChanged = FALSE;
    531 
    532             rc = VBoxVrListRectsSubst(&pCurSwapchain->VisibleRegions, pRects->cRects, (const RTRECT*)pRects->aRects, &fChanged);
    533             if (!RT_SUCCESS(rc))
    534             {
    535                 WARN(("VBoxWddmVrListRectsAdd failed, rc %d!", rc));
    536                 Status = STATUS_UNSUCCESSFUL;
    537                 goto done;
    538             }
    539 
    540             if (!fChanged)
    541                 continue;
    542 
    543             uint32_t cVRects;
    544             RTRECT CurCtxRect;
    545             CurCtxRect.xLeft = pCurSwapchain->Pos.x;
    546             CurCtxRect.yTop = pCurSwapchain->Pos.y;
    547             CurCtxRect.xRight = CurCtxRect.xLeft + pCurSwapchain->width;
    548             CurCtxRect.yBottom = CurCtxRect.yTop + pCurSwapchain->height;
    549             Status = vboxVdmaVRegGet(pCurSwapchain, &CurCtxRect, &cVRects, &pVRectsBuff, &cVRectsBuff);
    550             if (!NT_SUCCESS(Status))
    551             {
    552                 WARN(("vboxVdmaVRegGet Status 0x%x", Status));
    553                 goto done;
    554             }
    555 
    556             ;
    557             uint32_t cbCommandBuffer = VBOXMP_CRCMD_HEADER_SIZE
    558                                      + VBOXMP_CRCMD_SIZE_WINDOWVISIBLEREGIONS(cVRects);
    559             void RT_UNTRUSTED_VOLATILE_HOST *pvCommandBuffer = VBoxMpCrShgsmiTransportBufAlloc(&pDevExt->CrHgsmiTransport,
    560                                                                                                cbCommandBuffer);
    561             if (!pvCommandBuffer)
    562             {
    563                 WARN(("VBoxMpCrShgsmiTransportBufAlloc failed!"));
    564                 Status = VERR_OUT_OF_RESOURCES;
    565                 goto done;
    566             }
    567 
    568             VBoxMpCrPackerTxBufferInit(pCurPacker, pvCommandBuffer, cbCommandBuffer, 1);
    569 
    570             Assert(pCurSwapchain->winHostID);
    571             crPackWindowVisibleRegion(&pCurPacker->CrPacker, pCurSwapchain->winHostID, cVRects, (GLint*)pVRectsBuff);
    572 
    573             Status = vboxVdmaCrSubmitWriteAsync(pDevExt, pCurPacker, pCurContext->u32CrConClientID);
    574             if (!NT_SUCCESS(Status))
    575             {
    576                 WARN(("vboxVdmaCrSubmitWriteAsync failed Status 0x%x", Status));
    577                 VBoxMpCrShgsmiTransportBufFree(&pDevExt->CrHgsmiTransport, pvCommandBuffer);
    578             }
    579         }
    580     }
    581 
    582     if (!pSwapchain)
    583         goto done;
    584 
    585     uint32_t cbCommandBuffer = VBOXMP_CRCMD_HEADER_SIZE, cCommands = 0;
    586 
    587     uint32_t cVRects;
    588     Status = vboxVdmaVRegGet(pSwapchain, (const RTRECT *)&pContextRects->ContextRect, &cVRects, &pVRectsBuff, &cVRectsBuff);
    589     if (!NT_SUCCESS(Status))
    590     {
    591         WARN(("vboxVdmaVRegGet Status 0x%x", Status));
    592         goto done;
    593     }
    594 
    595     ++cCommands;
    596     cbCommandBuffer += VBOXMP_CRCMD_SIZE_WINDOWVISIBLEREGIONS(cVRects);
    597 
    598     if (fCurRectChanged && fCurChanged)
    599     {
    600         ++cCommands;
    601         cbCommandBuffer += VBOXMP_CRCMD_SIZE_WINDOWPOSITION;
    602     }
    603 
    604     if (!pSwapchain->fExposed)
    605     {
    606         ++cCommands;
    607         cbCommandBuffer += VBOXMP_CRCMD_SIZE_WINDOWSHOW;
    608         ++cCommands;
    609         cbCommandBuffer += VBOXMP_CRCMD_SIZE_WINDOWSIZE;
    610     }
    611 
    612     void RT_UNTRUSTED_VOLATILE_HOST *pvCommandBuffer = VBoxMpCrShgsmiTransportBufAlloc(&pDevExt->CrHgsmiTransport, cbCommandBuffer);
    613     if (!pvCommandBuffer)
    614     {
    615         WARN(("VBoxMpCrShgsmiTransportBufAlloc failed!"));
    616         Status = STATUS_INSUFFICIENT_RESOURCES;
    617         goto done;
    618     }
    619 
    620     VBoxMpCrPackerTxBufferInit(pCrPacker, pvCommandBuffer, cbCommandBuffer, cCommands);
    621 
    622     Assert(pSwapchain->winHostID);
    623 
    624     if (fCurRectChanged && fCurChanged)
    625         crPackWindowPosition(&pCrPacker->CrPacker, pSwapchain->winHostID, CurPos.x, CurPos.y);
    626 
    627     if (!pSwapchain->fExposed)
    628     {
    629         crPackWindowSize(&pCrPacker->CrPacker, pSwapchain->winHostID, pSwapchain->width, pSwapchain->height);
    630         crPackWindowShow(&pCrPacker->CrPacker, pSwapchain->winHostID, TRUE);
    631         pSwapchain->fExposed = TRUE;
    632     }
    633 
    634     crPackWindowVisibleRegion(&pCrPacker->CrPacker, pSwapchain->winHostID, cVRects, (GLint*)pVRectsBuff);
    635 
    636     Status = vboxVdmaCrSubmitWriteAsync(pDevExt, pCrPacker, u32CrConClientID);
    637     if (!NT_SUCCESS(Status))
    638     {
    639         WARN(("vboxVdmaCrSubmitWriteAsync failed Status 0x%x", Status));
    640         VBoxMpCrShgsmiTransportBufFree(&pDevExt->CrHgsmiTransport, pvCommandBuffer);
    641     }
    642 
    643 done:
    644     VBOXWDDM_CTXLOCK_UNLOCK(pDevExt);
    645 
    646     if (pRectsToFree)
    647         vboxWddmMemFree(pRectsToFree);
    648 
    649     if (pVRectsBuff)
    650         vboxWddmMemFree(pVRectsBuff);
    651 
    652     return Status;
    653 }
    654 #endif
    655286
    656287static NTSTATUS vboxVdmaGgDmaColorFill(PVBOXMP_DEVEXT pDevExt, VBOXVDMA_CLRFILL *pCF)
     
    878509}
    879510
    880 #ifdef VBOX_WITH_CROGL
    881 typedef struct VBOXVDMA_CRRXGENERICSYNC
    882 {
    883     int rc;
    884     KEVENT Event;
    885 } VBOXVDMA_CRRXGENERICSYNC, *PVBOXVDMA_CRRXGENERICSYNC;
    886 
    887 /** @callback_method_impl{PFNVBOXMP_CRSHGSMITRANSPORT_SENDWRITEREADASYNC_COMPLETION}   */
    888 static DECLCALLBACK(void) vboxVdmaCrRxGenericSyncCompletion(PVBOXMP_CRSHGSMITRANSPORT pCon, int rc,
    889                                                             void RT_UNTRUSTED_VOLATILE_HOST *pvRx, uint32_t cbRx,
    890                                                             void RT_UNTRUSTED_VOLATILE_HOST *pvCtx)
    891 {
    892     VBOXMP_VDMACR_WRITEREADCOMPLETION RT_UNTRUSTED_VOLATILE_HOST *pCompletionData
    893         = (VBOXMP_VDMACR_WRITEREADCOMPLETION RT_UNTRUSTED_VOLATILE_HOST *)pvCtx;
    894     PVBOXVDMA_CRRXGENERICSYNC pData = (PVBOXVDMA_CRRXGENERICSYNC)pCompletionData->pvContext;
    895     if (RT_SUCCESS(rc))
    896     {
    897         rc = VBoxMpCrCmdRxHandler((CRMessageHeader *)pvRx, cbRx);
    898         if (!RT_SUCCESS(rc))
    899         {
    900             WARN(("VBoxMpCrCmdRxHandler failed %d", rc));
    901         }
    902     }
    903     else
    904     {
    905         WARN(("rx failure %d", rc));
    906     }
    907 
    908     pData->rc = rc;
    909 
    910     KeSetEvent(&pData->Event, 0, FALSE);
    911 
    912     vboxVdmaCrSubmitWriteReadAsyncGenericCompletion(pCon, pvCtx);
    913 }
    914 
    915 NTSTATUS vboxVdmaCrRxGenericSync(PVBOXMP_DEVEXT pDevExt, VBOXMP_CRPACKER *pCrPacker, uint32_t u32CrConClientID)
    916 {
    917     VBOXVDMA_CRRXGENERICSYNC Data;
    918     Data.rc = VERR_NOT_SUPPORTED;
    919     KeInitializeEvent(&Data.Event, SynchronizationEvent, FALSE);
    920     NTSTATUS Status = vboxVdmaCrSubmitWriteReadAsync(pDevExt, pCrPacker, u32CrConClientID, vboxVdmaCrRxGenericSyncCompletion, &Data);
    921     if (!NT_SUCCESS(Status))
    922     {
    923         WARN(("vboxVdmaCrSubmitWriteAsync failed Status 0x%x", Status));
    924         return Status;
    925     }
    926 
    927      Status = KeWaitForSingleObject(&Data.Event, Executive, KernelMode, FALSE, NULL /* PLARGE_INTEGER Timeout */);
    928      if (!NT_SUCCESS(Status))
    929      {
    930          WARN(("KeWaitForSingleObject failed Status 0x%x", Status));
    931          return Status;
    932      }
    933 
    934      return STATUS_SUCCESS;
    935 }
    936 
    937 typedef struct VBOXMP_CRHGSMIMGR
    938 {
    939     VBOXMP_CRPACKER CrPacker;
    940     void RT_UNTRUSTED_VOLATILE_HOST *pvCommandBuffer;
    941 } VBOXMP_CRHGSMIMGR;
    942 
    943 DECLINLINE(CRPackContext*) vboxVdmaCrHmGetPackContext(VBOXMP_CRHGSMIMGR *pMgr)
    944 {
    945     return &pMgr->CrPacker.CrPacker;
    946 }
    947 
    948 NTSTATUS vboxVdmaCrHmCreate(PVBOXMP_DEVEXT pDevExt, VBOXMP_CRHGSMIMGR *pMgr, uint32_t cbCommandBuffer, uint32_t cCommands)
    949 {
    950     pMgr->pvCommandBuffer = VBoxMpCrShgsmiTransportBufAlloc(&pDevExt->CrHgsmiTransport, cbCommandBuffer);
    951     if (!pMgr->pvCommandBuffer)
    952     {
    953         WARN(("VBoxMpCrShgsmiTransportBufAlloc failed!"));
    954         return VERR_OUT_OF_RESOURCES;
    955     }
    956 
    957     VBoxMpCrPackerInit(&pMgr->CrPacker);
    958 
    959     VBoxMpCrPackerTxBufferInit(&pMgr->CrPacker, pMgr->pvCommandBuffer, cbCommandBuffer, cCommands);
    960 
    961     return STATUS_SUCCESS;
    962 }
    963 
    964 NTSTATUS vboxVdmaCrHmSubmitWrSync(PVBOXMP_DEVEXT pDevExt, VBOXMP_CRHGSMIMGR *pMgr, uint32_t u32CrConClientID)
    965 {
    966     NTSTATUS Status = vboxVdmaCrRxGenericSync(pDevExt, &pMgr->CrPacker, u32CrConClientID);
    967     if (!NT_SUCCESS(Status))
    968     {
    969         WARN(("vboxVdmaCrRxGenericSync failed Status 0x%x", Status));
    970         VBoxMpCrShgsmiTransportBufFree(&pDevExt->CrHgsmiTransport, pMgr->pvCommandBuffer);
    971         return Status;
    972     }
    973 
    974     return STATUS_SUCCESS;
    975 }
    976 #if 0
    977 NTSTATUS vboxVdmaCrCmdGetChromiumParametervCR(PVBOXMP_DEVEXT pDevExt, uint32_t u32CrConClientID, GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid * values)
    978 {
    979     uint32_t cbCommandBuffer = VBOXMP_CRCMD_HEADER_SIZE + VBOXMP_CRCMD_SIZE_GETCHROMIUMPARAMETERVCR;
    980     uint32_t cCommands = 1;
    981 
    982     VBOXMP_CRHGSMIMGR Mgr;
    983     NTSTATUS Status = vboxVdmaCrHmCreate(pDevExt, &Mgr, cbCommandBuffer, cCommands);
    984     if (!NT_SUCCESS(Status))
    985     {
    986         WARN(("vboxVdmaCrHmCreate failed Status 0x%x", Status));
    987         return Status;
    988     }
    989 
    990     int dummy = 1;
    991 
    992     crPackGetChromiumParametervCR(vboxVdmaCrHmGetPackContext(&Mgr), target, index, type, count, values, &dummy);
    993 
    994     Status = vboxVdmaCrHmSubmitWrSync(pDevExt, &Mgr, u32CrConClientID);
    995     if (!NT_SUCCESS(Status))
    996     {
    997         WARN(("vboxVdmaCrHmSubmitWrSync failed Status 0x%x", Status));
    998         return Status;
    999     }
    1000 
    1001     return STATUS_SUCCESS;
    1002 }
    1003 
    1004 static NTSTATUS vboxVdmaCrCmdCreateContext(PVBOXMP_DEVEXT pDevExt, int32_t visualBits, int32_t *pi32CtxID)
    1005 {
    1006     uint32_t cbCommandBuffer = VBOXMP_CRCMD_HEADER_SIZE + VBOXMP_CRCMD_SIZE_CREATECONTEXT;
    1007     uint32_t cCommands = 1;
    1008 
    1009     VBOXMP_CRHGSMIMGR Mgr;
    1010     NTSTATUS Status = vboxVdmaCrHmCreate(pDevExt, &Mgr, cbCommandBuffer, cCommands);
    1011     if (!NT_SUCCESS(Status))
    1012     {
    1013         WARN(("vboxVdmaCrHmCreate failed Status 0x%x", Status));
    1014         return Status;
    1015     }
    1016 
    1017     int dummy = 1;
    1018 
    1019     crPackCreateContext(&CrPacker.CrPacker, "", visualBits, 0, &pi32CtxID, &dummy);
    1020 
    1021     Status = vboxVdmaCrHmSubmitWrSync(pDevExt, &Mgr, u32CrConClientID);
    1022     if (!NT_SUCCESS(Status))
    1023     {
    1024         WARN(("vboxVdmaCrHmSubmitWrSync failed Status 0x%x", Status));
    1025         return Status;
    1026     }
    1027 
    1028     return STATUS_SUCCESS;
    1029 }
    1030 
    1031 static NTSTATUS vboxVdmaCrCmdWindowCreate(PVBOXMP_DEVEXT pDevExt, int32_t visualBits, int32_t *pi32WinID)
    1032 {
    1033     uint32_t cbCommandBuffer = VBOXMP_CRCMD_HEADER_SIZE + VBOXMP_CRCMD_SIZE_WINDOWCREATE;
    1034     uint32_t cCommands = 1;
    1035 
    1036     VBOXMP_CRHGSMIMGR Mgr;
    1037     NTSTATUS Status = vboxVdmaCrHmCreate(pDevExt, &Mgr, cbCommandBuffer, cCommands);
    1038     if (!NT_SUCCESS(Status))
    1039     {
    1040         WARN(("vboxVdmaCrHmCreate failed Status 0x%x", Status));
    1041         return Status;
    1042     }
    1043 
    1044     int dummy = 1;
    1045 
    1046     crPackWindowCreate(&CrPacker.CrPacker, "", visualBits, 0, &pi32CtxID, &dummy);
    1047 
    1048     Status = vboxVdmaCrHmSubmitWrSync(pDevExt, &Mgr, u32CrConClientID);
    1049     if (!NT_SUCCESS(Status))
    1050     {
    1051         WARN(("vboxVdmaCrHmSubmitWrSync failed Status 0x%x", Status));
    1052         return Status;
    1053     }
    1054 
    1055     return STATUS_SUCCESS;
    1056 }
    1057 
    1058 static NTSTATUS vboxVdmaCrCtlGetDefaultCtxId(PVBOXMP_DEVEXT pDevExt, int32_t *pi32CtxID)
    1059 {
    1060     if (!pDevExt->i32CrConDefaultCtxID)
    1061     {
    1062         if (!pDevExt->f3DEnabled)
    1063         {
    1064             WARN(("3D disabled, should not be here!"));
    1065             return STATUS_UNSUCCESSFUL;
    1066         }
    1067 
    1068         uint32_t u32ClienID;
    1069         NTSTATUS Status = vboxVdmaCrCtlGetDefaultClientId(pDevExt, &u32ClienID);
    1070         if (!NT_SUCCESS(Status))
    1071         {
    1072             WARN(("vboxVdmaCrCtlGetDefaultClientId failed, Status %#x", Status));
    1073             return Status;
    1074         }
    1075 
    1076         Status = vboxVdmaCrCmdWindowCreate(PVBOXMP_DEVEXT pDevExt, int32_t visualBits, int32_t *pi32WinID)
    1077 
    1078         VBOXMP_CRPACKER CrPacker;
    1079         VBoxMpCrPackerInit(&CrPacker);
    1080 
    1081         int rc = VBoxMpCrCtlConConnect(pDevExt, &pDevExt->CrCtlCon, CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR, &pDevExt->u32CrConDefaultClientID);
    1082         if (!RT_SUCCESS(rc))
    1083         {
    1084             WARN(("VBoxMpCrCtlConConnect failed, rc %d", rc));
    1085             return STATUS_UNSUCCESSFUL;
    1086         }
    1087     }
    1088 
    1089     *pi32CtxID = pDevExt->i32CrConDefaultCtxID;
    1090     return STATUS_SUCCESS;
    1091 }
    1092 #endif
    1093 
    1094 static NTSTATUS vboxVdmaTexPresentSubmit(PVBOXMP_DEVEXT pDevExt,
    1095         VBOXMP_CRPACKER *pCrPacker,
    1096         uint32_t u32CrConClientID,
    1097         uint32_t hostID,
    1098         uint32_t cfg,
    1099         int32_t posX,
    1100         int32_t posY,
    1101         uint32_t cRects,
    1102         const RTRECT*paRects)
    1103 {
    1104     Assert(pDevExt->fTexPresentEnabled);
    1105 
    1106     uint32_t cbCommandBuffer = VBOXMP_CRCMD_HEADER_SIZE + VBOXMP_CRCMD_SIZE_VBOXTEXPRESENT(cRects);
    1107     uint32_t cCommands = 1;
    1108     void RT_UNTRUSTED_VOLATILE_HOST *pvCommandBuffer = VBoxMpCrShgsmiTransportBufAlloc(&pDevExt->CrHgsmiTransport, cbCommandBuffer);
    1109     if (!pvCommandBuffer)
    1110     {
    1111         WARN(("VBoxMpCrShgsmiTransportBufAlloc failed!"));
    1112         return VERR_OUT_OF_RESOURCES;
    1113     }
    1114 
    1115     VBoxMpCrPackerTxBufferInit(pCrPacker, pvCommandBuffer, cbCommandBuffer, cCommands);
    1116 
    1117     crPackVBoxTexPresent(&pCrPacker->CrPacker, hostID, cfg, posX, posY, cRects, (int32_t*)paRects);
    1118 
    1119     NTSTATUS Status = vboxVdmaCrSubmitWriteAsync(pDevExt, pCrPacker, u32CrConClientID);
    1120     if (!NT_SUCCESS(Status))
    1121     {
    1122         WARN(("vboxVdmaCrSubmitWriteAsync failed Status 0x%x", Status));
    1123         VBoxMpCrShgsmiTransportBufFree(&pDevExt->CrHgsmiTransport, pvCommandBuffer);
    1124     }
    1125 
    1126     return Status;
    1127 }
    1128 
    1129 static NTSTATUS vboxVdmaChromiumParameteriCRSubmit(PVBOXMP_DEVEXT pDevExt,
    1130         VBOXMP_CRPACKER *pCrPacker,
    1131         uint32_t u32CrConClientID,
    1132         uint32_t target, uint32_t value)
    1133 {
    1134     Assert(pDevExt->fTexPresentEnabled);
    1135 
    1136     uint32_t cbCommandBuffer = VBOXMP_CRCMD_HEADER_SIZE + VBOXMP_CRCMD_SIZE_CHROMIUMPARAMETERICR;
    1137     uint32_t cCommands = 1;
    1138     void RT_UNTRUSTED_VOLATILE_HOST *pvCommandBuffer = VBoxMpCrShgsmiTransportBufAlloc(&pDevExt->CrHgsmiTransport, cbCommandBuffer);
    1139     if (!pvCommandBuffer)
    1140     {
    1141         WARN(("VBoxMpCrShgsmiTransportBufAlloc failed!"));
    1142         return VERR_OUT_OF_RESOURCES;
    1143     }
    1144 
    1145     VBoxMpCrPackerTxBufferInit(pCrPacker, pvCommandBuffer, cbCommandBuffer, cCommands);
    1146 
    1147     crPackChromiumParameteriCR(&pCrPacker->CrPacker, target, value);
    1148 
    1149     NTSTATUS Status = vboxVdmaCrSubmitWriteAsync(pDevExt, pCrPacker, u32CrConClientID);
    1150     if (!NT_SUCCESS(Status))
    1151     {
    1152         WARN(("vboxVdmaCrSubmitWriteAsync failed Status 0x%x", Status));
    1153         VBoxMpCrShgsmiTransportBufFree(&pDevExt->CrHgsmiTransport, pvCommandBuffer);
    1154     }
    1155 
    1156     return Status;
    1157 }
    1158 
    1159 NTSTATUS VBoxVdmaChromiumParameteriCRSubmit(PVBOXMP_DEVEXT pDevExt, uint32_t target, uint32_t value)
    1160 {
    1161     uint32_t u32CrConClientID;
    1162     NTSTATUS Status = vboxVdmaCrCtlGetDefaultClientId(pDevExt, &u32CrConClientID);
    1163     if (!NT_SUCCESS(Status))
    1164     {
    1165         WARN(("vboxVdmaCrCtlGetDefaultClientId failed Status 0x%x", Status));
    1166         return Status;
    1167     }
    1168 
    1169     VBOXMP_CRPACKER *pCrPacker = (VBOXMP_CRPACKER *)RTMemTmpAlloc(sizeof(*pCrPacker));
    1170     if (!pCrPacker)
    1171         return STATUS_NO_MEMORY;
    1172     VBoxMpCrPackerInit(pCrPacker);
    1173 
    1174     Status = vboxVdmaChromiumParameteriCRSubmit(pDevExt, pCrPacker, u32CrConClientID, target, value);
    1175     if (!NT_SUCCESS(Status))
    1176         WARN(("vboxVdmaChromiumParameteriCRSubmit failed Status 0x%x", Status));
    1177 
    1178     RTMemTmpFree(pCrPacker);
    1179     return Status;
    1180 }
    1181 
    1182 static NTSTATUS vboxVdmaCrCtlGetDefaultClientId(PVBOXMP_DEVEXT pDevExt, uint32_t *pu32ClienID)
    1183 {
    1184     if (pDevExt->enmHwType != VBOXVIDEO_HWTYPE_VBOX)
    1185     {
    1186         /* Should not be called at all in this case. */
    1187         AssertFailed();
    1188         return STATUS_UNSUCCESSFUL;
    1189     }
    1190 
    1191     if (!pDevExt->u32CrConDefaultClientID)
    1192     {
    1193         if (!pDevExt->f3DEnabled)
    1194         {
    1195             WARN(("3D disabled, should not be here!"));
    1196             return STATUS_UNSUCCESSFUL;
    1197         }
    1198 
    1199         int rc = VBoxMpCrCtlConConnect(pDevExt, &pDevExt->CrCtlCon, CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR, &pDevExt->u32CrConDefaultClientID);
    1200         if (!RT_SUCCESS(rc))
    1201         {
    1202             WARN(("VBoxMpCrCtlConConnect failed, rc %d", rc));
    1203             return STATUS_UNSUCCESSFUL;
    1204         }
    1205     }
    1206 
    1207     *pu32ClienID = pDevExt->u32CrConDefaultClientID;
    1208     return STATUS_SUCCESS;
    1209 }
    1210 
    1211 
    1212 static NTSTATUS vboxVdmaProcessVRegTexPresent(PVBOXMP_DEVEXT pDevExt,
    1213         VBOXMP_CRPACKER *pCrPacker,
    1214         uint32_t u32CrConClientID,
    1215         const VBOXWDDM_ALLOC_DATA *pSrcAllocData,
    1216         const VBOXWDDM_ALLOC_DATA *pDstAllocData,
    1217         const RECT *pSrcRect, const VBOXVDMAPIPE_RECTS *pDstRects)
    1218 {
    1219     D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId = pDstAllocData->SurfDesc.VidPnSourceId;
    1220     if (srcId >= (D3DDDI_VIDEO_PRESENT_SOURCE_ID)VBoxCommonFromDeviceExt(pDevExt)->cDisplays)
    1221     {
    1222         WARN(("invalid srcId"));
    1223         return STATUS_NOT_SUPPORTED;
    1224     }
    1225 
    1226     VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[srcId];
    1227 
    1228     bool fPrimary = vboxWddmAddrVramEqual(&pDstAllocData->Addr, &pSource->AllocData.Addr);
    1229     /* we care only about screen regions */
    1230     if (!fPrimary)
    1231     {
    1232         WARN(("non-primary allocation passed to vboxWddmSubmitBltCmd!"));
    1233         return STATUS_NOT_SUPPORTED;
    1234     }
    1235 
    1236     NTSTATUS Status = STATUS_SUCCESS;
    1237     uint32_t hostID = pSrcAllocData->hostID;
    1238     int rc;
    1239     if (hostID)
    1240     {
    1241 //            Assert(pContext->enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D);
    1242         int32_t posX = pDstRects->ContextRect.left - pSrcRect->left;
    1243         int32_t posY = pDstRects->ContextRect.top - pSrcRect->top;
    1244 
    1245         Status = vboxVdmaTexPresentSubmit(pDevExt, pCrPacker, u32CrConClientID, hostID, srcId, posX, posY, pDstRects->UpdateRects.cRects, (const RTRECT*)pDstRects->UpdateRects.aRects);
    1246         if (NT_SUCCESS(Status))
    1247         {
    1248             rc = VBoxVrListRectsSubst(&pSource->VrList, pDstRects->UpdateRects.cRects, (const RTRECT*)pDstRects->UpdateRects.aRects, NULL);
    1249             if (RT_SUCCESS(rc))
    1250                 pSource->fHas3DVrs = TRUE;
    1251             else
    1252                 WARN(("VBoxVrListRectsSubst failed rc %d, ignoring..", rc));
    1253         }
    1254         else
    1255             WARN(("vboxVdmaTexPresentSubmit failed Status 0x%x", Status));
    1256     }
    1257     else
    1258     {
    1259         Assert(fPrimary);
    1260 
    1261         bool fChanged = false;
    1262         Assert(pSource->pPrimaryAllocation->bVisible);
    1263         rc = VBoxVrListRectsAdd(&pSource->VrList, pDstRects->UpdateRects.cRects, (const RTRECT*)pDstRects->UpdateRects.aRects, &fChanged);
    1264         if (RT_SUCCESS(rc))
    1265         {
    1266             if (fChanged)
    1267             {
    1268                 Status = vboxVdmaTexPresentSubmit(pDevExt, pCrPacker, u32CrConClientID, hostID, srcId, 0, 0, pDstRects->UpdateRects.cRects, (const RTRECT*)pDstRects->UpdateRects.aRects);
    1269                 if (NT_SUCCESS(Status))
    1270                 {
    1271                     if (pSource->fHas3DVrs)
    1272                     {
    1273                         if (VBoxVrListRectsCount(&pSource->VrList) == 1)
    1274                         {
    1275                             RTRECT Rect;
    1276                             VBoxVrListRectsGet(&pSource->VrList, 1, &Rect);
    1277                             if (   Rect.xLeft   == 0
    1278                                 && Rect.yTop    == 0
    1279                                 && Rect.xRight  == (int32_t)pDstAllocData->SurfDesc.width
    1280                                 && Rect.yBottom == (int32_t)pDstAllocData->SurfDesc.height)
    1281                             {
    1282                                 pSource->fHas3DVrs = FALSE;
    1283                             }
    1284                         }
    1285                     }
    1286                 }
    1287                 else
    1288                     WARN(("vboxVdmaTexPresentSubmit failed Status 0x%x", Status));
    1289             }
    1290         }
    1291         else
    1292             WARN(("VBoxVrListRectsAdd failed rc %d, ignoring..", rc));
    1293     }
    1294 
    1295     return Status;
    1296 }
    1297 
    1298 static NTSTATUS vboxVdmaProcessVReg(PVBOXMP_DEVEXT pDevExt,
    1299         VBOXMP_CRPACKER *pCrPacker,
    1300         uint32_t u32CrConClientID,
    1301         const VBOXWDDM_ALLOCATION *pSrcAlloc,
    1302         const VBOXWDDM_ALLOCATION *pDstAlloc,
    1303         const RECT *pSrcRect, const VBOXVDMAPIPE_RECTS *pDstRects)
    1304 {
    1305     D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId = pDstAlloc->AllocData.SurfDesc.VidPnSourceId;
    1306     VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[srcId];
    1307     NTSTATUS Status = STATUS_SUCCESS;
    1308 
    1309     if (pDevExt->fTexPresentEnabled)
    1310     {
    1311         Status = vboxVdmaProcessVRegTexPresent(pDevExt, pCrPacker, u32CrConClientID,
    1312                 &pSrcAlloc->AllocData, &pDstAlloc->AllocData,
    1313                 pSrcRect, pDstRects);
    1314     }
    1315     else
    1316     {
    1317         PVBOXWDDM_SWAPCHAIN pSwapchain = vboxWddmSwapchainRetainByAlloc(pDevExt, pSrcAlloc);
    1318 
    1319         if (pSwapchain)
    1320         {
    1321             Assert(pSrcAlloc->AllocData.SurfDesc.width == pSwapchain->width);
    1322             Assert(pSrcAlloc->AllocData.SurfDesc.height == pSwapchain->height);
    1323         }
    1324 
    1325         Status = vboxVdmaProcessVRegCmdLegacy(pDevExt, pCrPacker, u32CrConClientID, pSource, pSwapchain, pSrcRect, pDstRects);
    1326         if (!NT_SUCCESS(Status))
    1327             WARN(("vboxVdmaProcessVRegCmdLegacy failed Status 0x%x", Status));
    1328 
    1329         if (pSwapchain)
    1330             vboxWddmSwapchainRelease(pSwapchain);
    1331     }
    1332 
    1333     return Status;
    1334 }
    1335 
    1336 NTSTATUS vboxVdmaTexPresentSetAlloc(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOC_DATA *pAllocData)
    1337 {
    1338     if (pDevExt->enmHwType != VBOXVIDEO_HWTYPE_VBOX)
    1339     {
    1340         /* Not used in this case. */
    1341         return STATUS_SUCCESS;
    1342     }
    1343 
    1344     uint32_t u32CrConClientID;
    1345     NTSTATUS Status = vboxVdmaCrCtlGetDefaultClientId(pDevExt, &u32CrConClientID);
    1346     if (!NT_SUCCESS(Status))
    1347     {
    1348         WARN(("vboxVdmaCrCtlGetDefaultClientId failed Status 0x%x", Status));
    1349         return Status;
    1350     }
    1351 
    1352     VBOXMP_CRPACKER *pCrPacker = (VBOXMP_CRPACKER *)RTMemTmpAlloc(sizeof(*pCrPacker));
    1353     if (!pCrPacker)
    1354         return STATUS_NO_MEMORY;
    1355     VBoxMpCrPackerInit(pCrPacker);
    1356 
    1357     RECT Rect;
    1358     Rect.left = 0;
    1359     Rect.top = 0;
    1360     Rect.right = pAllocData->SurfDesc.width;
    1361     Rect.bottom = pAllocData->SurfDesc.height;
    1362 
    1363     if (pDevExt->fCmdVbvaEnabled)
    1364         Status = vboxVdmaTexPresentSubmit(pDevExt, pCrPacker, u32CrConClientID, pAllocData->hostID, pAllocData->SurfDesc.VidPnSourceId, 0, 0, 1, (RTRECT*)&Rect);
    1365     else if (pDevExt->fTexPresentEnabled)
    1366     {
    1367         VBOXVDMAPIPE_RECTS RectInfo;
    1368         RectInfo.ContextRect = Rect;
    1369         RectInfo.UpdateRects.cRects = 1;
    1370         RectInfo.UpdateRects.aRects[0] = Rect;
    1371 
    1372         Status = vboxVdmaProcessVRegTexPresent(pDevExt, pCrPacker, u32CrConClientID,
    1373                 pAllocData, pAllocData,
    1374                 &Rect, &RectInfo);
    1375     }
    1376     else
    1377         Status = STATUS_NOT_IMPLEMENTED;
    1378 
    1379     RTMemTmpFree(pCrPacker);
    1380     return Status;
    1381 }
    1382 
    1383 static NTSTATUS vboxVdmaProcessVRegCmd(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_CONTEXT *pContext,
    1384         const VBOXWDDM_DMA_ALLOCINFO *pSrcAllocInfo,
    1385         const VBOXWDDM_DMA_ALLOCINFO *pDstAllocInfo,
    1386         const RECT *pSrcRect, const VBOXVDMAPIPE_RECTS *pDstRects)
    1387 {
    1388     return vboxVdmaProcessVReg(pDevExt, &pContext->CrPacker, pContext->u32CrConClientID,
    1389             pSrcAllocInfo->pAlloc, pDstAllocInfo->pAlloc,
    1390             pSrcRect, pDstRects);
    1391 }
    1392511
    1393512static void vboxVdmaBltDirtyRectsUpdate(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_SOURCE *pSource, uint32_t cRects, const RECT *paRects)
     
    1416535    }
    1417536}
    1418 #endif
    1419 
    1420 NTSTATUS vboxVdmaProcessBltCmd(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_CONTEXT *pContext, VBOXWDDM_DMA_PRIVATEDATA_BLT *pBlt)
    1421 {
    1422     NTSTATUS Status = STATUS_SUCCESS;
    1423     PVBOXWDDM_ALLOCATION pDstAlloc = pBlt->Blt.DstAlloc.pAlloc;
    1424     PVBOXWDDM_ALLOCATION pSrcAlloc = pBlt->Blt.SrcAlloc.pAlloc;
    1425     BOOLEAN fVRAMUpdated = FALSE;
    1426 #ifdef VBOX_WITH_CROGL
    1427     if (!pDstAlloc->AllocData.hostID && !pSrcAlloc->AllocData.hostID)
    1428 #endif
    1429     {
    1430         /* the allocations contain a real data in VRAM, do blitting */
    1431         vboxVdmaGgDmaBlt(pDevExt, &pBlt->Blt);
    1432         fVRAMUpdated = TRUE;
    1433     }
    1434 
    1435 #ifdef VBOX_WITH_CROGL
    1436     if (VBOXWDDM_IS_FB_ALLOCATION(pDevExt, pDstAlloc)
    1437             && pDstAlloc->bVisible)
    1438     {
    1439         VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->AllocData.SurfDesc.VidPnSourceId];
    1440         Assert(pDstAlloc->AllocData.SurfDesc.VidPnSourceId < VBOX_VIDEO_MAX_SCREENS);
    1441         Assert(pSource->pPrimaryAllocation == pDstAlloc);
    1442 
    1443         if (fVRAMUpdated)
    1444             vboxVdmaBltDirtyRectsUpdate(pDevExt, pSource, pBlt->Blt.DstRects.UpdateRects.cRects, pBlt->Blt.DstRects.UpdateRects.aRects);
    1445 
    1446         if (pSrcAlloc->AllocData.hostID || (pDevExt->fTexPresentEnabled ? pSource->fHas3DVrs : !!pDevExt->cContexts3D))
    1447         {
    1448             Status = vboxVdmaProcessVRegCmd(pDevExt, pContext, &pBlt->Blt.SrcAlloc, &pBlt->Blt.DstAlloc, &pBlt->Blt.SrcRect, &pBlt->Blt.DstRects);
    1449             if (!NT_SUCCESS(Status))
    1450                 WARN(("vboxVdmaProcessVRegCmd failed Status 0x%x", Status));
    1451         }
    1452     }
    1453 #endif
    1454     return Status;
    1455 }
    1456 
    1457 NTSTATUS vboxVdmaProcessFlipCmd(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_CONTEXT *pContext, VBOXWDDM_DMA_PRIVATEDATA_FLIP *pFlip)
    1458 {
    1459     NTSTATUS Status = STATUS_SUCCESS;
    1460     PVBOXWDDM_ALLOCATION pAlloc = pFlip->Flip.Alloc.pAlloc;
    1461     VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pAlloc->AllocData.SurfDesc.VidPnSourceId];
    1462     vboxWddmAssignPrimary(pSource, pAlloc, pAlloc->AllocData.SurfDesc.VidPnSourceId);
    1463 #ifdef VBOX_WITH_CROGL
    1464     if (pAlloc->AllocData.hostID)
    1465     {
    1466         RECT SrcRect;
    1467         VBOXVDMAPIPE_RECTS Rects;
    1468         SrcRect.left = 0;
    1469         SrcRect.top = 0;
    1470         SrcRect.right = pAlloc->AllocData.SurfDesc.width;
    1471         SrcRect.bottom = pAlloc->AllocData.SurfDesc.height;
    1472         Rects.ContextRect.left = 0;
    1473         Rects.ContextRect.top = 0;
    1474         Rects.ContextRect.right = pAlloc->AllocData.SurfDesc.width;
    1475         Rects.ContextRect.bottom = pAlloc->AllocData.SurfDesc.height;
    1476         Rects.UpdateRects.cRects = 1;
    1477         Rects.UpdateRects.aRects[0] = Rects.ContextRect;
    1478 
    1479         Status = vboxVdmaProcessVRegCmd(pDevExt, pContext, &pFlip->Flip.Alloc, &pFlip->Flip.Alloc, &SrcRect, &Rects);
    1480         if (!NT_SUCCESS(Status))
    1481             WARN(("vboxVdmaProcessVRegCmd failed Status 0x%x", Status));
    1482     }
    1483     else
    1484 #endif
    1485     {
    1486         WARN(("unexpected flip request"));
    1487     }
    1488 
    1489     return Status;
    1490 }
    1491 
    1492 NTSTATUS vboxVdmaProcessClrFillCmd(PVBOXMP_DEVEXT pDevExt, VBOXWDDM_CONTEXT *pContext, VBOXWDDM_DMA_PRIVATEDATA_CLRFILL *pCF)
    1493 {
    1494     RT_NOREF(pContext);
    1495     NTSTATUS Status = STATUS_SUCCESS;
    1496     PVBOXWDDM_ALLOCATION pAlloc = pCF->ClrFill.Alloc.pAlloc;
    1497 #ifdef VBOX_WITH_CROGL
    1498     if (!pAlloc->AllocData.hostID)
    1499 #endif
    1500     {
    1501         Status = vboxVdmaGgDmaColorFill(pDevExt, &pCF->ClrFill);
    1502         if (!NT_SUCCESS(Status))
    1503             WARN(("vboxVdmaGgDmaColorFill failed Status 0x%x", Status));
    1504     }
    1505 #ifdef VBOX_WITH_CROGL
    1506     else
    1507         WARN(("unexpected clrfill request"));
    1508 #endif
    1509 
    1510     return Status;
    1511 }
     537
    1512538
    1513539
     
    21461172    return Status;
    21471173}
    2148 
    2149 NTSTATUS vboxVdmaDdiCmdFenceComplete(PVBOXMP_DEVEXT pDevExt, uint32_t u32NodeOrdinal, uint32_t u32FenceId, DXGK_INTERRUPT_TYPE enmComplType)
    2150 {
    2151     if (vboxVdmaDdiCmdCanComplete(pDevExt, u32NodeOrdinal))
    2152         return vboxVdmaDdiCmdFenceNotifyComplete(pDevExt, u32NodeOrdinal, u32FenceId);
    2153 
    2154     PVBOXVDMADDI_CMD pCmd = (PVBOXVDMADDI_CMD)vboxWddmMemAlloc(sizeof (VBOXVDMADDI_CMD));
    2155     Assert(pCmd);
    2156     if (pCmd)
    2157     {
    2158         vboxVdmaDdiCmdInit(pCmd, u32NodeOrdinal, u32FenceId, vboxVdmaDdiCmdCompletionCbFree, NULL);
    2159         NTSTATUS Status = vboxVdmaDdiCmdCompleted(pDevExt, pCmd, enmComplType);
    2160         AssertNtStatusSuccess(Status);
    2161         if (Status == STATUS_SUCCESS)
    2162             return STATUS_SUCCESS;
    2163         vboxWddmMemFree(pCmd);
    2164         return Status;
    2165     }
    2166     return STATUS_NO_MEMORY;
    2167 }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h

    r76563 r80422  
    9595}
    9696
    97 NTSTATUS vboxVdmaDdiCmdFenceComplete(PVBOXMP_DEVEXT pDevExt, uint32_t u32NodeOrdinal, uint32_t u32FenceId, DXGK_INTERRUPT_TYPE enmComplType);
    98 
    9997DECLCALLBACK(VOID) vboxVdmaDdiCmdCompletionCbFree(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
    10098
     
    314312#define VBOXVDMAPIPE_CMD_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMAPIPE_CMD_DR)(((uint8_t*)(_pCmd)) - RT_UOFFSETOF(VBOXVDMAPIPE_CMD_DR, DdiCmd)))
    315313
    316 NTSTATUS vboxVdmaProcessBltCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_BLT *pBlt);
    317 NTSTATUS vboxVdmaProcessFlipCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_FLIP *pFlip);
    318 NTSTATUS vboxVdmaProcessClrFillCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_CLRFILL *pCF);
    319 #ifdef VBOX_WITH_CROGL
    320 NTSTATUS vboxVdmaTexPresentSetAlloc(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOC_DATA *pAllocData);
    321 NTSTATUS VBoxVdmaChromiumParameteriCRSubmit(PVBOXMP_DEVEXT pDevExt, uint32_t target, uint32_t value);
    322 #endif
    323 
    324314#endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_mp_wddm_VBoxMPVdma_h */
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r79937 r80422  
    2222#include "VBoxMPVidPn.h"
    2323
     24#include <iprt/alloc.h>
    2425#include <iprt/asm.h>
    2526#include <iprt/param.h>
     
    3940
    4041#include <stdio.h>
    41 
    42 /* Uncomment this in order to enable dumping regions guest wants to display on DxgkDdiPresentNew(). */
    43 //#define VBOX_WDDM_DUMP_REGIONS_ON_PRESENT
    4442
    4543#define VBOXWDDM_DUMMY_DMABUFFER_SIZE (sizeof(VBOXCMDVBVA_HDR) / 2)
     
    192190}
    193191
    194 static void vboxWddmPopulateDmaAllocInfo(PVBOXWDDM_DMA_ALLOCINFO pInfo, PVBOXWDDM_ALLOCATION pAlloc, DXGK_ALLOCATIONLIST *pDmaAlloc)
    195 {
    196     pInfo->pAlloc = pAlloc;
    197     if (pDmaAlloc->SegmentId)
    198     {
    199         pInfo->offAlloc = (VBOXVIDEOOFFSET)pDmaAlloc->PhysicalAddress.QuadPart;
    200         pInfo->segmentIdAlloc = pDmaAlloc->SegmentId;
    201     }
    202     else
    203         pInfo->segmentIdAlloc = 0;
    204     pInfo->srcId = pAlloc->AllocData.SurfDesc.VidPnSourceId;
    205 }
    206 
    207 static void vboxWddmPopulateDmaAllocInfoWithOffset(PVBOXWDDM_DMA_ALLOCINFO pInfo, PVBOXWDDM_ALLOCATION pAlloc, DXGK_ALLOCATIONLIST *pDmaAlloc, uint32_t offStart)
    208 {
    209     pInfo->pAlloc = pAlloc;
    210     if (pDmaAlloc->SegmentId)
    211     {
    212         pInfo->offAlloc = (VBOXVIDEOOFFSET)pDmaAlloc->PhysicalAddress.QuadPart + offStart;
    213         pInfo->segmentIdAlloc = pDmaAlloc->SegmentId;
    214     }
    215     else
    216         pInfo->segmentIdAlloc = 0;
    217     pInfo->srcId = pAlloc->AllocData.SurfDesc.VidPnSourceId;
    218 }
    219 
    220192int vboxWddmGhDisplayPostInfoScreen(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOC_DATA *pAllocData, const POINT * pVScreenPos, uint16_t fFlags)
    221193{
     
    375347NTSTATUS vboxWddmGhDisplaySetInfoLegacy(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOC_DATA *pAllocData, const POINT * pVScreenPos, uint8_t u8CurCyncState, bool fPowerOff, bool fDisabled)
    376348{
     349    RT_NOREF(u8CurCyncState);
    377350    NTSTATUS Status = STATUS_SUCCESS;
    378351    bool fValidAlloc = pAllocData->SurfDesc.width > 0 && pAllocData->SurfDesc.height > 0;
     
    381354    if (fValidAlloc)
    382355    {
    383 #ifdef VBOX_WITH_CROGL
    384         if ((u8CurCyncState & VBOXWDDM_HGSYNC_F_CHANGED_LOCATION_ONLY) == VBOXWDDM_HGSYNC_F_CHANGED_LOCATION_ONLY
    385                 && pAllocData->hostID)
    386         {
    387             Status = vboxVdmaTexPresentSetAlloc(pDevExt, pAllocData);
    388             if (!NT_SUCCESS(Status))
    389                 WARN(("vboxVdmaTexPresentSetAlloc failed, Status 0x%x", Status));
    390             return Status;
    391         }
    392 #endif
    393 
    394356        if (pAllocData->SurfDesc.VidPnSourceId == 0)
    395357            Status = vboxWddmGhDisplaySetMode(pDevExt, pAllocData);
     
    402364        if (NT_SUCCESS(Status))
    403365        {
    404 #ifdef VBOX_WITH_CROGL
    405             if (fValidAlloc && pDevExt->f3DEnabled)
    406             {
    407                 Status = vboxVdmaTexPresentSetAlloc(pDevExt, pAllocData);
    408                 if (NT_SUCCESS(Status))
    409                     return STATUS_SUCCESS;
    410                 else
    411                     WARN(("vboxVdmaTexPresentSetAlloc failed, Status 0x%x", Status));
    412             }
    413 #else
    414366            return STATUS_SUCCESS;
    415 #endif
    416367        }
    417368        else
     
    426377NTSTATUS vboxWddmGhDisplaySetInfoNew(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOC_DATA *pAllocData, const uint32_t *pTargetMap, const POINT * pVScreenPos, uint8_t u8CurCyncState, bool fPowerOff, bool fDisabled)
    427378{
     379    RT_NOREF(u8CurCyncState);
    428380    NTSTATUS Status = STATUS_SUCCESS;
    429381    bool fValidAlloc = pAllocData->SurfDesc.width > 0 && pAllocData->SurfDesc.height > 0;
     
    432384    if (fValidAlloc)
    433385    {
    434 #ifdef VBOX_WITH_CROGL
    435         if ((u8CurCyncState & VBOXWDDM_HGSYNC_F_CHANGED_LOCATION_ONLY) == VBOXWDDM_HGSYNC_F_CHANGED_LOCATION_ONLY
    436                 && pAllocData->hostID)
    437         {
    438             Status = vboxVdmaTexPresentSetAlloc(pDevExt, pAllocData);
    439             if (!NT_SUCCESS(Status))
    440                 WARN(("vboxVdmaTexPresentSetAlloc failed, Status 0x%x", Status));
    441             return Status;
    442         }
    443 #endif
    444 
    445386        if (ASMBitTest(pTargetMap, 0))
    446387            Status = vboxWddmGhDisplaySetMode(pDevExt, pAllocData);
     
    452393        if (NT_SUCCESS(Status))
    453394        {
    454 #ifdef VBOX_WITH_CROGL
    455             if (fValidAlloc && pDevExt->f3DEnabled)
    456             {
    457                 Status = vboxVdmaTexPresentSetAlloc(pDevExt, pAllocData);
    458                 if (NT_SUCCESS(Status))
    459                     return STATUS_SUCCESS;
    460                 else
    461                     WARN(("vboxVdmaTexPresentSetAlloc failed, Status 0x%x", Status));
    462             }
    463 #else
    464395            return STATUS_SUCCESS;
    465 #endif
    466396        }
    467397        else
     
    844774    if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX)
    845775    {
    846         pDevExt->f3DEnabled = VBoxMpCrCtlConIs3DSupported();
     776        pDevExt->f3DEnabled = FALSE;
    847777    }
    848778    else if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
     
    993923    ULONG offCmdVbva = cbAvailable - cbCmdVbva;
    994924
     925/// @todo The Gallium 3D driver (which still needs pDevExt->fCmdVbvaEnabled == true) does not (should not) use CmdVbva.
     926///       But we still have to create the Vbva structure because code elsewhere in the driver depends on it,
     927///       for example vboxWddmVramCpuVisibleSize. CmdVbva will be removed eventually.
    995928    int rc = VBoxCmdVbvaCreate(pDevExt, &pDevExt->CmdVbva, offCmdVbva, cbCmdVbva);
    996929    if (RT_SUCCESS(rc))
    997930    {
    998         rc = VBoxCmdVbvaEnable(pDevExt, &pDevExt->CmdVbva);
    999         if (RT_SUCCESS(rc))
    1000         {
     931// Do not actually send the request to the host, because the Gallium driver does not need this.
     932//        rc = VBoxCmdVbvaEnable(pDevExt, &pDevExt->CmdVbva);
     933//        if (RT_SUCCESS(rc))
     934//        {
    1001935            rc = VBoxMPCmnMapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), (void**)&pDevExt->pvVisibleVram,
    1002936                                           0, vboxWddmVramCpuVisibleSize(pDevExt));
     
    1006940                WARN(("VBoxMPCmnMapAdapterMemory failed, rc %d", rc));
    1007941
    1008             VBoxCmdVbvaDisable(pDevExt, &pDevExt->CmdVbva);
    1009         }
    1010         else
    1011             WARN(("VBoxCmdVbvaEnable failed, rc %d", rc));
     942//            VBoxCmdVbvaDisable(pDevExt, &pDevExt->CmdVbva);
     943//        }
     944//        else
     945//            WARN(("VBoxCmdVbvaEnable failed, rc %d", rc));
    1012946
    1013947        VBoxCmdVbvaDestroy(pDevExt, &pDevExt->CmdVbva);
     
    1045979    if (pDevExt->fCmdVbvaEnabled)
    1046980    {
    1047         rc = VBoxCmdVbvaDisable(pDevExt, &pDevExt->CmdVbva);
    1048         if (RT_SUCCESS(rc))
    1049         {
    1050             rc = VBoxCmdVbvaDestroy(pDevExt, &pDevExt->CmdVbva);
    1051             if (RT_FAILURE(rc))
    1052                 WARN(("VBoxCmdVbvaDestroy failed %d", rc));
    1053         }
    1054         else
    1055             WARN(("VBoxCmdVbvaDestroy failed %d", rc));
     981//        rc = VBoxCmdVbvaDisable(pDevExt, &pDevExt->CmdVbva);
     982//        if (RT_SUCCESS(rc))
     983//        {
     984//            rc = VBoxCmdVbvaDestroy(pDevExt, &pDevExt->CmdVbva);
     985//            if (RT_FAILURE(rc))
     986//                WARN(("VBoxCmdVbvaDestroy failed %d", rc));
     987//        }
     988//        else
     989//            WARN(("VBoxCmdVbvaDestroy failed %d", rc));
    1056990
    1057991    }
     
    11791113            {
    11801114                /* Figure out the host capabilities. Start with nothing. */
    1181                 pDevExt->fTexPresentEnabled = FALSE;
    11821115                pDevExt->fCmdVbvaEnabled = FALSE;
    11831116                pDevExt->fComplexTopologiesEnabled = TRUE;
     
    11851118                if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX)
    11861119                {
    1187 #ifdef VBOX_WITH_CROGL
     1120                    pDevExt->f3DEnabled = FALSE;
     1121                }
     1122#ifdef VBOX_WITH_MESA3D
     1123                else if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
     1124                {
    11881125                    if (pDevExt->f3DEnabled)
    11891126                    {
    1190                         pDevExt->fTexPresentEnabled = !!(VBoxMpCrGetHostCaps() & CR_VBOX_CAP_TEX_PRESENT);
    1191                         pDevExt->fCmdVbvaEnabled = !!(VBoxMpCrGetHostCaps() & CR_VBOX_CAP_CMDVBVA);
    1192                     }
    1193 #else
    1194                     pDevExt->f3DEnabled = FALSE;
    1195 #endif
    1196                 }
    1197 #ifdef VBOX_WITH_MESA3D
    1198                 else if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    1199                 {
    1200                     if (pDevExt->f3DEnabled)
    1201                     {
    1202                         pDevExt->fTexPresentEnabled = TRUE;
     1127                        /// @todo This enables legacy code which is shared with VMSVGA, for example displays setup.
     1128                        //  Must be removed eventually.
    12031129                        pDevExt->fCmdVbvaEnabled = TRUE;
    12041130                        pDevExt->fComplexTopologiesEnabled = FALSE; /** @todo Enable after implementing multimonitor support. */
     
    12551181                    VBoxWddmSlInit(pDevExt);
    12561182
    1257 #ifdef VBOX_WITH_CROGL
    1258                     VBoxMpCrShgsmiTransportCreate(&pDevExt->CrHgsmiTransport, pDevExt);
    1259 #endif
    1260 
    12611183                    for (UINT i = 0; i < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
    12621184                    {
    12631185                        PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[i];
    12641186                        KeInitializeSpinLock(&pSource->AllocationLock);
    1265 #ifdef VBOX_WITH_CROGL
    1266                         VBoxVrListInit(&pSource->VrList);
    1267 #endif
    12681187                    }
    12691188
     
    14351354#endif
    14361355
    1437 #ifdef VBOX_WITH_CROGL
    1438     if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX && pDevExt->u32CrConDefaultClientID)
    1439         VBoxMpCrCtlConDisconnect(pDevExt, &pDevExt->CrCtlCon, pDevExt->u32CrConDefaultClientID);
    1440 
    1441     VBoxMpCrShgsmiTransportTerm(&pDevExt->CrHgsmiTransport);
    1442 #endif
    1443 
    14441356    VBoxWddmSlTerm(pDevExt);
    14451357
     
    15811493    PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)MiniportDeviceContext;
    15821494    BOOLEAN bOur = FALSE;
    1583 #ifdef VBOX_WITH_MESA3D
    1584     BOOLEAN bSvga = FALSE;
    1585     if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    1586     {
    1587         bSvga = GaDxgkDdiInterruptRoutine(MiniportDeviceContext, MessageNumber);
    1588     }
    1589 #endif
    15901495    bool bNeedDpc = FALSE;
    15911496    if (!VBoxCommonFromDeviceExt(pDevExt)->hostCtx.pfHostFlags) /* If HGSMI is enabled at all. */
    15921497    {
    15931498        WARN(("ISR called with hgsmi disabled!"));
    1594 #ifdef VBOX_WITH_MESA3D
    1595         return bSvga;
    1596 #else
    15971499        return FALSE;
    1598 #endif
    15991500    }
    16001501
     
    17191620        pDevExt->u.primary.DxgkInterface.DxgkCbQueueDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    17201621
    1721 #ifdef VBOX_WITH_MESA3D
    1722     return bSvga || bOur;
    1723 #else
    17241622    return bOur;
    1725 #endif
    17261623}
    17271624#endif
     
    19601857}
    19611858
    1962 #ifdef VBOX_WITH_CROGL
    1963 static VOID DxgkDdiDpcRoutineNew(
    1964     IN CONST PVOID  MiniportDeviceContext
    1965     )
    1966 {
    1967 //    LOGF(("ENTER, context(0x%p)", MiniportDeviceContext));
    1968 
    1969     vboxVDbgBreakFv();
    1970 
    1971     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)MiniportDeviceContext;
    1972 
    1973     pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    1974 
    1975 #ifdef VBOX_WITH_MESA3D
    1976     if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    1977     {
    1978         GaDxgkDdiDpcRoutine(MiniportDeviceContext);
    1979     }
    1980 #endif
    1981 
    1982     if (ASMAtomicReadU32(&pDevExt->fCompletingCommands))
    1983     {
    1984         VBOXWDDM_GETDPCDATA_CONTEXT context = {0};
    1985         BOOLEAN bRet;
    1986 
    1987         context.pDevExt = pDevExt;
    1988 
    1989         /* get DPC data at IRQL */
    1990         NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
    1991                 pDevExt->u.primary.DxgkInterface.DeviceHandle,
    1992                 vboxWddmGetDPCDataCallback,
    1993                 &context,
    1994                 0, /* IN ULONG MessageNumber */
    1995                 &bRet);
    1996         AssertNtStatusSuccess(Status); NOREF(Status);
    1997 
    1998     //    if (context.data.bNotifyDpc)
    1999         pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    2000 
    2001         if (!vboxVtListIsEmpty(&context.data.CtlList))
    2002         {
    2003             int rc = VBoxSHGSMICommandPostprocessCompletion (&VBoxCommonFromDeviceExt(pDevExt)->guestCtx.heapCtx, &context.data.CtlList);
    2004             AssertRC(rc);
    2005         }
    2006 #ifdef VBOX_WITH_VIDEOHWACCEL
    2007         if (!vboxVtListIsEmpty(&context.data.VhwaCmdList))
    2008         {
    2009             vboxVhwaCompletionListProcess(pDevExt, &context.data.VhwaCmdList);
    2010         }
    2011 #endif
    2012     }
    2013 //    LOGF(("LEAVE, context(0x%p)", MiniportDeviceContext));
    2014 }
    2015 #endif
    2016 
    20171859static VOID DxgkDdiDpcRoutineLegacy(
    20181860    IN CONST PVOID  MiniportDeviceContext
     
    22292071
    22302072    VbglR0TerminateClient();
    2231 
    2232 #ifdef VBOX_WITH_CROGL
    2233     VBoxVrTerm();
    2234 #endif
    22352073
    22362074    PRTLOGGER pLogger = RTLogRelSetDefaultInstance(NULL);
     
    24342272                    if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX)
    24352273                    {
    2436 #ifdef VBOX_WITH_CROGL
    2437                         pQAI->u.vbox.u32VBox3DCaps = VBoxMpCrGetHostCaps();
    2438 #endif
     2274                        pQAI->u.vbox.u32VBox3DCaps = 0;
    24392275                    }
    24402276#ifdef VBOX_WITH_MESA3D
     
    26032439VOID vboxWddmAllocationCleanup(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
    26042440{
     2441    RT_NOREF(pDevExt);
    26052442    switch (pAllocation->enmType)
    26062443    {
     
    26262463            break;
    26272464    }
    2628 #ifdef VBOX_WITH_CROGL
    2629     PVBOXWDDM_SWAPCHAIN pSwapchain = vboxWddmSwapchainRetainByAlloc(pDevExt, pAllocation);
    2630     if (pSwapchain)
    2631     {
    2632         vboxWddmSwapchainAllocRemove(pDevExt, pSwapchain, pAllocation);
    2633         vboxWddmSwapchainRelease(pSwapchain);
    2634     }
    2635 #endif
    26362465}
    26372466
     
    29662795        /* wait for all current allocation-related ops are completed */
    29672796        vboxWddmAllocationCleanup(pDevExt, pAlloc);
    2968         if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX && pAlloc->hSharedHandle && pAlloc->AllocData.hostID)
    2969             VBoxVdmaChromiumParameteriCRSubmit(pDevExt, GL_PIN_TEXTURE_CLEAR_CR, pAlloc->AllocData.hostID);
    29702797        vboxWddmAllocationDestroy(pAlloc);
    29712798    }
     
    31722999}
    31733000
    3174 #ifdef VBOX_WITH_CROGL
    3175 static NTSTATUS
    3176 APIENTRY
    3177 DxgkDdiPatchNew(
    3178     CONST HANDLE  hAdapter,
    3179     CONST DXGKARG_PATCH*  pPatch)
    3180 {
    3181     RT_NOREF(hAdapter);
    3182     /* DxgkDdiPatch should be made pageable. */
    3183     PAGED_CODE();
    3184 
    3185 #ifdef VBOX_WITH_MESA3D
    3186     if (((PVBOXMP_DEVEXT)hAdapter)->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    3187     {
    3188         return GaDxgkDdiPatch(hAdapter, pPatch);
    3189     }
    3190 #endif
    3191 
    3192     LOGF(("ENTER, context(0x%x)", hAdapter));
    3193 
    3194     vboxVDbgBreakFv();
    3195 
    3196     uint8_t * pPrivateBuf = (uint8_t*)((uint8_t*)pPatch->pDmaBufferPrivateData + pPatch->DmaBufferPrivateDataSubmissionStartOffset);
    3197     UINT cbPatchBuff = pPatch->DmaBufferPrivateDataSubmissionEndOffset - pPatch->DmaBufferPrivateDataSubmissionStartOffset;
    3198 
    3199     for (UINT i = pPatch->PatchLocationListSubmissionStart; i < pPatch->PatchLocationListSubmissionLength; ++i)
    3200     {
    3201         const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[i];
    3202         Assert(pPatchList->AllocationIndex < pPatch->AllocationListSize);
    3203         const DXGK_ALLOCATIONLIST *pAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    3204         if (!pAllocationList->SegmentId)
    3205         {
    3206             WARN(("no segment id specified"));
    3207             continue;
    3208         }
    3209 
    3210         if (pPatchList->PatchOffset == ~0UL)
    3211         {
    3212             /* this is a dummy patch request, ignore */
    3213             continue;
    3214         }
    3215 
    3216         if (pPatchList->PatchOffset >= cbPatchBuff)
    3217         {
    3218             WARN(("pPatchList->PatchOffset(%d) >= cbPatchBuff(%d)", pPatchList->PatchOffset, cbPatchBuff));
    3219             return STATUS_INVALID_PARAMETER;
    3220         }
    3221 
    3222         VBOXCMDVBVAOFFSET *poffVram = (VBOXCMDVBVAOFFSET*)(pPrivateBuf + pPatchList->PatchOffset);
    3223         Assert(pAllocationList->SegmentId);
    3224         Assert(!pAllocationList->PhysicalAddress.HighPart);
    3225         Assert(!(pAllocationList->PhysicalAddress.QuadPart & 0xfffUL)); /* <- just a check to ensure allocation offset does not go here */
    3226         *poffVram = pAllocationList->PhysicalAddress.LowPart + pPatchList->AllocationOffset;
    3227     }
    3228 
    3229     return STATUS_SUCCESS;
    3230 }
    3231 #endif
    3232 
    3233 static NTSTATUS
    3234 APIENTRY
    3235 DxgkDdiPatchLegacy(
    3236     CONST HANDLE  hAdapter,
    3237     CONST DXGKARG_PATCH*  pPatch)
    3238 {
    3239     RT_NOREF(hAdapter);
    3240     /* DxgkDdiPatch should be made pageable. */
    3241     PAGED_CODE();
    3242 
    3243     NTSTATUS Status = STATUS_SUCCESS;
    3244 
    3245     LOGF(("ENTER, context(0x%x)", hAdapter));
    3246 
    3247     vboxVDbgBreakFv();
    3248 
    3249     /* Value == 2 is Present
    3250      * Value == 4 is RedirectedPresent
    3251      * we do not expect any other flags to be set here */
    3252 //    Assert(pPatch->Flags.Value == 2 || pPatch->Flags.Value == 4);
    3253     if (pPatch->DmaBufferPrivateDataSubmissionEndOffset - pPatch->DmaBufferPrivateDataSubmissionStartOffset >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR))
    3254     {
    3255         Assert(pPatch->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR));
    3256         VBOXWDDM_DMA_PRIVATEDATA_BASEHDR *pPrivateDataBase = (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR*)((uint8_t*)pPatch->pDmaBufferPrivateData + pPatch->DmaBufferPrivateDataSubmissionStartOffset);
    3257         switch (pPrivateDataBase->enmCmd)
    3258         {
    3259             case VBOXVDMACMD_TYPE_DMA_PRESENT_BLT:
    3260             {
    3261                 PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateDataBase;
    3262                 Assert(pPatch->PatchLocationListSubmissionLength == 2);
    3263                 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart];
    3264                 Assert(pPatchList->AllocationIndex == DXGK_PRESENT_SOURCE_INDEX);
    3265                 Assert(pPatchList->PatchOffset == 0);
    3266                 const DXGK_ALLOCATIONLIST *pSrcAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    3267                 Assert(pSrcAllocationList->SegmentId);
    3268                 pBlt->Blt.SrcAlloc.segmentIdAlloc = pSrcAllocationList->SegmentId;
    3269                 pBlt->Blt.SrcAlloc.offAlloc = (VBOXVIDEOOFFSET)pSrcAllocationList->PhysicalAddress.QuadPart;
    3270 
    3271                 pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart + 1];
    3272                 Assert(pPatchList->AllocationIndex == DXGK_PRESENT_DESTINATION_INDEX);
    3273                 Assert(pPatchList->PatchOffset == 4);
    3274                 const DXGK_ALLOCATIONLIST *pDstAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    3275                 Assert(pDstAllocationList->SegmentId);
    3276                 pBlt->Blt.DstAlloc.segmentIdAlloc = pDstAllocationList->SegmentId;
    3277                 pBlt->Blt.DstAlloc.offAlloc = (VBOXVIDEOOFFSET)pDstAllocationList->PhysicalAddress.QuadPart;
    3278                 break;
    3279             }
    3280             case VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP:
    3281             {
    3282                 PVBOXWDDM_DMA_PRIVATEDATA_FLIP pFlip = (PVBOXWDDM_DMA_PRIVATEDATA_FLIP)pPrivateDataBase;
    3283                 Assert(pPatch->PatchLocationListSubmissionLength == 1);
    3284                 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart];
    3285                 Assert(pPatchList->AllocationIndex == DXGK_PRESENT_SOURCE_INDEX);
    3286                 Assert(pPatchList->PatchOffset == 0);
    3287                 const DXGK_ALLOCATIONLIST *pSrcAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    3288                 Assert(pSrcAllocationList->SegmentId);
    3289                 pFlip->Flip.Alloc.segmentIdAlloc = pSrcAllocationList->SegmentId;
    3290                 pFlip->Flip.Alloc.offAlloc = (VBOXVIDEOOFFSET)pSrcAllocationList->PhysicalAddress.QuadPart;
    3291                 break;
    3292             }
    3293             case VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL:
    3294             {
    3295                 PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateDataBase;
    3296                 Assert(pPatch->PatchLocationListSubmissionLength == 1);
    3297                 const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart];
    3298                 Assert(pPatchList->AllocationIndex == DXGK_PRESENT_DESTINATION_INDEX);
    3299                 Assert(pPatchList->PatchOffset == 0);
    3300                 const DXGK_ALLOCATIONLIST *pDstAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    3301                 Assert(pDstAllocationList->SegmentId);
    3302                 pCF->ClrFill.Alloc.segmentIdAlloc = pDstAllocationList->SegmentId;
    3303                 pCF->ClrFill.Alloc.offAlloc = (VBOXVIDEOOFFSET)pDstAllocationList->PhysicalAddress.QuadPart;
    3304                 break;
    3305             }
    3306             case VBOXVDMACMD_TYPE_DMA_NOP:
    3307                 break;
    3308             case VBOXVDMACMD_TYPE_CHROMIUM_CMD:
    3309             {
    3310                 uint8_t * pPrivateBuf = (uint8_t*)pPrivateDataBase;
    3311                 for (UINT i = pPatch->PatchLocationListSubmissionStart; i < pPatch->PatchLocationListSubmissionLength; ++i)
    3312                 {
    3313                     const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[i];
    3314                     Assert(pPatchList->AllocationIndex < pPatch->AllocationListSize);
    3315                     const DXGK_ALLOCATIONLIST *pAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    3316                     Assert(pAllocationList->SegmentId);
    3317                     if (pAllocationList->SegmentId)
    3318                     {
    3319                         DXGK_ALLOCATIONLIST *pAllocation2Patch = (DXGK_ALLOCATIONLIST*)(pPrivateBuf + pPatchList->PatchOffset);
    3320                         pAllocation2Patch->SegmentId = pAllocationList->SegmentId;
    3321                         pAllocation2Patch->PhysicalAddress.QuadPart = pAllocationList->PhysicalAddress.QuadPart + pPatchList->AllocationOffset;
    3322                         Assert(!(pAllocationList->PhysicalAddress.QuadPart & 0xfffUL)); /* <- just a check to ensure allocation offset does not go here */
    3323                     }
    3324                 }
    3325                 break;
    3326             }
    3327             default:
    3328             {
    3329                 AssertBreakpoint();
    3330                 uint8_t *pBuf = ((uint8_t *)pPatch->pDmaBuffer) + pPatch->DmaBufferSubmissionStartOffset;
    3331                 for (UINT i = pPatch->PatchLocationListSubmissionStart; i < pPatch->PatchLocationListSubmissionLength; ++i)
    3332                 {
    3333                     const D3DDDI_PATCHLOCATIONLIST* pPatchList = &pPatch->pPatchLocationList[i];
    3334                     Assert(pPatchList->AllocationIndex < pPatch->AllocationListSize);
    3335                     const DXGK_ALLOCATIONLIST *pAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    3336                     if (pAllocationList->SegmentId)
    3337                     {
    3338                         Assert(pPatchList->PatchOffset < (pPatch->DmaBufferSubmissionEndOffset - pPatch->DmaBufferSubmissionStartOffset));
    3339                         *((VBOXVIDEOOFFSET*)(pBuf+pPatchList->PatchOffset)) = (VBOXVIDEOOFFSET)pAllocationList->PhysicalAddress.QuadPart;
    3340                     }
    3341                     else
    3342                     {
    3343                         /* sanity */
    3344                         if (pPatch->Flags.Value == 2 || pPatch->Flags.Value == 4)
    3345                             Assert(i == 0);
    3346                     }
    3347                 }
    3348                 break;
    3349             }
    3350         }
    3351     }
    3352     else if (pPatch->DmaBufferPrivateDataSubmissionEndOffset == pPatch->DmaBufferPrivateDataSubmissionStartOffset)
    3353     {
    3354         /* this is a NOP, just return success */
    3355 //        LOG(("null data size, treating as NOP"));
    3356         return STATUS_SUCCESS;
    3357     }
    3358     else
    3359     {
    3360         WARN(("DmaBufferPrivateDataSubmissionEndOffset (%d) - DmaBufferPrivateDataSubmissionStartOffset (%d) < sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR) (%d)",
    3361                 pPatch->DmaBufferPrivateDataSubmissionEndOffset,
    3362                 pPatch->DmaBufferPrivateDataSubmissionStartOffset,
    3363                 sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)));
    3364         return STATUS_INVALID_PARAMETER;
    3365     }
    3366 
    3367     LOGF(("LEAVE, context(0x%x)", hAdapter));
    3368 
    3369     return Status;
    3370 }
    3371 
    33723001typedef struct VBOXWDDM_CALL_ISR
    33733002{
     
    34033032}
    34043033
    3405 #ifdef VBOX_WITH_CRHGSMI
    3406 DECLCALLBACK(VOID) vboxWddmDmaCompleteChromiumCmd(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext)
    3407 {
    3408     RT_NOREF(pCmd);
    3409     PVBOXVDMACBUF_DR pDr = (PVBOXVDMACBUF_DR)pvContext;
    3410     vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
    3411 }
    3412 #endif
    3413 
    3414 #ifdef VBOX_WITH_CROGL
    3415 static NTSTATUS
    3416 APIENTRY
    3417 DxgkDdiSubmitCommandNew(
    3418     CONST HANDLE  hAdapter,
    3419     CONST DXGKARG_SUBMITCOMMAND*  pSubmitCommand)
    3420 {
    3421     /* DxgkDdiSubmitCommand runs at dispatch, should not be pageable. */
    3422 
    3423 #ifdef VBOX_WITH_MESA3D
    3424     if (((PVBOXMP_DEVEXT)hAdapter)->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    3425     {
    3426         return GaDxgkDdiSubmitCommand(hAdapter, pSubmitCommand);
    3427     }
    3428 #endif
    3429 
    3430 //    LOGF(("ENTER, context(0x%x)", hAdapter));
    3431 
    3432     vboxVDbgBreakFv();
    3433 
    3434     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)hAdapter;
    3435 #ifdef VBOX_STRICT
    3436     PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pSubmitCommand->hContext;
    3437     Assert(pContext);
    3438     Assert(pContext->pDevice);
    3439     Assert(pContext->pDevice->pAdapter == pDevExt);
    3440     Assert(!pSubmitCommand->DmaBufferSegmentId);
    3441 #endif
    3442 
    3443     uint32_t cbCmd = pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset - pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset;
    3444     uint32_t cbDma = pSubmitCommand->DmaBufferSubmissionEndOffset - pSubmitCommand->DmaBufferSubmissionStartOffset;
    3445     VBOXCMDVBVA_HDR *pHdr;
    3446     VBOXCMDVBVA_HDR NopCmd;
    3447     uint32_t cbCurCmd, cbCurDma;
    3448     if (cbCmd < sizeof (VBOXCMDVBVA_HDR))
    3449     {
    3450         if (cbCmd || cbDma)
    3451         {
    3452             WARN(("invalid command data"));
    3453             return STATUS_INVALID_PARAMETER;
    3454         }
    3455         Assert(!cbDma);
    3456         NopCmd.u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    3457         NopCmd.u8Flags = 0;
    3458         NopCmd.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    3459         NopCmd.u2.complexCmdEl.u16CbCmdHost = sizeof (VBOXCMDVBVA_HDR);
    3460         NopCmd.u2.complexCmdEl.u16CbCmdGuest = 0;
    3461         cbCmd = sizeof (VBOXCMDVBVA_HDR);
    3462         pHdr = &NopCmd;
    3463         cbCurCmd = sizeof (VBOXCMDVBVA_HDR);
    3464         cbCurDma = 0;
    3465     }
    3466     else
    3467     {
    3468         pHdr = (VBOXCMDVBVA_HDR*)(((uint8_t*)pSubmitCommand->pDmaBufferPrivateData) + pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset);
    3469         cbCurCmd = pHdr->u2.complexCmdEl.u16CbCmdHost;
    3470         cbCurDma = pHdr->u2.complexCmdEl.u16CbCmdGuest;
    3471     }
    3472 
    3473 
    3474     VBOXCMDVBVA_HDR *pDstHdr, *pCurDstCmd;
    3475     if (cbCmd != cbCurCmd || cbCurDma != cbDma)
    3476     {
    3477         if (cbCmd < cbCurCmd || cbDma < cbCurDma)
    3478         {
    3479             WARN(("incorrect buffer size"));
    3480             return STATUS_INVALID_PARAMETER;
    3481         }
    3482 
    3483         pDstHdr = VBoxCmdVbvaSubmitLock(pDevExt, &pDevExt->CmdVbva, cbCmd + sizeof (VBOXCMDVBVA_HDR));
    3484         if (!pDstHdr)
    3485         {
    3486             WARN(("VBoxCmdVbvaSubmitLock failed"));
    3487             return STATUS_UNSUCCESSFUL;
    3488         }
    3489 
    3490         pDstHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_COMPLEXCMD;
    3491         pDstHdr->u8Flags = 0;
    3492         pDstHdr->u.u8PrimaryID = 0;
    3493 
    3494         pCurDstCmd = pDstHdr + 1;
    3495     }
    3496     else
    3497     {
    3498         pDstHdr = VBoxCmdVbvaSubmitLock(pDevExt, &pDevExt->CmdVbva, cbCmd);
    3499         if (!pDstHdr)
    3500         {
    3501             WARN(("VBoxCmdVbvaSubmitLock failed"));
    3502             return STATUS_UNSUCCESSFUL;
    3503         }
    3504         pCurDstCmd = pDstHdr;
    3505     }
    3506 
    3507     PHYSICAL_ADDRESS phAddr;
    3508     phAddr.QuadPart = pSubmitCommand->DmaBufferPhysicalAddress.QuadPart + pSubmitCommand->DmaBufferSubmissionStartOffset;
    3509     NTSTATUS Status = STATUS_SUCCESS;
    3510     for (;;)
    3511     {
    3512         switch (pHdr->u8OpCode)
    3513         {
    3514             case VBOXCMDVBVA_OPTYPE_SYSMEMCMD:
    3515             {
    3516                 VBOXCMDVBVA_SYSMEMCMD *pSysMem = (VBOXCMDVBVA_SYSMEMCMD*)pHdr;
    3517                 if (pSubmitCommand->DmaBufferPhysicalAddress.QuadPart & PAGE_OFFSET_MASK)
    3518                 {
    3519                     WARN(("command should be page aligned for now"));
    3520                     return STATUS_INVALID_PARAMETER;
    3521                 }
    3522                 pSysMem->phCmd = (VBOXCMDVBVAPHADDR)(pSubmitCommand->DmaBufferPhysicalAddress.QuadPart + pSubmitCommand->DmaBufferSubmissionStartOffset);
    3523 #ifdef DEBUG
    3524                 {
    3525                     uint32_t cbRealDmaCmd = (pSysMem->Hdr.u8Flags | (pSysMem->Hdr.u.u8PrimaryID << 8));
    3526                     Assert(cbRealDmaCmd >= cbDma);
    3527                     if (cbDma < cbRealDmaCmd)
    3528                         WARN(("parrtial sysmem transfer"));
    3529                 }
    3530 #endif
    3531                 break;
    3532             }
    3533             default:
    3534                 break;
    3535         }
    3536 
    3537         memcpy(pCurDstCmd, pHdr, cbCurCmd);
    3538         pCurDstCmd->u2.complexCmdEl.u16CbCmdGuest = 0;
    3539 
    3540         phAddr.QuadPart += cbCurDma;
    3541         pHdr = (VBOXCMDVBVA_HDR*)(((uint8_t*)pHdr) + cbCurCmd);
    3542         pCurDstCmd = (VBOXCMDVBVA_HDR*)(((uint8_t*)pCurDstCmd) + cbCurCmd);
    3543         cbCmd -= cbCurCmd;
    3544         cbDma -= cbCurDma;
    3545         if (!cbCmd)
    3546         {
    3547             if (cbDma)
    3548             {
    3549                 WARN(("invalid param"));
    3550                 Status = STATUS_INVALID_PARAMETER;
    3551             }
    3552             break;
    3553         }
    3554 
    3555         if (cbCmd < sizeof (VBOXCMDVBVA_HDR))
    3556         {
    3557             WARN(("invalid param"));
    3558             Status = STATUS_INVALID_PARAMETER;
    3559             break;
    3560         }
    3561 
    3562         cbCurCmd = pHdr->u2.complexCmdEl.u16CbCmdHost;
    3563         cbCurDma = pHdr->u2.complexCmdEl.u16CbCmdGuest;
    3564 
    3565         if (cbCmd < cbCurCmd)
    3566         {
    3567             WARN(("invalid param"));
    3568             Status = STATUS_INVALID_PARAMETER;
    3569             break;
    3570         }
    3571 
    3572         if (cbDma < cbCurDma)
    3573         {
    3574             WARN(("invalid param"));
    3575             Status = STATUS_INVALID_PARAMETER;
    3576             break;
    3577         }
    3578     }
    3579 
    3580     uint32_t u32FenceId = pSubmitCommand->SubmissionFenceId;
    3581 
    3582     if (!NT_SUCCESS(Status))
    3583     {
    3584         /* nop the entire command on failure */
    3585         pDstHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    3586         pDstHdr->u8Flags = 0;
    3587         pDstHdr->u.i8Result = 0;
    3588         u32FenceId = 0;
    3589     }
    3590 
    3591     VBoxCmdVbvaSubmitUnlock(pDevExt, &pDevExt->CmdVbva, pDstHdr, u32FenceId);
    3592 
    3593     return Status;
    3594 }
    3595 #endif
    3596 
    3597 static NTSTATUS
    3598 APIENTRY
    3599 DxgkDdiSubmitCommandLegacy(
    3600     CONST HANDLE  hAdapter,
    3601     CONST DXGKARG_SUBMITCOMMAND*  pSubmitCommand)
    3602 {
    3603     /* DxgkDdiSubmitCommand runs at dispatch, should not be pageable. */
    3604     NTSTATUS Status = STATUS_SUCCESS;
    3605 
    3606 //    LOGF(("ENTER, context(0x%x)", hAdapter));
    3607 
    3608     vboxVDbgBreakFv();
    3609 
    3610     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)hAdapter;
    3611     PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pSubmitCommand->hContext;
    3612     PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pPrivateDataBase = NULL;
    3613     VBOXVDMACMD_TYPE enmCmd = VBOXVDMACMD_TYPE_UNDEFINED;
    3614     Assert(pContext);
    3615     Assert(pContext->pDevice);
    3616     Assert(pContext->pDevice->pAdapter == pDevExt);
    3617     Assert(!pSubmitCommand->DmaBufferSegmentId);
    3618 
    3619     /* the DMA command buffer is located in system RAM, the host will need to pick it from there */
    3620     //BufInfo.fFlags = 0; /* see VBOXVDMACBUF_FLAG_xx */
    3621     if (pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset - pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR))
    3622     {
    3623         pPrivateDataBase = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)((uint8_t*)pSubmitCommand->pDmaBufferPrivateData + pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset);
    3624         Assert(pPrivateDataBase);
    3625         enmCmd = pPrivateDataBase->enmCmd;
    3626     }
    3627     else if (pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset == pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset)
    3628     {
    3629         enmCmd = VBOXVDMACMD_TYPE_DMA_NOP;
    3630     }
    3631     else
    3632     {
    3633         WARN(("DmaBufferPrivateDataSubmissionEndOffset (%d) - DmaBufferPrivateDataSubmissionStartOffset (%d) < sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR) (%d)",
    3634                 pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset,
    3635                 pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset,
    3636                 sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)));
    3637         return STATUS_INVALID_PARAMETER;
    3638     }
    3639 
    3640     switch (enmCmd)
    3641     {
    3642         case VBOXVDMACMD_TYPE_DMA_PRESENT_BLT:
    3643         {
    3644             VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase;
    3645             PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateData;
    3646             PVBOXWDDM_ALLOCATION pDstAlloc = pBlt->Blt.DstAlloc.pAlloc;
    3647             PVBOXWDDM_ALLOCATION pSrcAlloc = pBlt->Blt.SrcAlloc.pAlloc;
    3648             BOOLEAN fSrcChanged;
    3649             BOOLEAN fDstChanged;
    3650 
    3651             fDstChanged = vboxWddmAddrSetVram(&pDstAlloc->AllocData.Addr, pBlt->Blt.DstAlloc.segmentIdAlloc, pBlt->Blt.DstAlloc.offAlloc);
    3652             fSrcChanged = vboxWddmAddrSetVram(&pSrcAlloc->AllocData.Addr, pBlt->Blt.SrcAlloc.segmentIdAlloc, pBlt->Blt.SrcAlloc.offAlloc);
    3653 
    3654             if (VBOXWDDM_IS_FB_ALLOCATION(pDevExt, pDstAlloc))
    3655             {
    3656                 Assert(pDstAlloc->AllocData.SurfDesc.VidPnSourceId < VBOX_VIDEO_MAX_SCREENS);
    3657 #if 0
    3658                 VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->AllocData.SurfDesc.VidPnSourceId];
    3659                 if (VBOXWDDM_IS_FB_ALLOCATION(pDevExt, pDstAlloc) && pDstAlloc->AllocData.hostID)
    3660                 {
    3661                     if (pSource->AllocData.hostID != pDstAlloc->AllocData.hostID)
    3662                     {
    3663                         pSource->AllocData.hostID = pDstAlloc->AllocData.hostID;
    3664                         fDstChanged = TRUE;
    3665                     }
    3666 
    3667                     if (fDstChanged)
    3668                         pSource->u8SyncState &= ~VBOXWDDM_HGSYNC_F_SYNCED_LOCATION;
    3669                 }
    3670 #endif
    3671             }
    3672 
    3673             Status = vboxVdmaProcessBltCmd(pDevExt, pContext, pBlt);
    3674             if (!NT_SUCCESS(Status))
    3675                 WARN(("vboxVdmaProcessBltCmd failed, Status 0x%x", Status));
    3676 
    3677             Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext->NodeOrdinal, pSubmitCommand->SubmissionFenceId,
    3678                     NT_SUCCESS(Status) ? DXGK_INTERRUPT_DMA_COMPLETED : DXGK_INTERRUPT_DMA_FAULTED);
    3679             break;
    3680         }
    3681         case VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP:
    3682         {
    3683             VBOXWDDM_DMA_PRIVATEDATA_FLIP *pFlip = (VBOXWDDM_DMA_PRIVATEDATA_FLIP*)pPrivateDataBase;
    3684             PVBOXWDDM_ALLOCATION pAlloc = pFlip->Flip.Alloc.pAlloc;
    3685             VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pAlloc->AllocData.SurfDesc.VidPnSourceId];
    3686             vboxWddmAddrSetVram(&pAlloc->AllocData.Addr, pFlip->Flip.Alloc.segmentIdAlloc, pFlip->Flip.Alloc.offAlloc);
    3687             vboxWddmAssignPrimary(pSource, pAlloc, pAlloc->AllocData.SurfDesc.VidPnSourceId);
    3688             vboxWddmGhDisplayCheckSetInfoFromSource(pDevExt, pSource);
    3689 
    3690             Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext->NodeOrdinal, pSubmitCommand->SubmissionFenceId,
    3691                     NT_SUCCESS(Status) ? DXGK_INTERRUPT_DMA_COMPLETED : DXGK_INTERRUPT_DMA_FAULTED);
    3692             break;
    3693         }
    3694         case VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL:
    3695         {
    3696             PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateDataBase;
    3697             vboxWddmAddrSetVram(&pCF->ClrFill.Alloc.pAlloc->AllocData.Addr, pCF->ClrFill.Alloc.segmentIdAlloc, pCF->ClrFill.Alloc.offAlloc);
    3698 
    3699             Status = vboxVdmaProcessClrFillCmd(pDevExt, pContext, pCF);
    3700             if (!NT_SUCCESS(Status))
    3701                 WARN(("vboxVdmaProcessClrFillCmd failed, Status 0x%x", Status));
    3702 
    3703             Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext->NodeOrdinal, pSubmitCommand->SubmissionFenceId,
    3704                     NT_SUCCESS(Status) ? DXGK_INTERRUPT_DMA_COMPLETED : DXGK_INTERRUPT_DMA_FAULTED);
    3705             break;
    3706         }
    3707         case VBOXVDMACMD_TYPE_DMA_NOP:
    3708         {
    3709             Status = vboxVdmaDdiCmdFenceComplete(pDevExt, pContext->NodeOrdinal, pSubmitCommand->SubmissionFenceId, DXGK_INTERRUPT_DMA_COMPLETED);
    3710             AssertNtStatusSuccess(Status);
    3711             break;
    3712         }
    3713         default:
    3714         {
    3715             WARN(("unexpected command %d", enmCmd));
    3716 #if 0 //def VBOX_WITH_VDMA
    3717             VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR *pPrivateData = (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR*)pPrivateDataBase;
    3718             PVBOXVDMACBUF_DR pDr = vboxVdmaCBufDrCreate (&pDevExt->u.primary.Vdma, 0);
    3719             if (!pDr)
    3720             {
    3721                 /** @todo try flushing.. */
    3722                 LOGREL(("vboxVdmaCBufDrCreate returned NULL"));
    3723                 return STATUS_INSUFFICIENT_RESOURCES;
    3724             }
    3725             // vboxVdmaCBufDrCreate zero initializes the pDr
    3726             //pDr->fFlags = 0;
    3727             pDr->cbBuf = pSubmitCommand->DmaBufferSubmissionEndOffset - pSubmitCommand->DmaBufferSubmissionStartOffset;
    3728             pDr->u32FenceId = pSubmitCommand->SubmissionFenceId;
    3729             pDr->rc = VERR_NOT_IMPLEMENTED;
    3730             if (pPrivateData)
    3731                 pDr->u64GuestContext = (uint64_t)pPrivateData->pContext;
    3732         //    else    // vboxVdmaCBufDrCreate zero initializes the pDr
    3733         //        pDr->u64GuestContext = NULL;
    3734             pDr->Location.phBuf = pSubmitCommand->DmaBufferPhysicalAddress.QuadPart + pSubmitCommand->DmaBufferSubmissionStartOffset;
    3735 
    3736             vboxVdmaCBufDrSubmit(pDevExt, &pDevExt->u.primary.Vdma, pDr);
    3737 #endif
    3738             break;
    3739         }
    3740     }
    3741 //    LOGF(("LEAVE, context(0x%x)", hAdapter));
    3742 
    3743     return Status;
    3744 }
    3745 
    3746 #ifdef VBOX_WITH_CROGL
    3747 static NTSTATUS
    3748 APIENTRY
    3749 DxgkDdiPreemptCommandNew(
    3750     CONST HANDLE  hAdapter,
    3751     CONST DXGKARG_PREEMPTCOMMAND*  pPreemptCommand)
    3752 {
    3753 #ifdef VBOX_WITH_MESA3D
    3754     if (((PVBOXMP_DEVEXT)hAdapter)->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    3755     {
    3756         return GaDxgkDdiPreemptCommand(hAdapter, pPreemptCommand);
    3757     }
    3758 #endif
    3759     LOGF(("ENTER, hAdapter(0x%x)", hAdapter));
    3760 
    3761     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)hAdapter;
    3762 
    3763     vboxVDbgBreakF();
    3764 
    3765     VBoxCmdVbvaPreempt(pDevExt, &pDevExt->CmdVbva, pPreemptCommand->PreemptionFenceId);
    3766 
    3767     LOGF(("LEAVE, hAdapter(0x%x)", hAdapter));
    3768 
    3769     return STATUS_SUCCESS;
    3770 }
    3771 #endif
    3772 
    3773 static NTSTATUS
    3774 APIENTRY
    3775 DxgkDdiPreemptCommandLegacy(
    3776     CONST HANDLE  hAdapter,
    3777     CONST DXGKARG_PREEMPTCOMMAND*  pPreemptCommand)
    3778 {
    3779     RT_NOREF(hAdapter, pPreemptCommand);
    3780     LOGF(("ENTER, hAdapter(0x%x)", hAdapter));
    3781 
    3782     AssertFailed();
    3783     /** @todo fixme: implement */
    3784 
    3785     LOGF(("LEAVE, hAdapter(0x%x)", hAdapter));
    3786 
    3787     return STATUS_SUCCESS;
    3788 }
    3789 
    3790 #ifdef VBOX_WITH_CROGL
    3791 /*
    3792  * DxgkDdiBuildPagingBuffer
    3793  */
    3794 static NTSTATUS
    3795 APIENTRY
    3796 DxgkDdiBuildPagingBufferNew(
    3797     CONST HANDLE  hAdapter,
    3798     DXGKARG_BUILDPAGINGBUFFER*  pBuildPagingBuffer)
    3799 {
    3800 #ifdef VBOX_WITH_MESA3D
    3801     if (((PVBOXMP_DEVEXT)hAdapter)->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    3802     {
    3803         return GaDxgkDdiBuildPagingBuffer(hAdapter, pBuildPagingBuffer);
    3804     }
    3805 #endif
    3806 
    3807     RT_NOREF(hAdapter);
    3808     /* DxgkDdiBuildPagingBuffer should be made pageable. */
    3809     PAGED_CODE();
    3810 
    3811     vboxVDbgBreakFv();
    3812 
    3813     uint32_t cbBuffer = 0, cbPrivateData = 0;
    3814 
    3815     LOGF(("ENTER context(0x%X), operation(0x%X) MultipassOffset(0x%X) DmaSizes(0x%X 0x%X)",
    3816         hAdapter, pBuildPagingBuffer->Operation, pBuildPagingBuffer->MultipassOffset,
    3817         pBuildPagingBuffer->DmaSize, pBuildPagingBuffer->DmaBufferPrivateDataSize));
    3818 
    3819     /* Checking for bare minimum of DMA buffer sizes*/
    3820     if (pBuildPagingBuffer->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_HDR))
    3821     {
    3822         WARN(("pBuildPagingBuffer->DmaBufferPrivateDataSize(%d) < sizeof (VBOXCMDVBVA_HDR)", pBuildPagingBuffer->DmaBufferPrivateDataSize));
    3823         return STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    3824     }
    3825 
    3826     if (pBuildPagingBuffer->DmaSize < VBOXWDDM_DUMMY_DMABUFFER_SIZE)
    3827     {
    3828         WARN(("pBuildPagingBuffer->DmaSize(%d) < VBOXWDDM_DUMMY_DMABUFFER_SIZE", pBuildPagingBuffer->DmaSize));
    3829         return STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    3830     }
    3831 
    3832     VBOXCMDVBVA_HDR *pHdr = (VBOXCMDVBVA_HDR*)pBuildPagingBuffer->pDmaBufferPrivateData;
    3833 
    3834     switch (pBuildPagingBuffer->Operation)
    3835     {
    3836         case DXGK_OPERATION_TRANSFER:
    3837         {
    3838 #if 0
    3839             if (!pBuildPagingBuffer->Transfer.Flags.AllocationIsIdle)
    3840             {
    3841                 WARN(("allocation is not idle"));
    3842                 return STATUS_GRAPHICS_ALLOCATION_BUSY;
    3843             }
    3844 #endif
    3845 
    3846             if (pBuildPagingBuffer->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_SYSMEMCMD))
    3847             {
    3848                 WARN(("private data too small"));
    3849                 return STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    3850             }
    3851 
    3852             Assert(!pBuildPagingBuffer->Transfer.MdlOffset);
    3853 
    3854             if ((!pBuildPagingBuffer->Transfer.Source.SegmentId) == (!pBuildPagingBuffer->Transfer.Destination.SegmentId))
    3855             {
    3856                 WARN(("we only support RAM <-> VRAM moves, Src Seg(%d), Dst Seg(%d)", pBuildPagingBuffer->Transfer.Source.SegmentId, pBuildPagingBuffer->Transfer.Destination.SegmentId));
    3857                 return STATUS_INVALID_PARAMETER;
    3858             }
    3859 
    3860             PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pBuildPagingBuffer->Transfer.hAllocation;
    3861             if (!pAlloc)
    3862             {
    3863                 WARN(("allocation is null"));
    3864                 return STATUS_INVALID_PARAMETER;
    3865             }
    3866 
    3867             if (pAlloc->AllocData.hostID)
    3868             {
    3869                 cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    3870                 cbPrivateData = sizeof (*pHdr);
    3871 
    3872                 pHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    3873                 pHdr->u8Flags = 0;
    3874                 pHdr->u.u8PrimaryID = 0;
    3875                 pHdr->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    3876                 break;
    3877             }
    3878 
    3879             if (pBuildPagingBuffer->DmaSize < sizeof (VBOXCMDVBVA_PAGING_TRANSFER))
    3880             {
    3881                 WARN(("pBuildPagingBuffer->DmaSize(%d) < sizeof VBOXCMDVBVA_PAGING_TRANSFER (%d)", pBuildPagingBuffer->DmaSize , sizeof (VBOXCMDVBVA_PAGING_TRANSFER)));
    3882                 /** @todo can this actually happen? what status to return? */
    3883                 return STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    3884             }
    3885 
    3886             VBOXCMDVBVA_PAGING_TRANSFER *pPaging = (VBOXCMDVBVA_PAGING_TRANSFER*)pBuildPagingBuffer->pDmaBuffer;
    3887             pPaging->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_PAGING_TRANSFER;
    3888             /* sanity */
    3889             pPaging->Hdr.u8Flags = 0;
    3890             pPaging->Hdr.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    3891 
    3892             PMDL pMdl;
    3893             uint32_t offVRAM;
    3894             BOOLEAN fIn;
    3895             UINT SegmentId;
    3896 
    3897             if (pBuildPagingBuffer->Transfer.Source.SegmentId)
    3898             {
    3899                 SegmentId = pBuildPagingBuffer->Transfer.Source.SegmentId;
    3900                 Assert(!pBuildPagingBuffer->Transfer.Destination.SegmentId);
    3901                 Assert(!pBuildPagingBuffer->Transfer.Source.SegmentAddress.HighPart);
    3902                 offVRAM = pBuildPagingBuffer->Transfer.Source.SegmentAddress.LowPart;
    3903                 pMdl = pBuildPagingBuffer->Transfer.Destination.pMdl;
    3904                 fIn = FALSE;
    3905             }
    3906             else
    3907             {
    3908                 SegmentId = pBuildPagingBuffer->Transfer.Destination.SegmentId;
    3909                 Assert(pBuildPagingBuffer->Transfer.Destination.SegmentId);
    3910                 Assert(!pBuildPagingBuffer->Transfer.Source.SegmentId);
    3911                 Assert(!pBuildPagingBuffer->Transfer.Destination.SegmentAddress.HighPart);
    3912                 offVRAM = pBuildPagingBuffer->Transfer.Destination.SegmentAddress.LowPart;
    3913                 pMdl = pBuildPagingBuffer->Transfer.Source.pMdl;
    3914                 fIn = TRUE;
    3915             }
    3916 
    3917             if (SegmentId != 1)
    3918             {
    3919                 WARN(("SegmentId"));
    3920                 cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    3921                 break;
    3922             }
    3923 
    3924             Assert(!(pBuildPagingBuffer->Transfer.TransferSize & PAGE_OFFSET_MASK));
    3925             Assert(!(offVRAM & PAGE_OFFSET_MASK));
    3926             uint32_t cPages = (uint32_t)(pBuildPagingBuffer->Transfer.TransferSize >> PAGE_SHIFT);
    3927             Assert(cPages > pBuildPagingBuffer->MultipassOffset);
    3928             cPages -= pBuildPagingBuffer->MultipassOffset;
    3929             uint32_t iFirstPage = pBuildPagingBuffer->MultipassOffset;
    3930             uint32_t cPagesWritten;
    3931             offVRAM += pBuildPagingBuffer->Transfer.TransferOffset + (pBuildPagingBuffer->MultipassOffset << PAGE_SHIFT);
    3932 
    3933             pPaging->Data.Alloc.u.offVRAM = offVRAM;
    3934             if (fIn)
    3935                 pPaging->Hdr.u8Flags |= VBOXCMDVBVA_OPF_PAGING_TRANSFER_IN;
    3936             cbBuffer = VBoxCVDdiPTransferVRamSysBuildEls(pPaging, pMdl, iFirstPage, cPages, pBuildPagingBuffer->DmaSize, &cPagesWritten);
    3937             if (cPagesWritten != cPages)
    3938                 pBuildPagingBuffer->MultipassOffset += cPagesWritten;
    3939             else
    3940                 pBuildPagingBuffer->MultipassOffset = 0;
    3941 
    3942             VBOXCMDVBVA_SYSMEMCMD *pSysMemCmd = (VBOXCMDVBVA_SYSMEMCMD*)pBuildPagingBuffer->pDmaBufferPrivateData;
    3943 
    3944             cbPrivateData = sizeof (*pSysMemCmd);
    3945 
    3946             pSysMemCmd->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_SYSMEMCMD;
    3947             pSysMemCmd->Hdr.u8Flags = cbBuffer & 0xff;
    3948             pSysMemCmd->Hdr.u.u8PrimaryID = (cbBuffer >> 8) & 0xff;
    3949             pSysMemCmd->Hdr.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    3950             pSysMemCmd->phCmd = 0;
    3951 
    3952             break;
    3953         }
    3954         case DXGK_OPERATION_FILL:
    3955         {
    3956             Assert(pBuildPagingBuffer->Fill.FillPattern == 0);
    3957             PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pBuildPagingBuffer->Fill.hAllocation;
    3958             if (!pAlloc)
    3959             {
    3960                 WARN(("allocation is null"));
    3961                 return STATUS_INVALID_PARAMETER;
    3962             }
    3963 
    3964             if (pAlloc->AllocData.hostID || pBuildPagingBuffer->Fill.Destination.SegmentId != 1)
    3965             {
    3966                 if (!pAlloc->AllocData.hostID)
    3967                 {
    3968                     WARN(("unexpected segment id"));
    3969                 }
    3970 
    3971                 cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    3972                 cbPrivateData = sizeof (*pHdr);
    3973 
    3974                 pHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    3975                 pHdr->u8Flags = 0;
    3976                 pHdr->u.u8PrimaryID = 0;
    3977                 pHdr->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    3978                 break;
    3979             }
    3980 
    3981             if (pBuildPagingBuffer->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_PAGING_FILL))
    3982             {
    3983                 WARN(("private data too small"));
    3984                 return STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    3985             }
    3986 
    3987             VBOXCMDVBVA_PAGING_FILL *pFill = (VBOXCMDVBVA_PAGING_FILL*)pBuildPagingBuffer->pDmaBufferPrivateData;
    3988             pFill->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_PAGING_FILL;
    3989             pFill->Hdr.u8Flags = 0;
    3990             pFill->Hdr.u.u8PrimaryID = 0;
    3991             pFill->Hdr.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    3992             pFill->u32CbFill = (uint32_t)pBuildPagingBuffer->Fill.FillSize;
    3993             pFill->u32Pattern = pBuildPagingBuffer->Fill.FillPattern;
    3994             Assert(!pBuildPagingBuffer->Fill.Destination.SegmentAddress.HighPart);
    3995             pFill->offVRAM = pBuildPagingBuffer->Fill.Destination.SegmentAddress.LowPart;
    3996 
    3997             cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    3998             cbPrivateData = sizeof (*pFill);
    3999 
    4000             break;
    4001         }
    4002         case DXGK_OPERATION_DISCARD_CONTENT:
    4003         {
    4004             PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pBuildPagingBuffer->DiscardContent.hAllocation;
    4005             if (!pAlloc)
    4006             {
    4007                 WARN(("allocation is null"));
    4008                 return STATUS_INVALID_PARAMETER;
    4009             }
    4010 //            WARN(("Do we need to do anything here?"));
    4011             break;
    4012         }
    4013         default:
    4014         {
    4015             WARN(("unsupported op (%d)", pBuildPagingBuffer->Operation));
    4016             break;
    4017         }
    4018     }
    4019 
    4020     Assert(cbPrivateData >= sizeof (VBOXCMDVBVA_HDR) || pBuildPagingBuffer->Operation == DXGK_OPERATION_DISCARD_CONTENT);
    4021     Assert(pBuildPagingBuffer->Operation == DXGK_OPERATION_DISCARD_CONTENT || cbBuffer);
    4022     Assert(cbBuffer <= pBuildPagingBuffer->DmaSize);
    4023     Assert(cbBuffer == 0 || cbBuffer >= sizeof (VBOXCMDVBVA_PAGING_TRANSFER) || cbBuffer == VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    4024     AssertCompile(VBOXWDDM_DUMMY_DMABUFFER_SIZE < 8);
    4025 
    4026     pHdr->u2.complexCmdEl.u16CbCmdHost = cbPrivateData;
    4027     pHdr->u2.complexCmdEl.u16CbCmdGuest = cbBuffer;
    4028 
    4029     pBuildPagingBuffer->pDmaBuffer = ((uint8_t*)pBuildPagingBuffer->pDmaBuffer) + cbBuffer;
    4030     pBuildPagingBuffer->pDmaBufferPrivateData = ((uint8_t*)pBuildPagingBuffer->pDmaBufferPrivateData) + cbPrivateData;
    4031 
    4032     LOGF(("LEAVE context(0x%X), MultipassOffset(0x%X) cbBuffer(0x%X) cbPrivateData(0x%X)",
    4033         hAdapter, pBuildPagingBuffer->MultipassOffset, cbBuffer, cbPrivateData));
    4034 
    4035     if (pBuildPagingBuffer->MultipassOffset)
    4036         return STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    4037     return STATUS_SUCCESS;
    4038 }
    4039 #endif
    4040 
    4041 static NTSTATUS
    4042 APIENTRY
    4043 DxgkDdiBuildPagingBufferLegacy(
    4044     CONST HANDLE  hAdapter,
    4045     DXGKARG_BUILDPAGINGBUFFER*  pBuildPagingBuffer)
    4046 {
    4047     /* DxgkDdiBuildPagingBuffer should be made pageable. */
    4048     PAGED_CODE();
    4049 
    4050     vboxVDbgBreakFv();
    4051 
    4052     NTSTATUS Status = STATUS_SUCCESS;
    4053     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)hAdapter;
    4054 
    4055     LOGF(("ENTER, context(0x%x)", hAdapter));
    4056 
    4057     uint32_t cbCmdDma = 0;
    4058 
    4059     /** @todo */
    4060     switch (pBuildPagingBuffer->Operation)
    4061     {
    4062         case DXGK_OPERATION_TRANSFER:
    4063         {
    4064             cbCmdDma = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    4065 #ifdef VBOX_WITH_VDMA
    4066 #if 0
    4067             if ((!pBuildPagingBuffer->Transfer.Source.SegmentId) != (!pBuildPagingBuffer->Transfer.Destination.SegmentId))
    4068             {
    4069                 PVBOXVDMACMD pCmd = (PVBOXVDMACMD)pBuildPagingBuffer->pDmaBuffer;
    4070                 pCmd->enmType = VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER_VRAMSYS;
    4071                 pCmd->u32CmdSpecific = 0;
    4072                 PVBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS pBody = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS);
    4073                 PMDL pMdl;
    4074                 uint32_t cPages = (pBuildPagingBuffer->Transfer.TransferSize + 0xfff) >> 12;
    4075                 cPages -= pBuildPagingBuffer->MultipassOffset;
    4076                 uint32_t iFirstPage = pBuildPagingBuffer->Transfer.MdlOffset + pBuildPagingBuffer->MultipassOffset;
    4077                 uint32_t cPagesRemaining;
    4078                 if (pBuildPagingBuffer->Transfer.Source.SegmentId)
    4079                 {
    4080                     uint64_t off = pBuildPagingBuffer->Transfer.Source.SegmentAddress.QuadPart;
    4081                     off += pBuildPagingBuffer->Transfer.TransferOffset + (pBuildPagingBuffer->MultipassOffset << PAGE_SHIFT);
    4082                     pBody->offVramBuf = off;
    4083                     pMdl = pBuildPagingBuffer->Transfer.Source.pMdl;
    4084                     pBody->fFlags = 0;//VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM
    4085                 }
    4086                 else
    4087                 {
    4088                     uint64_t off = pBuildPagingBuffer->Transfer.Destination.SegmentAddress.QuadPart;
    4089                     off += pBuildPagingBuffer->Transfer.TransferOffset + (pBuildPagingBuffer->MultipassOffset << PAGE_SHIFT);
    4090                     pBody->offVramBuf = off;
    4091                     pMdl = pBuildPagingBuffer->Transfer.Destination.pMdl;
    4092                     pBody->fFlags = VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM;
    4093                 }
    4094 
    4095                 uint32_t sbBufferUsed = vboxWddmBpbTransferVRamSysBuildEls(pBody, pMdl, iFirstPage, cPages, pBuildPagingBuffer->DmaSize, &cPagesRemaining);
    4096                 Assert(sbBufferUsed);
    4097             }
    4098 
    4099 #else
    4100             PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pBuildPagingBuffer->Transfer.hAllocation;
    4101             Assert(pAlloc);
    4102             if (pAlloc
    4103                     && !pAlloc->fRcFlags.Overlay /* overlay surfaces actually contain a valid data */
    4104                     && pAlloc->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE  /* shadow primary - also */
    4105                     && pAlloc->enmType != VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER /* hgsmi buffer - also */
    4106                     )
    4107             {
    4108                 /* we do not care about the others for now */
    4109                 Status = STATUS_SUCCESS;
    4110                 break;
    4111             }
    4112             UINT cbCmd = VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_BPB_TRANSFER);
    4113             VBOXVDMACBUF_DR RT_UNTRUSTED_VOLATILE_HOST *pDr = vboxVdmaCBufDrCreate(&pDevExt->u.primary.Vdma, cbCmd);
    4114             Assert(pDr);
    4115             if (pDr)
    4116             {
    4117                 SIZE_T cbTransfered = 0;
    4118                 SIZE_T cbTransferSize = pBuildPagingBuffer->Transfer.TransferSize;
    4119                 VBOXVDMACMD RT_UNTRUSTED_VOLATILE_HOST *pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
    4120                 do
    4121                 {
    4122                     // vboxVdmaCBufDrCreate zero initializes the pDr
    4123                     pDr->fFlags = VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR;
    4124                     pDr->cbBuf = cbCmd;
    4125                     pDr->rc = VERR_NOT_IMPLEMENTED;
    4126 
    4127                     pHdr->enmType = VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER;
    4128                     pHdr->u32CmdSpecific = 0;
    4129                     VBOXVDMACMD_DMA_BPB_TRANSFER RT_UNTRUSTED_VOLATILE_HOST *pBody
    4130                         = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_DMA_BPB_TRANSFER);
    4131 //                    pBody->cbTransferSize = (uint32_t)pBuildPagingBuffer->Transfer.TransferSize;
    4132                     pBody->fFlags = 0;
    4133                     SIZE_T cSrcPages = (cbTransferSize + 0xfff ) >> 12;
    4134                     SIZE_T cDstPages = cSrcPages;
    4135 
    4136                     if (pBuildPagingBuffer->Transfer.Source.SegmentId)
    4137                     {
    4138                         uint64_t off = pBuildPagingBuffer->Transfer.Source.SegmentAddress.QuadPart;
    4139                         off += pBuildPagingBuffer->Transfer.TransferOffset + cbTransfered;
    4140                         pBody->Src.offVramBuf = off;
    4141                         pBody->fFlags |= VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET;
    4142                     }
    4143                     else
    4144                     {
    4145                         UINT index = pBuildPagingBuffer->Transfer.MdlOffset + (UINT)(cbTransfered>>12);
    4146                         pBody->Src.phBuf = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[index] << PAGE_SHIFT;
    4147                         PFN_NUMBER num = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[index];
    4148                         cSrcPages = 1;
    4149                         for (UINT i = 1; i < ((cbTransferSize - cbTransfered + 0xfff) >> 12); ++i)
    4150                         {
    4151                             PFN_NUMBER cur = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Source.pMdl)[index+i];
    4152                             if(cur != ++num)
    4153                             {
    4154                                 cSrcPages+= i-1;
    4155                                 break;
    4156                             }
    4157                         }
    4158                     }
    4159 
    4160                     if (pBuildPagingBuffer->Transfer.Destination.SegmentId)
    4161                     {
    4162                         uint64_t off = pBuildPagingBuffer->Transfer.Destination.SegmentAddress.QuadPart;
    4163                         off += pBuildPagingBuffer->Transfer.TransferOffset;
    4164                         pBody->Dst.offVramBuf = off + cbTransfered;
    4165                         pBody->fFlags |= VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET;
    4166                     }
    4167                     else
    4168                     {
    4169                         UINT index = pBuildPagingBuffer->Transfer.MdlOffset + (UINT)(cbTransfered>>12);
    4170                         pBody->Dst.phBuf = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[index] << PAGE_SHIFT;
    4171                         PFN_NUMBER num = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[index];
    4172                         cDstPages = 1;
    4173                         for (UINT i = 1; i < ((cbTransferSize - cbTransfered + 0xfff) >> 12); ++i)
    4174                         {
    4175                             PFN_NUMBER cur = MmGetMdlPfnArray(pBuildPagingBuffer->Transfer.Destination.pMdl)[index+i];
    4176                             if(cur != ++num)
    4177                             {
    4178                                 cDstPages+= i-1;
    4179                                 break;
    4180                             }
    4181                         }
    4182                     }
    4183 
    4184                     SIZE_T cbCurTransfer;
    4185                     cbCurTransfer = RT_MIN(cbTransferSize - cbTransfered, (SIZE_T)cSrcPages << PAGE_SHIFT);
    4186                     cbCurTransfer = RT_MIN(cbCurTransfer, (SIZE_T)cDstPages << PAGE_SHIFT);
    4187 
    4188                     pBody->cbTransferSize = (UINT)cbCurTransfer;
    4189                     Assert(!(cbCurTransfer & 0xfff));
    4190 
    4191                     int rc = vboxVdmaCBufDrSubmitSynch(pDevExt, &pDevExt->u.primary.Vdma, pDr);
    4192                     AssertRC(rc);
    4193                     if (RT_SUCCESS(rc))
    4194                     {
    4195                         Status = STATUS_SUCCESS;
    4196                         cbTransfered += cbCurTransfer;
    4197                     }
    4198                     else
    4199                         Status = STATUS_UNSUCCESSFUL;
    4200                 } while (cbTransfered < cbTransferSize);
    4201                 Assert(cbTransfered == cbTransferSize);
    4202                 vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
    4203             }
    4204             else
    4205             {
    4206                 /** @todo try flushing.. */
    4207                 LOGREL(("vboxVdmaCBufDrCreate returned NULL"));
    4208                 Status = STATUS_INSUFFICIENT_RESOURCES;
    4209             }
    4210 #endif
    4211 #endif /* #ifdef VBOX_WITH_VDMA */
    4212             break;
    4213         }
    4214         case DXGK_OPERATION_FILL:
    4215         {
    4216             cbCmdDma = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    4217             Assert(pBuildPagingBuffer->Fill.FillPattern == 0);
    4218             /*PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pBuildPagingBuffer->Fill.hAllocation; - unused. Incomplete code? */
    4219 //            pBuildPagingBuffer->pDmaBuffer = (uint8_t*)pBuildPagingBuffer->pDmaBuffer + VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_BPB_FILL);
    4220             break;
    4221         }
    4222         case DXGK_OPERATION_DISCARD_CONTENT:
    4223         {
    4224 //            AssertBreakpoint();
    4225             break;
    4226         }
    4227         default:
    4228         {
    4229             WARN(("unsupported op (%d)", pBuildPagingBuffer->Operation));
    4230             break;
    4231         }
    4232     }
    4233 
    4234     if (cbCmdDma)
    4235     {
    4236         pBuildPagingBuffer->pDmaBuffer = ((uint8_t*)pBuildPagingBuffer->pDmaBuffer) + cbCmdDma;
    4237     }
    4238 
    4239     LOGF(("LEAVE, context(0x%x)", hAdapter));
    4240 
    4241     return Status;
    4242 
    4243 }
    42443034
    42453035NTSTATUS
     
    45663356        switch (pEscapeHdr->escapeCode)
    45673357        {
    4568 #ifdef VBOX_WITH_CRHGSMI
    4569             case VBOXESC_UHGSMI_SUBMIT:
    4570             {
    4571                 if (pDevExt->fCmdVbvaEnabled)
    4572                 {
    4573                     WARN(("VBOXESC_UHGSMI_SUBMIT not supported for CmdVbva mode"));
    4574                     Status = STATUS_INVALID_PARAMETER;
    4575                     break;
    4576                 }
    4577                 /* submit VBOXUHGSMI command */
    4578                 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
    4579                 PVBOXDISPIFESCAPE_UHGSMI_SUBMIT pSubmit = (PVBOXDISPIFESCAPE_UHGSMI_SUBMIT)pEscapeHdr;
    4580                 Assert(pEscape->PrivateDriverDataSize >= sizeof (VBOXDISPIFESCAPE_UHGSMI_SUBMIT)
    4581                         && pEscape->PrivateDriverDataSize == RT_UOFFSETOF_DYN(VBOXDISPIFESCAPE_UHGSMI_SUBMIT, aBuffers[pEscapeHdr->u32CmdSpecific]));
    4582                 if (   pEscape->PrivateDriverDataSize >= sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD)
    4583                     && pEscape->PrivateDriverDataSize == RT_UOFFSETOF_DYN(VBOXDISPIFESCAPE_UHGSMI_SUBMIT, aBuffers[pEscapeHdr->u32CmdSpecific]))
    4584                 {
    4585                     Status = vboxVideoAMgrCtxAllocSubmit(pDevExt, &pContext->AllocContext, pEscapeHdr->u32CmdSpecific, pSubmit->aBuffers);
    4586                     AssertNtStatusSuccess(Status);
    4587                 }
    4588                 else
    4589                     Status = STATUS_BUFFER_TOO_SMALL;
    4590 
    4591                 break;
    4592             }
    4593 
    4594             case VBOXESC_UHGSMI_ALLOCATE:
    4595             {
    4596                 /* allocate VBOXUHGSMI buffer */
    4597                 if (pDevExt->fCmdVbvaEnabled)
    4598                 {
    4599                     WARN(("VBOXESC_UHGSMI_ALLOCATE not supported for CmdVbva mode"));
    4600                     Status = STATUS_INVALID_PARAMETER;
    4601                     break;
    4602                 }
    4603 
    4604                 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
    4605                 PVBOXDISPIFESCAPE_UHGSMI_ALLOCATE pAlocate = (PVBOXDISPIFESCAPE_UHGSMI_ALLOCATE)pEscapeHdr;
    4606                 Assert(pEscape->PrivateDriverDataSize == sizeof (VBOXDISPIFESCAPE_UHGSMI_ALLOCATE));
    4607                 if (pEscape->PrivateDriverDataSize == sizeof (VBOXDISPIFESCAPE_UHGSMI_ALLOCATE))
    4608                 {
    4609                     Status = vboxVideoAMgrCtxAllocCreate(&pContext->AllocContext, &pAlocate->Alloc);
    4610                     AssertNtStatusSuccess(Status);
    4611                 }
    4612                 else
    4613                     Status = STATUS_BUFFER_TOO_SMALL;
    4614 
    4615                 break;
    4616             }
    4617 
    4618             case VBOXESC_UHGSMI_DEALLOCATE:
    4619             {
    4620                 if (pDevExt->fCmdVbvaEnabled)
    4621                 {
    4622                     WARN(("VBOXESC_UHGSMI_DEALLOCATE not supported for CmdVbva mode"));
    4623                     Status = STATUS_INVALID_PARAMETER;
    4624                     break;
    4625                 }
    4626                 /* deallocate VBOXUHGSMI buffer */
    4627                 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
    4628                 PVBOXDISPIFESCAPE_UHGSMI_DEALLOCATE pDealocate = (PVBOXDISPIFESCAPE_UHGSMI_DEALLOCATE)pEscapeHdr;
    4629                 Assert(pEscape->PrivateDriverDataSize == sizeof (VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE));
    4630                 if (pEscape->PrivateDriverDataSize == sizeof (VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE))
    4631                 {
    4632                     Status = vboxVideoAMgrCtxAllocDestroy(&pContext->AllocContext, pDealocate->hAlloc);
    4633                     AssertNtStatusSuccess(Status);
    4634                 }
    4635                 else
    4636                     Status = STATUS_BUFFER_TOO_SMALL;
    4637 
    4638                 break;
    4639             }
    4640 
    4641             case VBOXESC_CRHGSMICTLCON_CALL:
    4642             {
    4643                 if (pDevExt->fCmdVbvaEnabled)
    4644                 {
    4645                     WARN(("VBOXESC_CRHGSMICTLCON_CALL not supported for CmdVbva mode"));
    4646                     Status = STATUS_INVALID_PARAMETER;
    4647                     break;
    4648                 }
    4649 
    4650                 PVBOXDISPIFESCAPE_CRHGSMICTLCON_CALL pCall = (PVBOXDISPIFESCAPE_CRHGSMICTLCON_CALL)pEscapeHdr;
    4651                 if (pEscape->PrivateDriverDataSize >= sizeof (*pCall))
    4652                 {
    4653                     /* this is true due to the above condition */
    4654                     Assert(pEscape->PrivateDriverDataSize > RT_OFFSETOF(VBOXDISPIFESCAPE_CRHGSMICTLCON_CALL, CallInfo));
    4655                     int rc = VBoxMpCrCtlConCallUserData(&pDevExt->CrCtlCon, &pCall->CallInfo, pEscape->PrivateDriverDataSize - RT_OFFSETOF(VBOXDISPIFESCAPE_CRHGSMICTLCON_CALL, CallInfo));
    4656                     pEscapeHdr->u32CmdSpecific = (uint32_t)rc;
    4657                     Status = STATUS_SUCCESS; /* <- always return success here, otherwise the private data buffer modifications
    4658                                               * i.e. rc status stored in u32CmdSpecific will not be copied to user mode */
    4659                     if (!RT_SUCCESS(rc))
    4660                         WARN(("VBoxMpCrUmCtlConCall failed, rc(%d)", rc));
    4661                 }
    4662                 else
    4663                 {
    4664                     WARN(("buffer too small!"));
    4665                     Status = STATUS_BUFFER_TOO_SMALL;
    4666                 }
    4667 
    4668                 break;
    4669             }
    4670 
    4671             case VBOXESC_CRHGSMICTLCON_GETCLIENTID:
    4672             {
    4673                 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
    4674                 if (!pContext)
    4675                 {
    4676                     WARN(("context not specified"));
    4677                     return STATUS_INVALID_PARAMETER;
    4678                 }
    4679                 if (pEscape->PrivateDriverDataSize == sizeof (*pEscapeHdr))
    4680                 {
    4681                     pEscapeHdr->u32CmdSpecific = pContext->u32CrConClientID;
    4682                     Status = STATUS_SUCCESS;
    4683                 }
    4684                 else
    4685                 {
    4686                     WARN(("unexpected buffer size!"));
    4687                     Status = STATUS_INVALID_PARAMETER;
    4688                 }
    4689 
    4690                 break;
    4691             }
    4692 
    4693             case VBOXESC_CRHGSMICTLCON_GETHOSTCAPS:
    4694             {
    4695                 if (pEscape->PrivateDriverDataSize == sizeof (*pEscapeHdr))
    4696                 {
    4697                     if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX)
    4698                         pEscapeHdr->u32CmdSpecific = VBoxMpCrGetHostCaps();
    4699 #ifdef VBOX_WITH_MESA3D
    4700                     else if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    4701                         /** @todo User-mode driver probably should not need it in Gallium mode. */
    4702                         pEscapeHdr->u32CmdSpecific = CR_VBOX_CAP_TEX_PRESENT | CR_VBOX_CAP_CMDVBVA;
    4703 #endif
    4704                     else
    4705                         pEscapeHdr->u32CmdSpecific = 0;
    4706                     Status = STATUS_SUCCESS;
    4707                 }
    4708                 else
    4709                 {
    4710                     WARN(("unexpected buffer size!"));
    4711                     Status = STATUS_INVALID_PARAMETER;
    4712                 }
    4713 
    4714                 break;
    4715             }
    4716 #endif
    4717 
    47183358            case VBOXESC_SETVISIBLEREGION:
    47193359            {
     
    47973437                Status = STATUS_SUCCESS;
    47983438                break;
    4799 #ifdef VBOX_WITH_CROGL
    4800             case VBOXESC_SETCTXHOSTID:
    4801             {
    4802                 /* set swapchain information */
    4803                 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
    4804                 if (!pContext)
    4805                 {
    4806                     WARN(("VBOXESC_SETCTXHOSTID: no context specified"));
    4807                     Status = STATUS_INVALID_PARAMETER;
    4808                     break;
    4809                 }
    4810 
    4811                 if (pEscape->PrivateDriverDataSize != sizeof (VBOXDISPIFESCAPE))
    4812                 {
    4813                     WARN(("VBOXESC_SETCTXHOSTID: invalid data size %d", pEscape->PrivateDriverDataSize));
    4814                     Status = STATUS_INVALID_PARAMETER;
    4815                     break;
    4816                 }
    4817 
    4818                 int32_t hostID = (int32_t)pEscapeHdr->u32CmdSpecific;
    4819                 if (hostID <= 0)
    4820                 {
    4821                     WARN(("VBOXESC_SETCTXHOSTID: invalid hostID %d", hostID));
    4822                     Status = STATUS_INVALID_PARAMETER;
    4823                     break;
    4824                 }
    4825 
    4826                 if (pContext->hostID)
    4827                 {
    4828                     WARN(("VBOXESC_SETCTXHOSTID: context already has hostID specified"));
    4829                     Status = STATUS_INVALID_PARAMETER;
    4830                     break;
    4831                 }
    4832 
    4833                 pContext->hostID = hostID;
    4834                 Status = STATUS_SUCCESS;
    4835                 break;
    4836             }
    4837             case VBOXESC_SWAPCHAININFO:
    4838             {
    4839                 /* set swapchain information */
    4840                 PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)pEscape->hContext;
    4841                 Status = vboxWddmSwapchainCtxEscape(pDevExt, pContext, (PVBOXDISPIFESCAPE_SWAPCHAININFO)pEscapeHdr, pEscape->PrivateDriverDataSize);
    4842                 AssertNtStatusSuccess(Status);
    4843                 break;
    4844             }
    4845 #endif
    48463439            case VBOXESC_CONFIGURETARGETS:
    48473440            {
     
    52433836}
    52443837
    5245 typedef struct VBOXWDDM_QUERYCURFENCE_CB
    5246 {
    5247     PVBOXMP_DEVEXT pDevExt;
    5248     ULONG MessageNumber;
    5249     ULONG uLastCompletedCmdFenceId;
    5250 } VBOXWDDM_QUERYCURFENCE_CB, *PVBOXWDDM_QUERYCURFENCE_CB;
    5251 
    5252 static BOOLEAN vboxWddmQueryCurrentFenceCb(PVOID Context)
    5253 {
    5254     PVBOXWDDM_QUERYCURFENCE_CB pdc = (PVBOXWDDM_QUERYCURFENCE_CB)Context;
    5255     PVBOXMP_DEVEXT pDevExt = pdc->pDevExt;
    5256     BOOL bRc = DxgkDdiInterruptRoutineLegacy(pDevExt, pdc->MessageNumber);
    5257     pdc->uLastCompletedCmdFenceId = pDevExt->u.primary.Vdma.uLastCompletedPagingBufferCmdFenceId;
    5258     return bRc;
    5259 }
    5260 
    5261 #ifdef VBOX_WITH_CROGL
    5262 static NTSTATUS
    5263 APIENTRY
    5264 DxgkDdiQueryCurrentFenceNew(
    5265     CONST HANDLE  hAdapter,
    5266     DXGKARG_QUERYCURRENTFENCE*  pCurrentFence)
    5267 {
    5268 #ifdef VBOX_WITH_MESA3D
    5269     if (((PVBOXMP_DEVEXT)hAdapter)->enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    5270     {
    5271         return GaDxgkDdiQueryCurrentFence(hAdapter, pCurrentFence);
    5272     }
    5273 #endif
    5274     LOGF(("ENTER, hAdapter(0x%x)", hAdapter));
    5275 
    5276     vboxVDbgBreakF();
    5277 
    5278     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)hAdapter;
    5279 
    5280     WARN(("=>DxgkDdiQueryCurrentFenceNew"));
    5281 
    5282     uint32_t u32FenceSubmitted = 0;
    5283     uint32_t u32FenceCompleted = 0;
    5284     uint32_t u32FenceProcessed = 0;
    5285 
    5286     LARGE_INTEGER DelayInterval;
    5287     DelayInterval.QuadPart = -10LL * 1000LL * 1000LL;
    5288 
    5289     for (;;)
    5290     {
    5291         u32FenceCompleted = VBoxCmdVbvaCheckCompleted(pDevExt, &pDevExt->CmdVbva, false, &u32FenceSubmitted, &u32FenceProcessed);
    5292         if (!u32FenceCompleted)
    5293         {
    5294             WARN(("VBoxCmdVbvaCheckCompleted failed"));
    5295             return STATUS_UNSUCCESSFUL;
    5296         }
    5297 
    5298         if (u32FenceSubmitted == u32FenceProcessed)
    5299             break;
    5300 
    5301         WARN(("uncompleted fences, u32FenceSubmitted(%d), u32FenceCompleted(%d) u32FenceProcessed(%d)", u32FenceSubmitted, u32FenceCompleted, u32FenceProcessed));
    5302 
    5303         NTSTATUS Status = KeDelayExecutionThread(KernelMode, FALSE, &DelayInterval);
    5304         if (Status != STATUS_SUCCESS)
    5305             WARN(("KeDelayExecutionThread failed %#x", Status));
    5306     }
    5307 
    5308     pCurrentFence->CurrentFence = u32FenceCompleted;
    5309 
    5310     WARN(("<=DxgkDdiQueryCurrentFenceNew"));
    5311 
    5312     LOGF(("LEAVE, hAdapter(0x%x)", hAdapter));
    5313 
    5314     return STATUS_SUCCESS;
    5315 }
    5316 #endif
    5317 
    5318 static NTSTATUS
    5319 APIENTRY
    5320 DxgkDdiQueryCurrentFenceLegacy(
    5321     CONST HANDLE  hAdapter,
    5322     DXGKARG_QUERYCURRENTFENCE*  pCurrentFence)
    5323 {
    5324     LOGF(("ENTER, hAdapter(0x%x)", hAdapter));
    5325 
    5326     vboxVDbgBreakF();
    5327 
    5328     PVBOXMP_DEVEXT pDevExt = (PVBOXMP_DEVEXT)hAdapter;
    5329     VBOXWDDM_QUERYCURFENCE_CB context = {0};
    5330     context.pDevExt = pDevExt;
    5331     BOOLEAN bRet;
    5332     NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
    5333             pDevExt->u.primary.DxgkInterface.DeviceHandle,
    5334             vboxWddmQueryCurrentFenceCb,
    5335             &context,
    5336             0, /* IN ULONG MessageNumber */
    5337             &bRet);
    5338     AssertNtStatusSuccess(Status);
    5339     if (Status == STATUS_SUCCESS)
    5340     {
    5341         pCurrentFence->CurrentFence = context.uLastCompletedCmdFenceId;
    5342     }
    5343 
    5344     LOGF(("LEAVE, hAdapter(0x%x)", hAdapter));
    5345 
    5346     return STATUS_SUCCESS;
    5347 }
    5348 
    53493838NTSTATUS
    53503839APIENTRY
     
    60894578}
    60904579
    6091 #ifdef VBOX_WITH_CROGL
    6092 static NTSTATUS
    6093 APIENTRY
    6094 DxgkDdiRenderNew(
    6095     CONST HANDLE  hContext,
    6096     DXGKARG_RENDER  *pRender)
    6097 {
    6098     RT_NOREF(hContext);
    6099 //    LOGF(("ENTER, hContext(0x%x)", hContext));
    6100     vboxVDbgBreakF();
    6101 
    6102 #ifdef VBOX_WITH_MESA3D
    6103     if (GaContextHwTypeIs((PVBOXWDDM_CONTEXT)hContext, VBOXVIDEO_HWTYPE_VMSVGA))
    6104     {
    6105         return GaDxgkDdiRender(hContext, pRender);
    6106     }
    6107 #endif
    6108 
    6109     if (pRender->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_HDR))
    6110     {
    6111         WARN(("pRender->DmaBufferPrivateDataSize(%d) < sizeof VBOXCMDVBVA_HDR (%d)",
    6112                 pRender->DmaBufferPrivateDataSize , sizeof (VBOXCMDVBVA_HDR)));
    6113         /** @todo can this actually happen? what status to return? */
    6114         return STATUS_INVALID_PARAMETER;
    6115     }
    6116     if (pRender->CommandLength < sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR))
    6117     {
    6118         WARN(("Present->DmaBufferPrivateDataSize(%d) < sizeof VBOXWDDM_DMA_PRIVATEDATA_BASEHDR (%d)",
    6119                 pRender->DmaBufferPrivateDataSize , sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)));
    6120         return STATUS_INVALID_PARAMETER;
    6121     }
    6122     if (pRender->PatchLocationListOutSize < pRender->AllocationListSize)
    6123     {
    6124         WARN(("pRender->PatchLocationListOutSize(%d) < pRender->AllocationListSize(%d)",
    6125                 pRender->PatchLocationListOutSize, pRender->AllocationListSize));
    6126         return STATUS_INVALID_PARAMETER;
    6127     }
    6128 
    6129     NTSTATUS Status = STATUS_SUCCESS;
    6130 
    6131     __try
    6132     {
    6133         PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pInputHdr = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)pRender->pCommand;
    6134 
    6135         uint32_t cbBuffer = 0;
    6136         uint32_t cbPrivateData = 0;
    6137         uint32_t cbCmd = 0;
    6138         VBOXCMDVBVA_HDR* pCmd = (VBOXCMDVBVA_HDR*)pRender->pDmaBufferPrivateData;
    6139 
    6140         switch (pInputHdr->enmCmd)
    6141         {
    6142             case VBOXVDMACMD_TYPE_CHROMIUM_CMD:
    6143             {
    6144                 if (pRender->AllocationListSize >= (UINT32_MAX - RT_UOFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos))/ RT_SIZEOFMEMB(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[0]))
    6145                 {
    6146                     WARN(("Invalid AllocationListSize %d", pRender->AllocationListSize));
    6147                     return STATUS_INVALID_PARAMETER;
    6148                 }
    6149 
    6150                 if (pRender->CommandLength != RT_UOFFSETOF_DYN(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize]))
    6151                 {
    6152                     WARN(("pRender->CommandLength (%d) != RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize](%d)",
    6153                             pRender->CommandLength, (int)RT_UOFFSETOF_DYN(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize])));
    6154                     return STATUS_INVALID_PARAMETER;
    6155                 }
    6156 
    6157                 if (pRender->AllocationListSize >= (UINT32_MAX - RT_UOFFSETOF(VBOXCMDVBVA_CRCMD, Cmd.aBuffers))/ RT_SIZEOFMEMB(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[0]))
    6158                 {
    6159                     WARN(("Invalid AllocationListSize %d", pRender->AllocationListSize));
    6160                     return STATUS_INVALID_PARAMETER;
    6161                 }
    6162 
    6163                 cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6164                 cbPrivateData = RT_UOFFSETOF_DYN(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[pRender->AllocationListSize]);
    6165 
    6166                 if (pRender->DmaBufferPrivateDataSize < cbPrivateData)
    6167                 {
    6168                     WARN(("pRender->DmaBufferPrivateDataSize too small %d, requested %d", pRender->DmaBufferPrivateDataSize, cbPrivateData));
    6169                     return STATUS_INVALID_PARAMETER;
    6170                 }
    6171 
    6172                 if (pRender->DmaSize < cbBuffer)
    6173                 {
    6174                     WARN(("dma buffer %d too small", pRender->DmaSize));
    6175                     return STATUS_INVALID_PARAMETER;
    6176                 }
    6177 
    6178     //            Assert(pRender->PatchLocationListOutSize == pRender->AllocationListSize);
    6179 
    6180                 if (pRender->PatchLocationListOutSize < pRender->AllocationListSize)
    6181                 {
    6182                     WARN(("pRender->PatchLocationListOutSize too small %d, requested %d", pRender->PatchLocationListOutSize, pRender->AllocationListSize));
    6183                     return STATUS_INVALID_PARAMETER;
    6184                 }
    6185 
    6186                 PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD pUmCmd = (PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD)pInputHdr;
    6187                 VBOXCMDVBVA_CRCMD* pChromiumCmd = (VBOXCMDVBVA_CRCMD*)pRender->pDmaBufferPrivateData;
    6188 
    6189                 pChromiumCmd->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_CRCMD;
    6190                 pChromiumCmd->Hdr.u8Flags = 0;
    6191                 pChromiumCmd->Cmd.cBuffers = pRender->AllocationListSize;
    6192 
    6193                 DXGK_ALLOCATIONLIST *pAllocationList = pRender->pAllocationList;
    6194                 VBOXCMDVBVA_CRCMD_BUFFER *pSubmInfo = pChromiumCmd->Cmd.aBuffers;
    6195                 PVBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO pSubmUmInfo = pUmCmd->aBufInfos;
    6196 
    6197                 for (UINT i = 0; i < pRender->AllocationListSize; ++i, ++pRender->pPatchLocationListOut, ++pAllocationList, ++pSubmInfo, ++pSubmUmInfo)
    6198                 {
    6199                     VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO SubmUmInfo = *pSubmUmInfo;
    6200                     D3DDDI_PATCHLOCATIONLIST* pPLL = pRender->pPatchLocationListOut;
    6201                     PVBOXWDDM_ALLOCATION pAlloc = vboxWddmGetAllocationFromAllocList(pAllocationList);
    6202                     if (SubmUmInfo.offData >= pAlloc->AllocData.SurfDesc.cbSize
    6203                             || SubmUmInfo.cbData > pAlloc->AllocData.SurfDesc.cbSize
    6204                             || SubmUmInfo.offData + SubmUmInfo.cbData > pAlloc->AllocData.SurfDesc.cbSize)
    6205                     {
    6206                         WARN(("invalid data"));
    6207                         return STATUS_INVALID_PARAMETER;
    6208                     }
    6209 
    6210                     memset(pPLL, 0, sizeof (*pPLL));
    6211 
    6212                     if (pAllocationList->SegmentId)
    6213                         pSubmInfo->offBuffer = pAllocationList->PhysicalAddress.LowPart + SubmUmInfo.offData;
    6214 
    6215                     pSubmInfo->cbBuffer = SubmUmInfo.cbData;
    6216 
    6217                     pPLL->AllocationIndex = i;
    6218                     pPLL->PatchOffset = RT_UOFFSETOF_DYN(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[i].offBuffer);
    6219                     pPLL->AllocationOffset = SubmUmInfo.offData;
    6220                 }
    6221 
    6222                 cbCmd = cbPrivateData;
    6223 
    6224                 break;
    6225             }
    6226             case VBOXVDMACMD_TYPE_DMA_NOP:
    6227             {
    6228                 cbPrivateData = sizeof (VBOXCMDVBVA_HDR);
    6229                 cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6230 
    6231                 if (pRender->DmaBufferPrivateDataSize < cbPrivateData)
    6232                 {
    6233                     WARN(("pRender->DmaBufferPrivateDataSize too small %d, requested %d", pRender->DmaBufferPrivateDataSize, cbPrivateData));
    6234                     return STATUS_INVALID_PARAMETER;
    6235                 }
    6236 
    6237                 if (pRender->DmaSize < cbBuffer)
    6238                 {
    6239                     WARN(("dma buffer %d too small", pRender->DmaSize));
    6240                     return STATUS_INVALID_PARAMETER;
    6241                 }
    6242 
    6243                 pCmd->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    6244                 pCmd->u8Flags = 0;
    6245 
    6246                 for (UINT i = 0; i < pRender->AllocationListSize; ++i, ++pRender->pPatchLocationListOut)
    6247                 {
    6248                     D3DDDI_PATCHLOCATIONLIST* pPLL = pRender->pPatchLocationListOut;
    6249                     memset(pPLL, 0, sizeof (*pPLL));
    6250                     pPLL->AllocationIndex = i;
    6251                     pPLL->PatchOffset = ~0UL;
    6252                     pPLL->AllocationOffset = 0;
    6253                 }
    6254 
    6255                 cbCmd = cbPrivateData;
    6256 
    6257                 break;
    6258             }
    6259             default:
    6260              {
    6261                  WARN(("unsupported render command %d", pInputHdr->enmCmd));
    6262                  return STATUS_INVALID_PARAMETER;
    6263              }
    6264         }
    6265 
    6266         Assert(cbPrivateData >= sizeof (VBOXCMDVBVA_HDR));
    6267         pRender->pDmaBufferPrivateData = ((uint8_t*)pRender->pDmaBufferPrivateData) + cbPrivateData;
    6268         pRender->pDmaBuffer = ((uint8_t*)pRender->pDmaBuffer) + cbBuffer;
    6269 
    6270         pCmd->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    6271         pCmd->u2.complexCmdEl.u16CbCmdHost = cbPrivateData;
    6272         pCmd->u2.complexCmdEl.u16CbCmdGuest = cbBuffer;
    6273     }
    6274     __except (EXCEPTION_EXECUTE_HANDLER)
    6275     {
    6276         Status = STATUS_INVALID_PARAMETER;
    6277         WARN(("invalid parameter"));
    6278     }
    6279 //    LOGF(("LEAVE, hContext(0x%x)", hContext));
    6280 
    6281     return Status;
    6282 }
    6283 #endif
    6284 
    6285 static void vboxWddmPatchLocationInit(D3DDDI_PATCHLOCATIONLIST *pPatchLocationListOut, UINT idx, UINT offPatch)
    6286 {
    6287     memset(pPatchLocationListOut, 0, sizeof (*pPatchLocationListOut));
    6288     pPatchLocationListOut->AllocationIndex = idx;
    6289     pPatchLocationListOut->PatchOffset = offPatch;
    6290 }
    6291 
    6292 static NTSTATUS
    6293 APIENTRY
    6294 DxgkDdiRenderLegacy(
    6295     CONST HANDLE  hContext,
    6296     DXGKARG_RENDER  *pRender)
    6297 {
    6298     RT_NOREF(hContext);
    6299 //    LOGF(("ENTER, hContext(0x%x)", hContext));
    6300 
    6301     if (pRender->DmaBufferPrivateDataSize < sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR))
    6302     {
    6303         WARN(("Present->DmaBufferPrivateDataSize(%d) < sizeof VBOXWDDM_DMA_PRIVATEDATA_BASEHDR (%d)",
    6304                 pRender->DmaBufferPrivateDataSize , sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)));
    6305         return STATUS_INVALID_PARAMETER;
    6306     }
    6307     if (pRender->CommandLength < sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR))
    6308     {
    6309         WARN(("Present->DmaBufferPrivateDataSize(%d) < sizeof VBOXWDDM_DMA_PRIVATEDATA_BASEHDR (%d)",
    6310                 pRender->DmaBufferPrivateDataSize , sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)));
    6311         return STATUS_INVALID_PARAMETER;
    6312     }
    6313     if (pRender->DmaSize < pRender->CommandLength)
    6314     {
    6315         WARN(("pRender->DmaSize(%d) < pRender->CommandLength(%d)",
    6316                 pRender->DmaSize, pRender->CommandLength));
    6317         return STATUS_INVALID_PARAMETER;
    6318     }
    6319     if (pRender->PatchLocationListOutSize < pRender->PatchLocationListInSize)
    6320     {
    6321         WARN(("pRender->PatchLocationListOutSize(%d) < pRender->PatchLocationListInSize(%d)",
    6322                 pRender->PatchLocationListOutSize, pRender->PatchLocationListInSize));
    6323         return STATUS_INVALID_PARAMETER;
    6324     }
    6325     if (pRender->AllocationListSize != pRender->PatchLocationListInSize)
    6326     {
    6327         WARN(("pRender->AllocationListSize(%d) != pRender->PatchLocationListInSize(%d)",
    6328                 pRender->AllocationListSize, pRender->PatchLocationListInSize));
    6329         return STATUS_INVALID_PARAMETER;
    6330     }
    6331 
    6332     NTSTATUS Status = STATUS_SUCCESS;
    6333 
    6334     __try
    6335     {
    6336         PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pInputHdr = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)pRender->pCommand;
    6337         switch (pInputHdr->enmCmd)
    6338         {
    6339             case VBOXVDMACMD_TYPE_DMA_NOP:
    6340             {
    6341                 PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pPrivateData = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)pRender->pDmaBufferPrivateData;
    6342                 pPrivateData->enmCmd = VBOXVDMACMD_TYPE_DMA_NOP;
    6343                 pRender->pDmaBufferPrivateData = (uint8_t*)pRender->pDmaBufferPrivateData + sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR);
    6344                 pRender->pDmaBuffer = ((uint8_t*)pRender->pDmaBuffer) + pRender->CommandLength;
    6345                 for (UINT i = 0; i < pRender->PatchLocationListInSize; ++i)
    6346                 {
    6347                     UINT offPatch = i * 4;
    6348                     if (offPatch + 4 > pRender->CommandLength)
    6349                     {
    6350                         WARN(("wrong offPatch"));
    6351                         return STATUS_INVALID_PARAMETER;
    6352                     }
    6353                     if (offPatch != pRender->pPatchLocationListIn[i].PatchOffset)
    6354                     {
    6355                         WARN(("wrong PatchOffset"));
    6356                         return STATUS_INVALID_PARAMETER;
    6357                     }
    6358                     if (i != pRender->pPatchLocationListIn[i].AllocationIndex)
    6359                     {
    6360                         WARN(("wrong AllocationIndex"));
    6361                         return STATUS_INVALID_PARAMETER;
    6362                     }
    6363                     vboxWddmPatchLocationInit(&pRender->pPatchLocationListOut[i], i, offPatch);
    6364                 }
    6365                 break;
    6366             }
    6367             default:
    6368             {
    6369                 WARN(("unsupported command %d", pInputHdr->enmCmd));
    6370                 return STATUS_INVALID_PARAMETER;
    6371             }
    6372         }
    6373     }
    6374     __except (EXCEPTION_EXECUTE_HANDLER)
    6375     {
    6376         Status = STATUS_INVALID_PARAMETER;
    6377         WARN(("invalid parameter"));
    6378     }
    6379 //    LOGF(("LEAVE, hContext(0x%x)", hContext));
    6380 
    6381     return Status;
    6382 }
    6383 
    63844580#define VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE() (VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_PRESENT_BLT))
    63854581#define VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(_c) (VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects[_c]))
     
    64164612    Assert(From == To);
    64174613    return From == To;
    6418 }
    6419 
    6420 #ifdef VBOX_WITH_CROGL
    6421 
    6422 DECLINLINE(void) VBoxCVDdiFillAllocDescHostID(VBOXCMDVBVA_ALLOCDESC *pDesc, const VBOXWDDM_ALLOCATION *pAlloc)
    6423 {
    6424     pDesc->Info.u.id = pAlloc->AllocData.hostID;
    6425     /* we do not care about wdth and height, zero them up though */
    6426     pDesc->u16Width = 0;
    6427     pDesc->u16Height = 0;
    6428 }
    6429 
    6430 DECLINLINE(void) VBoxCVDdiFillAllocInfoOffVRAM(VBOXCMDVBVA_ALLOCINFO *pInfo, const DXGK_ALLOCATIONLIST *pList)
    6431 {
    6432     Assert(!pList->PhysicalAddress.HighPart);
    6433     pInfo->u.offVRAM = pList->PhysicalAddress.LowPart;
    6434 }
    6435 
    6436 DECLINLINE(void) VBoxCVDdiFillAllocDescOffVRAM(VBOXCMDVBVA_ALLOCDESC *pDesc, const VBOXWDDM_ALLOCATION *pAlloc, const DXGK_ALLOCATIONLIST *pList)
    6437 {
    6438     VBoxCVDdiFillAllocInfoOffVRAM(&pDesc->Info, pList);
    6439     pDesc->u16Width = (uint16_t)pAlloc->AllocData.SurfDesc.width;
    6440     pDesc->u16Height = (uint16_t)pAlloc->AllocData.SurfDesc.height;
    6441 }
    6442 
    6443 static NTSTATUS vboxWddmCmCmdBltIdNotIdFill(VBOXCMDVBVA_BLT_HDR *pBltHdr, const VBOXWDDM_ALLOCATION *pIdAlloc, const VBOXWDDM_ALLOCATION *pAlloc, const DXGK_ALLOCATIONLIST *pList,
    6444                             BOOLEAN fToId, uint32_t *poffPatch, uint32_t *poffRects)
    6445 {
    6446     uint8_t fFlags;
    6447     Assert(pIdAlloc->AllocData.hostID);
    6448     Assert(!pAlloc->AllocData.hostID);
    6449 
    6450     D3DDDIFORMAT enmFormat = vboxWddmFmtNoAlphaFormat(pAlloc->AllocData.SurfDesc.format);
    6451     if (enmFormat != D3DDDIFMT_X8R8G8B8)
    6452     {
    6453         WARN(("unsupported format"));
    6454         return STATUS_INVALID_PARAMETER;
    6455     }
    6456 
    6457     if (pIdAlloc->AllocData.SurfDesc.width == pAlloc->AllocData.SurfDesc.width
    6458             && pIdAlloc->AllocData.SurfDesc.height == pAlloc->AllocData.SurfDesc.height)
    6459     {
    6460         fFlags = VBOXCMDVBVA_OPF_BLT_TYPE_OFFPRIMSZFMT_OR_ID | VBOXCMDVBVA_OPF_OPERAND2_ISID;
    6461         VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID *pBlt = (VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID*)pBltHdr;
    6462         VBoxCVDdiFillAllocInfoOffVRAM(&pBlt->alloc, pList);
    6463         pBlt->id = pIdAlloc->AllocData.hostID;
    6464         *poffPatch = RT_UOFFSETOF(VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID, alloc.u.offVRAM);
    6465         *poffRects = RT_UOFFSETOF(VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID, aRects);
    6466     }
    6467     else
    6468     {
    6469         fFlags = VBOXCMDVBVA_OPF_BLT_TYPE_SAMEDIM_A8R8G8B8 | VBOXCMDVBVA_OPF_OPERAND2_ISID;
    6470         VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8 *pBlt = (VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8*)pBltHdr;
    6471         VBoxCVDdiFillAllocDescOffVRAM(&pBlt->alloc1, pAlloc, pList);
    6472         pBlt->info2.u.id = pIdAlloc->AllocData.hostID;
    6473         *poffPatch = RT_UOFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, alloc1.Info.u.offVRAM);
    6474         *poffRects = RT_UOFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, aRects);
    6475     }
    6476 
    6477     if (fToId)
    6478         fFlags |= VBOXCMDVBVA_OPF_BLT_DIR_IN_2;
    6479 
    6480     pBltHdr->Hdr.u8Flags |= fFlags;
    6481     return STATUS_SUCCESS;
    6482 }
    6483 
    6484 static NTSTATUS vboxWddmCmCmdBltNotIdNotIdFill(VBOXCMDVBVA_BLT_HDR *pBltHdr, const VBOXWDDM_ALLOCATION *pSrcAlloc, const DXGK_ALLOCATIONLIST *pSrcList,
    6485         const VBOXWDDM_ALLOCATION *pDstAlloc, const DXGK_ALLOCATIONLIST *pDstList,
    6486                             uint32_t *poffSrcPatch, uint32_t *poffDstPatch, uint32_t *poffRects)
    6487 {
    6488     if (pDstAlloc->AllocData.SurfDesc.width == pSrcAlloc->AllocData.SurfDesc.width
    6489             && pDstAlloc->AllocData.SurfDesc.height == pSrcAlloc->AllocData.SurfDesc.height)
    6490     {
    6491         pBltHdr->Hdr.u8Flags |= VBOXCMDVBVA_OPF_BLT_TYPE_SAMEDIM_A8R8G8B8;
    6492         VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8 *pBlt = (VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8*)pBltHdr;
    6493         VBoxCVDdiFillAllocDescOffVRAM(&pBlt->alloc1, pDstAlloc, pDstList);
    6494         VBoxCVDdiFillAllocInfoOffVRAM(&pBlt->info2, pSrcList);
    6495         *poffDstPatch = RT_UOFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, alloc1.Info.u.offVRAM);
    6496         *poffSrcPatch = RT_UOFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, info2.u.offVRAM);
    6497         *poffRects = RT_UOFFSETOF(VBOXCMDVBVA_BLT_SAMEDIM_A8R8G8B8, aRects);
    6498     }
    6499     else
    6500     {
    6501         pBltHdr->Hdr.u8Flags |= VBOXCMDVBVA_OPF_BLT_TYPE_GENERIC_A8R8G8B8;
    6502         VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8 *pBlt = (VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8*)pBltHdr;
    6503         VBoxCVDdiFillAllocDescOffVRAM(&pBlt->alloc1, pDstAlloc, pDstList);
    6504         VBoxCVDdiFillAllocDescOffVRAM(&pBlt->alloc2, pSrcAlloc, pSrcList);
    6505         *poffDstPatch = RT_UOFFSETOF(VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8, alloc1.Info.u.offVRAM);
    6506         *poffSrcPatch = RT_UOFFSETOF(VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8, alloc2.Info.u.offVRAM);
    6507         *poffRects = RT_UOFFSETOF(VBOXCMDVBVA_BLT_GENERIC_A8R8G8B8, aRects);
    6508     }
    6509     return STATUS_SUCCESS;
    6510 }
    6511 /**
    6512  * DxgkDdiPresent
    6513  */
    6514 static NTSTATUS
    6515 APIENTRY
    6516 DxgkDdiPresentNew(
    6517     CONST HANDLE  hContext,
    6518     DXGKARG_PRESENT  *pPresent)
    6519 {
    6520     RT_NOREF(hContext);
    6521     PAGED_CODE();
    6522 
    6523 //    LOGF(("ENTER, hContext(0x%x)", hContext));
    6524 
    6525     vboxVDbgBreakFv();
    6526 #ifdef VBOX_WITH_MESA3D
    6527     if (GaContextHwTypeIs((PVBOXWDDM_CONTEXT)hContext, VBOXVIDEO_HWTYPE_VMSVGA))
    6528     {
    6529         return GaDxgkDdiPresent(hContext, pPresent);
    6530     }
    6531 #endif
    6532 
    6533 #ifdef VBOX_STRICT
    6534     PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)hContext;
    6535     PVBOXWDDM_DEVICE pDevice = pContext->pDevice;
    6536     PVBOXMP_DEVEXT pDevExt = pDevice->pAdapter;
    6537 #endif
    6538     uint32_t cbBuffer = 0;
    6539     uint32_t cbPrivateData = 0;
    6540 
    6541     if (pPresent->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_HDR))
    6542     {
    6543         WARN(("Present->DmaBufferPrivateDataSize(%d) < sizeof VBOXCMDVBVA_HDR (%d)", pPresent->DmaBufferPrivateDataSize , sizeof (VBOXCMDVBVA_HDR)));
    6544         /** @todo can this actually happen? what status to return? */
    6545         return STATUS_INVALID_PARAMETER;
    6546     }
    6547 
    6548     VBOXCMDVBVA_HDR* pHdr = (VBOXCMDVBVA_HDR*)pPresent->pDmaBufferPrivateData;
    6549 
    6550     UINT u32SrcPatch = ~0UL;
    6551     UINT u32DstPatch = ~0UL;
    6552     BOOLEAN fPatchSrc = false;
    6553     BOOLEAN fPatchDst = false;
    6554     VBOXCMDVBVA_RECT *paRects = NULL;
    6555 
    6556     if (pPresent->DmaSize < VBOXWDDM_DUMMY_DMABUFFER_SIZE)
    6557     {
    6558         WARN(("Present->DmaSize(%d) < VBOXWDDM_DUMMY_DMABUFFER_SIZE (%d)", pPresent->DmaSize , VBOXWDDM_DUMMY_DMABUFFER_SIZE));
    6559         /** @todo can this actually happen? what status to return? */
    6560         return STATUS_INVALID_PARAMETER;
    6561     }
    6562 
    6563 #ifdef VBOX_WDDM_DUMP_REGIONS_ON_PRESENT
    6564     LogRel(("%s: [%ld, %ld, %ld, %ld] -> [%ld, %ld, %ld, %ld] (SubRectCnt=%u)\n",
    6565         pPresent->Flags.Blt ? "Blt" : (pPresent->Flags.Flip ? "Flip" : (pPresent->Flags.ColorFill ? "ColorFill" : "Unknown OP")),
    6566         pPresent->SrcRect.left, pPresent->SrcRect.top, pPresent->SrcRect.right, pPresent->SrcRect.bottom,
    6567         pPresent->DstRect.left, pPresent->DstRect.top, pPresent->DstRect.right, pPresent->DstRect.bottom,
    6568         pPresent->SubRectCnt));
    6569     for (unsigned int i = 0; i < pPresent->SubRectCnt; i++)
    6570         LogRel(("\tsub#%u = [%ld, %ld, %ld, %ld]\n", i, pPresent->pDstSubRects[i].left, pPresent->pDstSubRects[i].top, pPresent->pDstSubRects[i].right, pPresent->pDstSubRects[i].bottom));
    6571 #endif
    6572 
    6573     if (pPresent->Flags.Blt)
    6574     {
    6575         Assert(pPresent->Flags.Value == 1); /* only Blt is set, we do not support anything else for now */
    6576         DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
    6577         DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
    6578         PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pSrc);
    6579         if (!pSrcAlloc)
    6580         {
    6581             /* this should not happen actually */
    6582             WARN(("failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
    6583             return STATUS_INVALID_HANDLE;
    6584         }
    6585 
    6586         PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDst);
    6587         if (!pDstAlloc)
    6588         {
    6589             /* this should not happen actually */
    6590             WARN(("failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
    6591             return STATUS_INVALID_HANDLE;
    6592         }
    6593 
    6594         fPatchSrc = TRUE;
    6595         fPatchDst = TRUE;
    6596 
    6597         BOOLEAN fDstPrimary = (!pDstAlloc->AllocData.hostID
    6598                 && pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
    6599                 && pDstAlloc->bAssigned);
    6600         BOOLEAN fSrcPrimary = (!pSrcAlloc->AllocData.hostID
    6601                 && pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
    6602                 && pSrcAlloc->bAssigned);
    6603 
    6604         pHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_BLT;
    6605         pHdr->u8Flags = 0;
    6606 
    6607         VBOXCMDVBVA_BLT_HDR *pBltHdr = (VBOXCMDVBVA_BLT_HDR*)pHdr;
    6608         pBltHdr->Pos.x = (int16_t)(pPresent->DstRect.left - pPresent->SrcRect.left);
    6609         pBltHdr->Pos.y = (int16_t)(pPresent->DstRect.top - pPresent->SrcRect.top);
    6610 
    6611         if (pPresent->DmaBufferPrivateDataSize < VBOXCMDVBVA_SIZEOF_BLTSTRUCT_MAX)
    6612         {
    6613             WARN(("Present->DmaBufferPrivateDataSize(%d) < (%d)", pPresent->DmaBufferPrivateDataSize , VBOXCMDVBVA_SIZEOF_BLTSTRUCT_MAX));
    6614             /** @todo can this actually happen? what status to return? */
    6615             return STATUS_INVALID_PARAMETER;
    6616         }
    6617 
    6618         if (pSrcAlloc->AllocData.hostID)
    6619         {
    6620             if (pDstAlloc->AllocData.hostID)
    6621             {
    6622                 VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID *pBlt = (VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID*)pBltHdr;
    6623                 pHdr->u8Flags |= VBOXCMDVBVA_OPF_BLT_TYPE_OFFPRIMSZFMT_OR_ID | VBOXCMDVBVA_OPF_OPERAND1_ISID | VBOXCMDVBVA_OPF_OPERAND2_ISID;
    6624                 pBlt->id = pDstAlloc->AllocData.hostID;
    6625                 pBlt->alloc.u.id = pSrcAlloc->AllocData.hostID;
    6626                 cbPrivateData = RT_UOFFSETOF(VBOXCMDVBVA_BLT_OFFPRIMSZFMT_OR_ID, aRects);
    6627             }
    6628             else
    6629             {
    6630                 NTSTATUS Status = vboxWddmCmCmdBltIdNotIdFill(pBltHdr, pSrcAlloc, pDstAlloc, pDst, FALSE, &u32DstPatch, &cbPrivateData);
    6631                 if (!NT_SUCCESS(Status))
    6632                 {
    6633                     WARN(("vboxWddmCmCmdBltIdNotIdFill failed, %#x", Status));
    6634                     return Status;
    6635                 }
    6636             }
    6637         }
    6638         else
    6639         {
    6640             if (pDstAlloc->AllocData.hostID)
    6641             {
    6642                 NTSTATUS Status = vboxWddmCmCmdBltIdNotIdFill(pBltHdr, pDstAlloc, pSrcAlloc, pSrc, TRUE, &u32SrcPatch, &cbPrivateData);
    6643                 if (!NT_SUCCESS(Status))
    6644                 {
    6645                     WARN(("vboxWddmCmCmdBltIdNotIdFill failed, %#x", Status));
    6646                     return Status;
    6647                 }
    6648             }
    6649             else
    6650             {
    6651                 vboxWddmCmCmdBltNotIdNotIdFill(pBltHdr, pSrcAlloc, pSrc, pDstAlloc, pDst, &u32SrcPatch, &u32DstPatch, &cbPrivateData);
    6652             }
    6653         }
    6654 
    6655         if (fDstPrimary)
    6656             pBltHdr->Hdr.u.u8PrimaryID = (uint8_t)pDstAlloc->AllocData.SurfDesc.VidPnSourceId;
    6657         else if (fSrcPrimary)
    6658         {
    6659             pBltHdr->Hdr.u8Flags |= VBOXCMDVBVA_OPF_PRIMARY_HINT_SRC;
    6660             pBltHdr->Hdr.u.u8PrimaryID = (uint8_t)pSrcAlloc->AllocData.SurfDesc.VidPnSourceId;
    6661         }
    6662         else
    6663             pBltHdr->Hdr.u.u8PrimaryID = 0xff;
    6664 
    6665         paRects = (VBOXCMDVBVA_RECT*)(((uint8_t*)pPresent->pDmaBufferPrivateData) + cbPrivateData);
    6666         cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6667     }
    6668     else if (pPresent->Flags.Flip)
    6669     {
    6670         if (pPresent->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_FLIP))
    6671         {
    6672             WARN(("Present->DmaBufferPrivateDataSize(%d) < sizeof VBOXCMDVBVA_FLIP (%d)", pPresent->DmaBufferPrivateDataSize , sizeof (VBOXCMDVBVA_FLIP)));
    6673             /** @todo can this actually happen? what status to return? */
    6674             return STATUS_INVALID_PARAMETER;
    6675         }
    6676 
    6677         fPatchSrc = TRUE;
    6678 
    6679         Assert(pPresent->Flags.Value == 4); /* only Blt is set, we do not support anything else for now */
    6680         Assert(pContext->enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D);
    6681         DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
    6682         PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pSrc);
    6683 
    6684         if (!pSrcAlloc)
    6685         {
    6686             /* this should not happen actually */
    6687             WARN(("failed to get pSrc Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
    6688             return STATUS_INVALID_HANDLE;
    6689         }
    6690 
    6691         Assert(pDevExt->cContexts3D);
    6692         pHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_FLIP;
    6693         Assert((UINT)pSrcAlloc->AllocData.SurfDesc.VidPnSourceId < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
    6694         pHdr->u.u8PrimaryID = pSrcAlloc->AllocData.SurfDesc.VidPnSourceId;
    6695         VBOXCMDVBVA_FLIP *pFlip = (VBOXCMDVBVA_FLIP*)pHdr;
    6696 
    6697         if (pSrcAlloc->AllocData.hostID)
    6698         {
    6699             pHdr->u8Flags = VBOXCMDVBVA_OPF_OPERAND1_ISID;
    6700             pFlip->src.u.id = pSrcAlloc->AllocData.hostID;
    6701         }
    6702         else
    6703         {
    6704             WARN(("VBoxCVDdiFillAllocInfo reported no host id for flip!"));
    6705             pHdr->u8Flags = 0;
    6706             VBoxCVDdiFillAllocInfoOffVRAM(&pFlip->src, pSrc);
    6707             u32SrcPatch = RT_UOFFSETOF(VBOXCMDVBVA_FLIP, src.u.offVRAM);
    6708         }
    6709 
    6710         cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6711         paRects = pFlip->aRects;
    6712         cbPrivateData = VBOXCMDVBVA_SIZEOF_FLIPSTRUCT_MIN;
    6713     }
    6714     else if (pPresent->Flags.ColorFill)
    6715     {
    6716 #ifdef DEBUG_misha
    6717         WARN(("test color fill!"));
    6718 #endif
    6719 
    6720         fPatchDst = TRUE;
    6721 
    6722         Assert(pContext->enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D);
    6723         Assert(pPresent->Flags.Value == 2); /* only ColorFill is set, we do not support anything else for now */
    6724         DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
    6725         PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDst);
    6726         if (!pDstAlloc)
    6727         {
    6728             /* this should not happen actually */
    6729             WARN(("failed to get pDst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
    6730             return STATUS_INVALID_HANDLE;
    6731         }
    6732 
    6733         if (pDstAlloc->AllocData.hostID)
    6734         {
    6735             WARN(("color fill present for texid not supported"));
    6736             pHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    6737             pHdr->u8Flags = 0;
    6738             pHdr->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    6739             cbPrivateData = sizeof (VBOXCMDVBVA_HDR);
    6740             cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6741         }
    6742         else
    6743         {
    6744             BOOLEAN fDstPrimary = (!pDstAlloc->AllocData.hostID
    6745                     && pDstAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
    6746                     && pDstAlloc->bAssigned);
    6747 
    6748             if (pPresent->DmaBufferPrivateDataSize < VBOXCMDVBVA_SIZEOF_CLRFILLSTRUCT_MAX)
    6749             {
    6750                 WARN(("Present->DmaBufferPrivateDataSize(%d) < VBOXCMDVBVA_SIZEOF_CLRFILLSTRUCT_MAX (%d)", pPresent->DmaBufferPrivateDataSize , VBOXCMDVBVA_SIZEOF_CLRFILLSTRUCT_MAX));
    6751                 /** @todo can this actually happen? what status to return? */
    6752                 return STATUS_INVALID_PARAMETER;
    6753             }
    6754 
    6755             VBOXCMDVBVA_CLRFILL_HDR *pClrFillHdr = (VBOXCMDVBVA_CLRFILL_HDR*)pHdr;
    6756 
    6757             pClrFillHdr->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_CLRFILL;
    6758             pClrFillHdr->u32Color = pPresent->Color;
    6759 
    6760             pHdr->u8Flags = VBOXCMDVBVA_OPF_CLRFILL_TYPE_GENERIC_A8R8G8B8;
    6761             pHdr->u.u8PrimaryID = 0;
    6762 
    6763             VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8 *pCFill = (VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8*)pHdr;
    6764             VBoxCVDdiFillAllocInfoOffVRAM(&pCFill->dst.Info, pDst);
    6765             pCFill->dst.u16Width = (uint16_t)pDstAlloc->AllocData.SurfDesc.width;
    6766             pCFill->dst.u16Height = (uint16_t)pDstAlloc->AllocData.SurfDesc.height;
    6767             u32DstPatch = RT_UOFFSETOF(VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8, dst.Info.u.offVRAM);
    6768             paRects = pCFill->aRects;
    6769             cbPrivateData = RT_UOFFSETOF(VBOXCMDVBVA_CLRFILL_GENERIC_A8R8G8B8, aRects);
    6770 
    6771             if (fDstPrimary)
    6772                 pCFill->Hdr.Hdr.u.u8PrimaryID = (uint8_t)pDstAlloc->AllocData.SurfDesc.VidPnSourceId;
    6773             else
    6774                 pCFill->Hdr.Hdr.u.u8PrimaryID = 0xff;
    6775 
    6776             cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6777         }
    6778     }
    6779     else
    6780     {
    6781         WARN(("cmd NOT IMPLEMENTED!! Flags(0x%x)", pPresent->Flags.Value));
    6782         return STATUS_NOT_SUPPORTED;
    6783     }
    6784 
    6785     if (paRects)
    6786     {
    6787         uint32_t cbMaxRects = pPresent->DmaBufferPrivateDataSize - cbPrivateData;
    6788         UINT iStartRect = pPresent->MultipassOffset;
    6789         UINT cMaxRects = cbMaxRects / sizeof (VBOXCMDVBVA_RECT);
    6790         Assert(pPresent->SubRectCnt > iStartRect);
    6791         UINT cRects = pPresent->SubRectCnt - iStartRect;
    6792         if (cRects > cMaxRects)
    6793         {
    6794             pPresent->MultipassOffset += cMaxRects;
    6795             cRects = cMaxRects;
    6796         }
    6797         else
    6798             pPresent->MultipassOffset = 0;
    6799 
    6800         Assert(cRects);
    6801         const RECT *paDstSubRects = &pPresent->pDstSubRects[iStartRect];
    6802         VBoxCVDdiPackRects(paRects, paDstSubRects, cRects);
    6803         cbPrivateData += (cRects * sizeof (VBOXCMDVBVA_RECT));
    6804     }
    6805 
    6806     if (fPatchSrc)
    6807     {
    6808         memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
    6809         pPresent->pPatchLocationListOut->PatchOffset = u32SrcPatch;
    6810         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    6811         ++pPresent->pPatchLocationListOut;
    6812     }
    6813 
    6814     if (fPatchDst)
    6815     {
    6816         memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
    6817         pPresent->pPatchLocationListOut->PatchOffset = u32DstPatch;
    6818         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    6819         ++pPresent->pPatchLocationListOut;
    6820     }
    6821 
    6822     pHdr->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    6823 
    6824     pHdr->u2.complexCmdEl.u16CbCmdHost = cbPrivateData;
    6825     pHdr->u2.complexCmdEl.u16CbCmdGuest = cbBuffer;
    6826 
    6827     Assert(cbBuffer);
    6828     Assert(cbPrivateData);
    6829     Assert(cbPrivateData >= sizeof (VBOXCMDVBVA_HDR));
    6830     pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + cbBuffer;
    6831     pPresent->pDmaBufferPrivateData = ((uint8_t*)pPresent->pDmaBufferPrivateData) + cbPrivateData;
    6832 
    6833     if (pPresent->MultipassOffset)
    6834         return STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    6835     return STATUS_SUCCESS;
    6836 }
    6837 #endif
    6838 
    6839 /**
    6840  * DxgkDdiPresent
    6841  */
    6842 static NTSTATUS
    6843 APIENTRY
    6844 DxgkDdiPresentLegacy(
    6845     CONST HANDLE  hContext,
    6846     DXGKARG_PRESENT  *pPresent)
    6847 {
    6848     RT_NOREF(hContext);
    6849     PAGED_CODE();
    6850 
    6851 //    LOGF(("ENTER, hContext(0x%x)", hContext));
    6852 
    6853     vboxVDbgBreakFv();
    6854 
    6855     NTSTATUS Status = STATUS_SUCCESS;
    6856 #ifdef VBOX_STRICT
    6857     PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)hContext;
    6858     PVBOXWDDM_DEVICE pDevice = pContext->pDevice;
    6859     PVBOXMP_DEVEXT pDevExt = pDevice->pAdapter;
    6860 #endif
    6861 
    6862     Assert(pPresent->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR));
    6863     if (pPresent->DmaBufferPrivateDataSize < sizeof (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR))
    6864     {
    6865         LOGREL(("Present->DmaBufferPrivateDataSize(%d) < sizeof VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR (%d)", pPresent->DmaBufferPrivateDataSize , sizeof (VBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR)));
    6866         /** @todo can this actually happen? what status tu return? */
    6867         return STATUS_INVALID_PARAMETER;
    6868     }
    6869 
    6870     PVBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR pPrivateData = (PVBOXWDDM_DMA_PRIVATEDATA_PRESENTHDR)pPresent->pDmaBufferPrivateData;
    6871     pPrivateData->BaseHdr.fFlags.Value = 0;
    6872     /*uint32_t cContexts2D = ASMAtomicReadU32(&pDevExt->cContexts2D); - unused */
    6873 
    6874     if (pPresent->Flags.Blt)
    6875     {
    6876         Assert(pPresent->Flags.Value == 1); /* only Blt is set, we do not support anything else for now */
    6877         DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
    6878         DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
    6879         PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pSrc);
    6880         if (!pSrcAlloc)
    6881         {
    6882             /* this should not happen actually */
    6883             WARN(("failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
    6884             Status = STATUS_INVALID_HANDLE;
    6885             goto done;
    6886         }
    6887 
    6888         PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDst);
    6889         if (!pDstAlloc)
    6890         {
    6891             /* this should not happen actually */
    6892             WARN(("failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
    6893             Status = STATUS_INVALID_HANDLE;
    6894             goto done;
    6895         }
    6896 
    6897 
    6898         UINT cbCmd = pPresent->DmaBufferPrivateDataSize;
    6899         pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
    6900 
    6901         PVBOXWDDM_DMA_PRIVATEDATA_BLT pBlt = (PVBOXWDDM_DMA_PRIVATEDATA_BLT)pPrivateData;
    6902 
    6903         vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.SrcAlloc, pSrcAlloc, pSrc);
    6904         vboxWddmPopulateDmaAllocInfo(&pBlt->Blt.DstAlloc, pDstAlloc, pDst);
    6905 
    6906         ASSERT_WARN(!pSrcAlloc->fRcFlags.SharedResource, ("Shared Allocatoin used in Present!"));
    6907 
    6908         pBlt->Blt.SrcRect = pPresent->SrcRect;
    6909         pBlt->Blt.DstRects.ContextRect = pPresent->DstRect;
    6910         pBlt->Blt.DstRects.UpdateRects.cRects = 0;
    6911         UINT cbHead = RT_UOFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_BLT, Blt.DstRects.UpdateRects.aRects[0]);
    6912         Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    6913         UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT);
    6914         pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6915         Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    6916         cbCmd -= cbHead;
    6917         Assert(cbCmd < UINT32_MAX/2);
    6918         Assert(cbCmd > sizeof (RECT));
    6919         if (cbCmd >= cbRects)
    6920         {
    6921             cbCmd -= cbRects;
    6922             memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[0], &pPresent->pDstSubRects[pPresent->MultipassOffset], cbRects);
    6923             pBlt->Blt.DstRects.UpdateRects.cRects += cbRects/sizeof (RECT);
    6924 
    6925             pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbRects;
    6926         }
    6927         else
    6928         {
    6929             UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT);
    6930             Assert(cbFitingRects);
    6931             memcpy(&pBlt->Blt.DstRects.UpdateRects.aRects[0], &pPresent->pDstSubRects[pPresent->MultipassOffset], cbFitingRects);
    6932             cbCmd -= cbFitingRects;
    6933             pPresent->MultipassOffset += cbFitingRects/sizeof (RECT);
    6934             pBlt->Blt.DstRects.UpdateRects.cRects += cbFitingRects/sizeof (RECT);
    6935             Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    6936 
    6937             pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbFitingRects;
    6938             Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    6939         }
    6940 
    6941         memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
    6942         pPresent->pPatchLocationListOut->PatchOffset = 0;
    6943         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    6944         ++pPresent->pPatchLocationListOut;
    6945         pPresent->pPatchLocationListOut->PatchOffset = 4;
    6946         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    6947         ++pPresent->pPatchLocationListOut;
    6948     }
    6949     else if (pPresent->Flags.Flip)
    6950     {
    6951         Assert(pPresent->Flags.Value == 4); /* only Blt is set, we do not support anything else for now */
    6952         Assert(pContext->enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D);
    6953         DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
    6954         PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pSrc);
    6955 
    6956         if (!pSrcAlloc)
    6957         {
    6958             /* this should not happen actually */
    6959             WARN(("failed to get pSrc Allocation info for hDeviceSpecificAllocation(0x%x)",pSrc->hDeviceSpecificAllocation));
    6960             Status = STATUS_INVALID_HANDLE;
    6961             goto done;
    6962         }
    6963 
    6964         Assert(pDevExt->cContexts3D);
    6965         pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP;
    6966         PVBOXWDDM_DMA_PRIVATEDATA_FLIP pFlip = (PVBOXWDDM_DMA_PRIVATEDATA_FLIP)pPrivateData;
    6967 
    6968         vboxWddmPopulateDmaAllocInfo(&pFlip->Flip.Alloc, pSrcAlloc, pSrc);
    6969 
    6970         UINT cbCmd = sizeof (VBOXWDDM_DMA_PRIVATEDATA_FLIP);
    6971         pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbCmd;
    6972         pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    6973         Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    6974 
    6975         memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
    6976         pPresent->pPatchLocationListOut->PatchOffset = 0;
    6977         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    6978         ++pPresent->pPatchLocationListOut;
    6979     }
    6980     else if (pPresent->Flags.ColorFill)
    6981     {
    6982         Assert(pContext->enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D);
    6983         Assert(pPresent->Flags.Value == 2); /* only ColorFill is set, we do not support anything else for now */
    6984         DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
    6985         PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDst);
    6986         if (!pDstAlloc)
    6987         {
    6988 
    6989             /* this should not happen actually */
    6990             WARN(("failed to get pDst Allocation info for hDeviceSpecificAllocation(0x%x)",pDst->hDeviceSpecificAllocation));
    6991             Status = STATUS_INVALID_HANDLE;
    6992             goto done;
    6993         }
    6994 
    6995         UINT cbCmd = pPresent->DmaBufferPrivateDataSize;
    6996         pPrivateData->BaseHdr.enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL;
    6997         PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL pCF = (PVBOXWDDM_DMA_PRIVATEDATA_CLRFILL)pPrivateData;
    6998 
    6999         vboxWddmPopulateDmaAllocInfo(&pCF->ClrFill.Alloc, pDstAlloc, pDst);
    7000 
    7001         pCF->ClrFill.Color = pPresent->Color;
    7002         pCF->ClrFill.Rects.cRects = 0;
    7003         UINT cbHead = RT_UOFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_CLRFILL, ClrFill.Rects.aRects[0]);
    7004         Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    7005         UINT cbRects = (pPresent->SubRectCnt - pPresent->MultipassOffset) * sizeof (RECT);
    7006         pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    7007         Assert(pPresent->DmaSize >= VBOXWDDM_DUMMY_DMABUFFER_SIZE);
    7008         cbCmd -= cbHead;
    7009         Assert(cbCmd < UINT32_MAX/2);
    7010         Assert(cbCmd > sizeof (RECT));
    7011         if (cbCmd >= cbRects)
    7012         {
    7013             cbCmd -= cbRects;
    7014             memcpy(&pCF->ClrFill.Rects.aRects[pPresent->MultipassOffset], pPresent->pDstSubRects, cbRects);
    7015             pCF->ClrFill.Rects.cRects += cbRects/sizeof (RECT);
    7016 
    7017             pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbRects;
    7018         }
    7019         else
    7020         {
    7021             UINT cbFitingRects = (cbCmd/sizeof (RECT)) * sizeof (RECT);
    7022             Assert(cbFitingRects);
    7023             memcpy(&pCF->ClrFill.Rects.aRects[0], pPresent->pDstSubRects, cbFitingRects);
    7024             cbCmd -= cbFitingRects;
    7025             pPresent->MultipassOffset += cbFitingRects/sizeof (RECT);
    7026             pCF->ClrFill.Rects.cRects += cbFitingRects/sizeof (RECT);
    7027             Assert(pPresent->SubRectCnt > pPresent->MultipassOffset);
    7028 
    7029             pPresent->pDmaBufferPrivateData = (uint8_t*)pPresent->pDmaBufferPrivateData + cbHead + cbFitingRects;
    7030             Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
    7031         }
    7032 
    7033         memset(pPresent->pPatchLocationListOut, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
    7034         pPresent->pPatchLocationListOut->PatchOffset = 0;
    7035         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
    7036         ++pPresent->pPatchLocationListOut;
    7037     }
    7038     else
    7039     {
    7040         WARN(("cmd NOT IMPLEMENTED!! Flags(0x%x)", pPresent->Flags.Value));
    7041         Status = STATUS_NOT_SUPPORTED;
    7042     }
    7043 
    7044 done:
    7045 //    LOGF(("LEAVE, hContext(0x%x), Status(0x%x)", hContext, Status));
    7046 
    7047     return Status;
    70484614}
    70494615
     
    71594725                    vboxWddmDisplaySettingsCheckPos(pDevExt, i);
    71604726                }
    7161 
    7162 #ifdef VBOX_WITH_CROGL
    7163                 if (!VBOXWDDM_IS_DISPLAYONLY() && pDevExt->f3DEnabled)
    7164                 {
    7165                     VBoxMpCrPackerInit(&pContext->CrPacker);
    7166                     int rc = VBoxMpCrCtlConConnect(pDevExt, &pDevExt->CrCtlCon, CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR, &pContext->u32CrConClientID);
    7167                     if (!RT_SUCCESS(rc))
    7168                         WARN(("VBoxMpCrCtlConConnect failed rc (%d), ignoring for system context", rc));
    7169                 }
    7170 #endif
    71714727            }
    71724728            Status = STATUS_SUCCESS;
     
    71824738                switch (pInfo->enmType)
    71834739                {
    7184 #ifdef VBOX_WITH_CROGL
    7185                     case VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D:
    7186                     {
    7187                         if (!pDevExt->fCmdVbvaEnabled)
    7188                         {
    7189                             Status = vboxVideoAMgrCtxCreate(&pDevExt->AllocMgr, &pContext->AllocContext);
    7190                             if (!NT_SUCCESS(Status))
    7191                                 WARN(("vboxVideoAMgrCtxCreate failed %#x", Status));
    7192                         }
    7193                         else
    7194                             Status = STATUS_SUCCESS;
    7195 
    7196                         if (Status == STATUS_SUCCESS)
    7197                         {
    7198                             Status = vboxWddmSwapchainCtxInit(pDevExt, pContext);
    7199                             AssertNtStatusSuccess(Status);
    7200                             if (Status == STATUS_SUCCESS)
    7201                             {
    7202                                 pContext->enmType = VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D;
    7203                                 Status = vboxVideoCmCtxAdd(&pDevice->pAdapter->CmMgr, &pContext->CmContext, (HANDLE)pInfo->u.vbox.hUmEvent, pInfo->u.vbox.u64UmInfo);
    7204                                 AssertNtStatusSuccess(Status);
    7205                                 if (Status == STATUS_SUCCESS)
    7206                                 {
    7207                                     if (pInfo->u.vbox.crVersionMajor || pInfo->u.vbox.crVersionMinor)
    7208                                     {
    7209                                         if (pDevExt->f3DEnabled)
    7210                                         {
    7211                                             if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX)
    7212                                             {
    7213                                                 int rc = VBoxMpCrCtlConConnect(pDevExt, &pDevExt->CrCtlCon,
    7214                                                     pInfo->u.vbox.crVersionMajor, pInfo->u.vbox.crVersionMinor,
    7215                                                     &pContext->u32CrConClientID);
    7216                                                 if (RT_SUCCESS(rc))
    7217                                                 {
    7218                                                     VBoxMpCrPackerInit(&pContext->CrPacker);
    7219                                                 }
    7220                                                 else
    7221                                                 {
    7222                                                     WARN(("VBoxMpCrCtlConConnect failed rc (%d)", rc));
    7223                                                     Status = STATUS_UNSUCCESSFUL;
    7224                                                 }
    7225                                             }
    7226                                         }
    7227                                         else
    7228                                         {
    7229                                             LOG(("3D Not Enabled, failing 3D context creation"));
    7230                                             Status = STATUS_UNSUCCESSFUL;
    7231                                         }
    7232                                     }
    7233 
    7234                                     if (NT_SUCCESS(Status))
    7235                                     {
    7236                                         ASMAtomicIncU32(&pDevExt->cContexts3D);
    7237                                         break;
    7238                                     }
    7239                                 }
    7240 
    7241                                 vboxWddmSwapchainCtxTerm(pDevExt, pContext);
    7242                             }
    7243                             vboxVideoAMgrCtxDestroy(&pContext->AllocContext);
    7244                         }
    7245                         break;
    7246                     }
    7247                     case VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D:
    7248                     case VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL:
    7249                     {
    7250                         pContext->enmType = pInfo->enmType;
    7251                         if (!pDevExt->fCmdVbvaEnabled)
    7252                         {
    7253                             Status = vboxVideoAMgrCtxCreate(&pDevExt->AllocMgr, &pContext->AllocContext);
    7254                             if (!NT_SUCCESS(Status))
    7255                                 WARN(("vboxVideoAMgrCtxCreate failed %#x", Status));
    7256                         }
    7257                         else
    7258                             Status = STATUS_SUCCESS;
    7259 
    7260                         if (Status == STATUS_SUCCESS)
    7261                         {
    7262                             if (pInfo->u.vbox.crVersionMajor || pInfo->u.vbox.crVersionMinor)
    7263                             {
    7264                                 if (pDevExt->f3DEnabled)
    7265                                 {
    7266                                     if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX)
    7267                                     {
    7268                                         int rc = VBoxMpCrCtlConConnect(pDevExt, &pDevExt->CrCtlCon,
    7269                                             pInfo->u.vbox.crVersionMajor, pInfo->u.vbox.crVersionMinor,
    7270                                             &pContext->u32CrConClientID);
    7271                                         if (!RT_SUCCESS(rc))
    7272                                         {
    7273                                             WARN(("VBoxMpCrCtlConConnect failed rc (%d)", rc));
    7274                                             Status = STATUS_UNSUCCESSFUL;
    7275                                         }
    7276                                     }
    7277                                 }
    7278                                 else
    7279                                 {
    7280                                     LOG(("3D Not Enabled, failing 3D (hgsmi) context creation"));
    7281                                     Status = STATUS_UNSUCCESSFUL;
    7282                                 }
    7283                             }
    7284 
    7285                             if (NT_SUCCESS(Status))
    7286                             {
    7287                                 ASMAtomicIncU32(&pDevExt->cContexts3D);
    7288                                 break;
    7289                             }
    7290                             vboxVideoAMgrCtxDestroy(&pContext->AllocContext);
    7291                         }
    7292                         break;
    7293                     }
    7294 #endif
    7295                     case VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D:
    7296                     {
    7297                         pContext->enmType = pInfo->enmType;
    7298                         ASMAtomicIncU32(&pDevExt->cContexts2D);
    7299                         break;
    7300                     }
    73014740                    case VBOXWDDM_CONTEXT_TYPE_CUSTOM_DISPIF_RESIZE:
    73024741                    {
     
    73704809    switch(pContext->enmType)
    73714810    {
    7372         case VBOXWDDM_CONTEXT_TYPE_CUSTOM_3D:
    7373         case VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D:
    7374         case VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL:
    7375         {
    7376             uint32_t cContexts = ASMAtomicDecU32(&pDevExt->cContexts3D);
    7377             Assert(cContexts < UINT32_MAX/2); NOREF(cContexts);
    7378             break;
    7379         }
    7380         case VBOXWDDM_CONTEXT_TYPE_CUSTOM_2D:
    7381         {
    7382             uint32_t cContexts = ASMAtomicDecU32(&pDevExt->cContexts2D);
    7383             Assert(cContexts < UINT32_MAX/2); NOREF(cContexts);
    7384             break;
    7385         }
    73864811        case VBOXWDDM_CONTEXT_TYPE_CUSTOM_DISPIF_RESIZE:
    73874812        {
     
    74174842            break;
    74184843    }
    7419 
    7420 #ifdef VBOX_WITH_CROGL
    7421     if (pDevExt->enmHwType == VBOXVIDEO_HWTYPE_VBOX && pContext->u32CrConClientID)
    7422     {
    7423         VBoxMpCrCtlConDisconnect(pDevExt, &pDevExt->CrCtlCon, pContext->u32CrConClientID);
    7424     }
    7425 #endif
    7426 
    7427 #ifdef VBOX_WITH_CROGL
    7428     /* first terminate the swapchain, this will also ensure
    7429      * all currently pending driver->user Cm commands
    7430      * (i.e. visible regions commands) are completed */
    7431     vboxWddmSwapchainCtxTerm(pDevExt, pContext);
    7432 #endif
    74334844
    74344845    Status = vboxVideoAMgrCtxDestroy(&pContext->AllocContext);
     
    77735184}
    77745185
    7775 static NTSTATUS vboxWddmInitFullGraphicsDriver(IN PDRIVER_OBJECT pDriverObject, IN PUNICODE_STRING pRegistryPath, BOOLEAN fCmdVbva)
    7776 {
    7777 #ifdef VBOX_WITH_CROGL
    7778 #define VBOXWDDM_CALLBACK_NAME(_base, _fCmdVbva) ((_fCmdVbva) ? _base##New : _base##Legacy)
    7779 #else
    7780 #define VBOXWDDM_CALLBACK_NAME(_base, _fCmdVbva) (_base##Legacy)
    7781 #endif
    7782 
     5186static NTSTATUS vboxWddmInitFullGraphicsDriver(IN PDRIVER_OBJECT pDriverObject, IN PUNICODE_STRING pRegistryPath)
     5187{
    77835188    DRIVER_INITIALIZATION_DATA DriverInitializationData = {'\0'};
    77845189
     
    77945199    DriverInitializationData.DxgkDdiRemoveDevice = DxgkDdiRemoveDevice;
    77955200    DriverInitializationData.DxgkDdiDispatchIoRequest = DxgkDdiDispatchIoRequest;
    7796     DriverInitializationData.DxgkDdiInterruptRoutine = VBOXWDDM_CALLBACK_NAME(DxgkDdiInterruptRoutine, fCmdVbva);
    7797     DriverInitializationData.DxgkDdiDpcRoutine = VBOXWDDM_CALLBACK_NAME(DxgkDdiDpcRoutine, fCmdVbva);
     5201    DriverInitializationData.DxgkDdiInterruptRoutine          = GaDxgkDdiInterruptRoutine;
     5202    DriverInitializationData.DxgkDdiDpcRoutine                = GaDxgkDdiDpcRoutine;
    77985203    DriverInitializationData.DxgkDdiQueryChildRelations = DxgkDdiQueryChildRelations;
    77995204    DriverInitializationData.DxgkDdiQueryChildStatus = DxgkDdiQueryChildStatus;
     
    78145219    DriverInitializationData.DxgkDdiAcquireSwizzlingRange = DxgkDdiAcquireSwizzlingRange;
    78155220    DriverInitializationData.DxgkDdiReleaseSwizzlingRange = DxgkDdiReleaseSwizzlingRange;
    7816     DriverInitializationData.DxgkDdiPatch = VBOXWDDM_CALLBACK_NAME(DxgkDdiPatch, fCmdVbva);
    7817     DriverInitializationData.DxgkDdiSubmitCommand = VBOXWDDM_CALLBACK_NAME(DxgkDdiSubmitCommand, fCmdVbva);
    7818     DriverInitializationData.DxgkDdiPreemptCommand = VBOXWDDM_CALLBACK_NAME(DxgkDdiPreemptCommand, fCmdVbva);
    7819     DriverInitializationData.DxgkDdiBuildPagingBuffer = VBOXWDDM_CALLBACK_NAME(DxgkDdiBuildPagingBuffer, fCmdVbva);
     5221
     5222    DriverInitializationData.DxgkDdiPatch                     = GaDxgkDdiPatch;
     5223    DriverInitializationData.DxgkDdiSubmitCommand             = GaDxgkDdiSubmitCommand;
     5224    DriverInitializationData.DxgkDdiPreemptCommand            = GaDxgkDdiPreemptCommand;
     5225    DriverInitializationData.DxgkDdiBuildPagingBuffer         = GaDxgkDdiBuildPagingBuffer;
     5226
    78205227    DriverInitializationData.DxgkDdiSetPalette = DxgkDdiSetPalette;
    78215228    DriverInitializationData.DxgkDdiSetPointerPosition = DxgkDdiSetPointerPosition;
     
    78255232    DriverInitializationData.DxgkDdiEscape = DxgkDdiEscape;
    78265233    DriverInitializationData.DxgkDdiCollectDbgInfo = DxgkDdiCollectDbgInfo;
    7827     DriverInitializationData.DxgkDdiQueryCurrentFence = VBOXWDDM_CALLBACK_NAME(DxgkDdiQueryCurrentFence, fCmdVbva);
     5234    DriverInitializationData.DxgkDdiQueryCurrentFence         = GaDxgkDdiQueryCurrentFence;
    78285235    DriverInitializationData.DxgkDdiIsSupportedVidPn = DxgkDdiIsSupportedVidPn;
    78295236    DriverInitializationData.DxgkDdiRecommendFunctionalVidPn = DxgkDdiRecommendFunctionalVidPn;
     
    78435250    DriverInitializationData.DxgkDdiOpenAllocation = DxgkDdiOpenAllocation;
    78445251    DriverInitializationData.DxgkDdiCloseAllocation = DxgkDdiCloseAllocation;
    7845     DriverInitializationData.DxgkDdiRender = VBOXWDDM_CALLBACK_NAME(DxgkDdiRender, fCmdVbva);
    7846     DriverInitializationData.DxgkDdiPresent = VBOXWDDM_CALLBACK_NAME(DxgkDdiPresent, fCmdVbva);
     5252    DriverInitializationData.DxgkDdiRender                    = GaDxgkDdiRender;
     5253    DriverInitializationData.DxgkDdiPresent                   = GaDxgkDdiPresent;
    78475254
    78485255    DriverInitializationData.DxgkDdiUpdateOverlay = DxgkDdiUpdateOverlay;
     
    79675374        }
    79685375
    7969         BOOL fCmdVbva = FALSE;
    79705376        if (enmHwType == VBOXVIDEO_HWTYPE_VBOX)
    79715377        {
    7972             /* Try to establish connection to the host 3D service. */
    7973 #ifdef VBOX_WITH_CROGL
    7974             VBoxMpCrCtlConInit();
    7975 
    7976             /* always need to do the check to request host caps */
    7977             LOG(("Doing the 3D check.."));
    7978             f3DSupported = VBoxMpCrCtlConIs3DSupported();
    7979 
    7980             fCmdVbva = RT_BOOL(VBoxMpCrGetHostCaps() & CR_VBOX_CAP_CMDVBVA);
    7981 #endif
     5378            /* No 3D for legacy adapter. */
     5379            f3DSupported = FALSE;
    79825380        }
    79835381        else if (enmHwType == VBOXVIDEO_HWTYPE_VMSVGA)
    79845382        {
    7985             fCmdVbva = TRUE;
     5383            /* Nothing. */
    79865384        }
    79875385        else
     
    80315429        if (NT_SUCCESS(Status))
    80325430        {
    8033 #ifdef VBOX_WITH_CROGL
    8034             rc = VBoxVrInit();
    8035             if (RT_SUCCESS(rc))
    8036 #endif
    8037             {
    8038                 if (g_VBoxDisplayOnly)
    8039                 {
    8040                     Status = vboxWddmInitDisplayOnlyDriver(DriverObject, RegistryPath);
    8041                 }
    8042                 else
    8043                 {
    8044                     Status = vboxWddmInitFullGraphicsDriver(DriverObject, RegistryPath, fCmdVbva);
    8045                 }
    8046 
    8047                 if (NT_SUCCESS(Status))
    8048                 {
    8049                     /*
    8050                      * Successfully initialized the driver.
    8051                      */
    8052                     return Status;
    8053                 }
    8054 
     5431            if (g_VBoxDisplayOnly)
     5432            {
     5433                Status = vboxWddmInitDisplayOnlyDriver(DriverObject, RegistryPath);
     5434            }
     5435            else
     5436            {
     5437                Assert(enmHwType == VBOXVIDEO_HWTYPE_VMSVGA);
     5438                Status = vboxWddmInitFullGraphicsDriver(DriverObject, RegistryPath);
     5439            }
     5440
     5441            if (NT_SUCCESS(Status))
     5442            {
    80555443                /*
    8056                  * Cleanup on failure.
     5444                 * Successfully initialized the driver.
    80575445                 */
    8058 
    8059 #ifdef VBOX_WITH_CROGL
    8060                 VBoxVrTerm();
    8061 #endif
    8062             }
    8063 #ifdef VBOX_WITH_CROGL
    8064             else
    8065             {
    8066                 WARN(("VBoxVrInit failed, rc(%d)", rc));
    8067                 Status = STATUS_UNSUCCESSFUL;
    8068             }
    8069 #endif
     5446                return Status;
     5447            }
     5448
     5449            /*
     5450             * Cleanup on failure.
     5451             */
    80705452        }
    80715453        else
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.h

    r76563 r80422  
    194194
    195195#ifdef VBOX_WITH_CROGL
    196 #define VBOXWDDMENTRY_2_SWAPCHAIN(_pE) ((PVBOXWDDM_SWAPCHAIN)((uint8_t*)(_pE) - RT_UOFFSETOF(VBOXWDDM_SWAPCHAIN, DevExtListEntry)))
    197 
    198196BOOLEAN DxgkDdiInterruptRoutineNew(
    199197    IN CONST PVOID MiniportDeviceContext,
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/VBoxMPGaWddm.cpp

    r77225 r80422  
    658658    DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
    659659    DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
     660
     661#ifdef VBOX_WDDM_DUMP_REGIONS_ON_PRESENT
     662    LogRel(("%s: [%ld, %ld, %ld, %ld] -> [%ld, %ld, %ld, %ld] (SubRectCnt=%u)\n",
     663        pPresent->Flags.Blt ? "Blt" : (pPresent->Flags.Flip ? "Flip" : (pPresent->Flags.ColorFill ? "ColorFill" : "Unknown OP")),
     664        pPresent->SrcRect.left, pPresent->SrcRect.top, pPresent->SrcRect.right, pPresent->SrcRect.bottom,
     665        pPresent->DstRect.left, pPresent->DstRect.top, pPresent->DstRect.right, pPresent->DstRect.bottom,
     666        pPresent->SubRectCnt));
     667    for (unsigned int i = 0; i < pPresent->SubRectCnt; i++)
     668        LogRel(("\tsub#%u = [%ld, %ld, %ld, %ld]\n", i, pPresent->pDstSubRects[i].left, pPresent->pDstSubRects[i].top, pPresent->pDstSubRects[i].right, pPresent->pDstSubRects[i].bottom));
     669#endif
    660670
    661671    if (pPresent->Flags.Blt)
     
    14101420    }
    14111421
     1422    pDevExt->u.primary.DxgkInterface.DxgkCbQueueDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
     1423
    14121424    GALOG(("leave\n"));
    14131425    /* "Return TRUE as quickly as possible". */
     
    14251437    }
    14261438
    1427     // pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
     1439    pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    14281440
    14291441    /* Scan fence objects and mark all with u32FenceId < u32LastCompletedFenceId as SIGNALED */
  • trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h

    r76563 r80422  
    3131# define VBOXESC_DBGPRINT                   0xABCD9005
    3232# define VBOXESC_SCREENLAYOUT               0xABCD9006
    33 # define VBOXESC_SWAPCHAININFO              0xABCD9007
    34 # define VBOXESC_UHGSMI_ALLOCATE            0xABCD9008
    35 # define VBOXESC_UHGSMI_DEALLOCATE          0xABCD9009
    36 # define VBOXESC_UHGSMI_SUBMIT              0xABCD900A
     33// obsolete                                 0xABCD9007
     34// obsolete                                 0xABCD9008
     35// obsolete                                 0xABCD9009
     36// obsolete                                 0xABCD900A
    3737# define VBOXESC_SHRC_ADDREF                0xABCD900B
    3838# define VBOXESC_SHRC_RELEASE               0xABCD900C
    3939# define VBOXESC_DBGDUMPBUF                 0xABCD900D
    40 # define VBOXESC_CRHGSMICTLCON_CALL         0xABCD900E
    41 # define VBOXESC_CRHGSMICTLCON_GETCLIENTID  0xABCD900F
     40// obsolete                                 0xABCD900E
     41// obsolete                                 0xABCD900F
    4242# define VBOXESC_REINITVIDEOMODESBYMASK     0xABCD9010
    4343# define VBOXESC_ADJUSTVIDEOMODES           0xABCD9011
    44 # define VBOXESC_SETCTXHOSTID               0xABCD9012
     44// obsolete                                 0xABCD9012
    4545# define VBOXESC_CONFIGURETARGETS           0xABCD9013
    4646# define VBOXESC_SETALLOCHOSTID             0xABCD9014
    47 # define VBOXESC_CRHGSMICTLCON_GETHOSTCAPS  0xABCD9015
     47// obsolete                                 0xABCD9015
    4848# define VBOXESC_UPDATEMODES                0xABCD9016
    4949# define VBOXESC_GUEST_DISPLAYCHANGED       0xABCD9017
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