Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/Makefile.kmk	(revision 95234)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/Makefile.kmk	(revision 95250)
@@ -117,4 +117,7 @@
  VBoxDispD3D_DEFS   += VBOX_WITH_VIDEOHWACCEL
 endif
+# Avoid "src\VBox\Additions\3D\mesa\mesa-21.3.8\include\c99_compat.h(99): warning C4668: '__STDC_VERSION__'
+# is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'"
+VBoxDispD3D_DEFS    += __STDC_VERSION__=0
 VBoxDispD3D_INCS     = \
 	../../../include \
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaDdi.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaDdi.cpp	(revision 95234)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/GaDdi.cpp	(revision 95250)
@@ -2166,5 +2166,28 @@
                 pAllocation->hAllocation   = pOAI->hAllocation;
                 pAllocation->enmType       = VBOXWDDM_ALLOC_TYPE_D3D;
-                pAllocation->hSharedHandle = 0; /* This is should be a sid of the allocation. Not needed here. */
+
+                /* 'hSharedHandle' a sid of the allocation. */
+                IDirect3DDevice9 *pDevice9If = VBOXDISP_D3DEV(pDevice);
+                IGaDirect3DDevice9Ex *pGaD3DDevice9Ex = NULL;
+                HRESULT hr2 = pDevice9If->QueryInterface(IID_IGaDirect3DDevice9Ex, (void**)&pGaD3DDevice9Ex);
+                Assert(SUCCEEDED(hr2));
+                if (SUCCEEDED(hr2))
+                {
+                    Assert(pGaD3DDevice9Ex);
+
+                    VBOXDISPIFESCAPE_SVGAGETSID data;
+                    memset(&data, 0, sizeof(data));
+                    data.EscapeHdr.escapeCode = VBOXESC_SVGAGETSID;
+                    data.hAllocation = pOAI->hAllocation;
+                    // data.u32Sid = 0;
+                    hr2 = pGaD3DDevice9Ex->EscapeCb(&data, sizeof(data), /* fHardwareAccess= */ false);
+                    if (SUCCEEDED(hr2))
+                        pAllocation->hSharedHandle = (HANDLE)(uintptr_t)data.u32Sid;
+                    else
+                        pAllocation->hSharedHandle = 0;
+
+                    pGaD3DDevice9Ex->Release();
+                }
+
                 pAllocation->AllocDesc     = *pAllocDesc;
                 pAllocation->pvMem         = NULL;
@@ -2245,8 +2268,11 @@
             else if (pOAI->pPrivateDriverData && pOAI->PrivateDriverDataSize == sizeof(VBOXDXALLOCATIONDESC))
             {
+                /* This is D3D UMD (VBoxDX) resource. Do the same as for "generic" resource branch below. */
                 VBOXDXALLOCATIONDESC *pAllocDesc = (VBOXDXALLOCATIONDESC *)pOAI->pPrivateDriverData;
+
+                pRc->fFlags.Generic = 1;
+                pRc->cAllocations   = 1;
                 pRc->RcDesc.fFlags.Primary = pAllocDesc->fPrimary;
                 pRc->RcDesc.fFlags.RenderTarget = 1;
-                //pRc->RcDesc.fFlags.NotLockable = 1;
                 pRc->RcDesc.enmFormat      = pAllocDesc->enmDDIFormat;
                 if (pAllocDesc->fPrimary)
@@ -2255,4 +2281,37 @@
                    pRc->RcDesc.RefreshRate.Numerator = pAllocDesc->PrimaryDesc.ModeDesc.RefreshRate.Numerator;
                    pRc->RcDesc.RefreshRate.Denominator = pAllocDesc->PrimaryDesc.ModeDesc.RefreshRate.Denominator;
+                }
+
+                hr = GaD3DIfCreateForRc(pRc);
+                if (SUCCEEDED(hr))
+                {
+                   /* Get the just created surface id and inform the miniport that the surface id
+                    * should be replaced with the original surface id.
+                    */
+                   IDirect3DDevice9 *pDevice9If = VBOXDISP_D3DEV(pDevice);
+                   IGaDirect3DDevice9Ex *pGaD3DDevice9Ex = NULL;
+                   HRESULT hr2 = pDevice9If->QueryInterface(IID_IGaDirect3DDevice9Ex, (void**)&pGaD3DDevice9Ex);
+                   if (SUCCEEDED(hr2))
+                   {
+                       Assert(pGaD3DDevice9Ex);
+                       PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0]; /* First allocation is enough. */
+                       uint32_t u32Sid;
+                       hr2 = pGaD3DDevice9Ex->GaSurfaceId(pAllocation->pD3DIf, &u32Sid);
+                       if (SUCCEEDED(hr2))
+                       {
+                           /* Inform the miniport. */
+                           Assert(pAllocation->hSharedHandle);
+
+                           pAllocation->hostID = u32Sid;
+
+                           VBOXDISPIFESCAPE_GASHAREDSID data;
+                           RT_ZERO(data);
+                           data.EscapeHdr.escapeCode = VBOXESC_GASHAREDSID;
+                           data.u32Sid = u32Sid;
+                           data.u32SharedSid = (uint32_t)(uintptr_t)pAllocation->hSharedHandle;
+                           hr2 = pGaD3DDevice9Ex->EscapeCb(&data, sizeof(data), /* fHardwareAccess= */ false);
+                       }
+                       pGaD3DDevice9Ex->Release();
+                   }
                 }
             }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/Present.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/Present.cpp	(revision 95234)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/gallium/Present.cpp	(revision 95250)
@@ -266,7 +266,10 @@
 HRESULT WINAPI WDDMPresent::GetCursorPos(POINT *pPoint)
 {
-    RT_NOREF(pPoint);
-    TRAPNOTIMPL;
-    return D3DERR_INVALIDCALL;
+    if (!::GetCursorPos(pPoint))
+    {
+        pPoint->x = 0;
+        pPoint->y = 0;
+    }
+    return S_OK;
 }
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.cpp	(revision 95234)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.cpp	(revision 95250)
@@ -1038,4 +1038,14 @@
                 Status = SvgaProcessSurface(pSvga, &p->dstSid, pHOA);
         } break;
+        case SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW:
+        {
+            SVGA3dCmdDXDefineRenderTargetView *p = (SVGA3dCmdDXDefineRenderTargetView *)pCommand;
+            Status = SvgaProcessSurface(pSvga, &p->sid, pHOA);
+        } break;
+        case SVGA_3D_CMD_DX_DEFINE_SHADERRESOURCE_VIEW:
+        {
+            SVGA3dCmdDXDefineShaderResourceView *p = (SVGA3dCmdDXDefineShaderResourceView *)pCommand;
+            Status = SvgaProcessSurface(pSvga, &p->sid, pHOA);
+        } break;
         default:
             if (SVGA_3D_CMD_DX_MIN <= u32CmdId && u32CmdId <= SVGA_3D_CMD_DX_MAX)
@@ -1824,5 +1834,5 @@
     if (NT_SUCCESS(Status))
     {
-        Status = SvgaGboFillPageTableForArray(&pRegion->pMob->gbo, pRegion->u32NumPages, pRegion->aPhys);
+        Status = SvgaGboFillPageTableForMemObj(&pRegion->pMob->gbo, pRegion->MemObj);
         Assert(NT_SUCCESS(Status));
         if (NT_SUCCESS(Status))
@@ -1873,6 +1883,6 @@
 static NTSTATUS gmrAlloc(GAWDDMREGION *pRegion)
 {
-    int rc = RTR0MemObjAllocLowTag(&pRegion->MemObj, pRegion->u32NumPages << PAGE_SHIFT,
-                                   false /* executable R0 mapping */, "WDDMGA");
+    int rc = RTR0MemObjAllocPageTag(&pRegion->MemObj, pRegion->u32NumPages << PAGE_SHIFT,
+                                    false /* executable R0 mapping */, "VMSVGAGMR");
     AssertRC(rc);
     if (RT_SUCCESS(rc))
@@ -2064,5 +2074,5 @@
                     Status = SvgaGMRReport(pSvga,
                                            VMSVGAMOB_ID(pRegion->pMob),
-                                           SVGA_REMAP_GMR2_PPN32,
+                                           SVGA_REMAP_GMR2_PPN64,
                                            pRegion->u32NumPages,
                                            &pRegion->aPhys[0]);
@@ -2284,35 +2294,4 @@
         for (unsigned i = 0; i < pGbo->cbGbo >> PAGE_SHIFT; ++i)
             paPpnGbo[i] = RTR0MemObjGetPagePhysAddr(hMemObj, i) >> PAGE_SHIFT;
-    }
-    return STATUS_SUCCESS;
-}
-
-
-NTSTATUS SvgaGboFillPageTableForArray(PVMSVGAGBO pGbo,
-                                      uint32_t u32NumPages,
-                                      RTHCPHYS *paPhys)
-{
-    if (pGbo->enmMobFormat == SVGA3D_MOBFMT_PTDEPTH64_0)
-    {
-        Assert(u32NumPages == 1);
-        pGbo->base = paPhys[0] >> PAGE_SHIFT;
-    }
-    else
-    {
-        /* The first of pages is alway the base. It is either the level 2 page or the single level 1 page */
-        pGbo->base = RTR0MemObjGetPagePhysAddr(pGbo->hMemObjPT, 0) >> PAGE_SHIFT;
-
-        PPN64 *paPpn = (PPN64 *)RTR0MemObjAddress(pGbo->hMemObjPT);
-        PPN64 *paPpnGbo;
-        if (pGbo->enmMobFormat == SVGA3D_MOBFMT_PTDEPTH64_2)
-            paPpnGbo = &paPpn[PAGE_SIZE / sizeof(PPN64)]; /* Level 1 pages follow the level 2 page. */
-        else if (pGbo->enmMobFormat == SVGA3D_MOBFMT_PTDEPTH64_1)
-            paPpnGbo = paPpn;
-        else
-            AssertFailedReturn(STATUS_INVALID_PARAMETER);
-
-        /* Store page numbers into the level 1 description pages. */
-        for (unsigned i = 0; i < u32NumPages; ++i)
-            paPpnGbo[i] = paPhys[i] >> PAGE_SHIFT;
     }
     return STATUS_SUCCESS;
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.h	(revision 95234)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/Svga.h	(revision 95250)
@@ -610,7 +610,4 @@
 NTSTATUS SvgaGboFillPageTableForMemObj(PVMSVGAGBO pGbo,
                                        RTR0MEMOBJ hMemObj);
-NTSTATUS SvgaGboFillPageTableForArray(PVMSVGAGBO pGbo,
-                                      uint32_t u32NumPages,
-                                      RTHCPHYS *paPhys);
 
 void SvgaMobFree(VBOXWDDM_EXT_VMSVGA *pSvga,
