Index: /trunk/include/VBox/VBoxVideo.h
===================================================================
--- /trunk/include/VBox/VBoxVideo.h	(revision 29487)
+++ /trunk/include/VBox/VBoxVideo.h	(revision 29488)
@@ -539,4 +539,11 @@
     uint32_t reserved;
 } VBOXVHWA_VERSION;
+
+#define VBOXVHWA_VERSION_INIT(_pv) do { \
+        (_pv)->maj = VBOXVHWA_VERSION_MAJ; \
+        (_pv)->min = VBOXVHWA_VERSION_MIN; \
+        (_pv)->bld = VBOXVHWA_VERSION_BLD; \
+        (_pv)->reserved = VBOXVHWA_VERSION_RSV; \
+        } while(0)
 
 typedef struct _VBOXVHWACMD_QUERYINFO1
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 29487)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/Makefile.kmk	(revision 29488)
@@ -77,4 +77,7 @@
 VBoxDispD3D_TEMPLATE = VBOXGUESTR3DLL
 VBoxDispD3D_DEFS     = UNICODE _UNICODE
+ifdef VBOX_WITH_VIDEOHWACCEL
+ VBoxDispD3D_DEFS   += VBOX_WITH_VIDEOHWACCEL
+endif
 VBoxDispD3D_SOURCES  = \
 	wddm/VBoxDispD3D.cpp \
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 29487)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp	(revision 29488)
@@ -30,4 +30,5 @@
 #include "VBoxDispD3D.h"
 #include "VBoxDispD3DCmn.h"
+#include "../../Miniport/wddm/VBoxVideoIf.h"
 
 #ifdef VBOXWDDMDISP_DEBUG
@@ -73,21 +74,110 @@
 
     HRESULT hr = S_OK;
+    PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)hAdapter;
 
     switch (pData->Type)
     {
         case D3DDDICAPS_DDRAW:
+        {
+            AssertBreakpoint();
             Assert(pData->DataSize >= sizeof (DDRAW_CAPS));
             if (pData->DataSize >= sizeof (DDRAW_CAPS))
+            {
                 memset(pData->pData, 0, sizeof (DDRAW_CAPS));
+#ifdef VBOX_WITH_VIDEOHWACCEL
+                VBOXWDDM_QI_2D_1 Query;
+                Query.hdr.enmType = VBOXWDDM_QI_TYPE_2D_1;
+                VBOXVHWA_VERSION_INIT(&Query.Info.u.in.guestVersion);
+                D3DDDICB_QUERYADAPTERINFO DdiQuery;
+                DdiQuery.PrivateDriverDataSize = sizeof(Query);
+                DdiQuery.pPrivateDriverData = &Query;
+                hr = pAdapter->RtCallbacks.pfnQueryAdapterInfoCb(pAdapter->hAdapter, &DdiQuery);
+                Assert(hr == S_OK);
+                if (hr == S_OK)
+                {
+                    if (Query.hdr.rc == VINF_SUCCESS)
+                    {
+                        /* query succeeded, check the results */
+                        if (Query.Info.u.out.cfgFlags == VBOXVHWA_CFG_ENABLED)
+                        {
+                            /* 2D is enabled*/
+                            DDRAW_CAPS *pCaps = (DDRAW_CAPS*)pData->pData;
+                            /* overlay supported */
+                            if (Query.Info.u.out.surfaceCaps & VBOXVHWA_SCAPS_OVERLAY)
+                            {
+                                if (Query.Info.u.out.caps & VBOXVHWA_CAPS_COLORKEY)
+                                {
+                                    pCaps->Caps = DDRAW_CAPS_COLORKEY;
+                                }
+                            }
+
+                            /* @todo: feel the caps from here */
+                        }
+                    }
+                }
+#endif
+            }
             else
                 hr = E_INVALIDARG;
             break;
+        }
         case D3DDDICAPS_DDRAW_MODE_SPECIFIC:
+        {
+            AssertBreakpoint();
             Assert(pData->DataSize >= sizeof (DDRAW_MODE_SPECIFIC_CAPS));
             if (pData->DataSize >= sizeof (DDRAW_MODE_SPECIFIC_CAPS))
-                memset(pData->pData, 0, sizeof (DDRAW_MODE_SPECIFIC_CAPS));
+            {
+                DDRAW_MODE_SPECIFIC_CAPS * pCaps = (DDRAW_MODE_SPECIFIC_CAPS*)pData->pData;
+                memset(&pCaps->Caps /* do not cleanup the first "Head" field,
+                                    zero starting with the one following "Head", i.e. Caps */,
+                        0, sizeof (DDRAW_MODE_SPECIFIC_CAPS) - RT_OFFSETOF(DDRAW_MODE_SPECIFIC_CAPS, Caps));
+#ifdef VBOX_WITH_VIDEOHWACCEL
+                VBOXWDDM_QI_2D_1 Query;
+                Query.hdr.enmType = VBOXWDDM_QI_TYPE_2D_1;
+                VBOXVHWA_VERSION_INIT(&Query.Info.u.in.guestVersion);
+                D3DDDICB_QUERYADAPTERINFO DdiQuery;
+                DdiQuery.PrivateDriverDataSize = sizeof(Query);
+                DdiQuery.pPrivateDriverData = &Query;
+                hr = pAdapter->RtCallbacks.pfnQueryAdapterInfoCb(pAdapter->hAdapter, &DdiQuery);
+                Assert(hr == S_OK);
+                if (hr == S_OK)
+                {
+                    if (Query.hdr.rc == VINF_SUCCESS)
+                    {
+                        /* query succeeded, check the results */
+                        if (Query.Info.u.out.cfgFlags == VBOXVHWA_CFG_ENABLED)
+                        {
+                            /* 2D is enabled*/
+                            if (Query.Info.u.out.surfaceCaps & VBOXVHWA_SCAPS_OVERLAY)
+                            {
+                                /* overlay supported */
+                                pCaps->Caps = MODE_CAPS_OVERLAY | MODE_CAPS_OVERLAYSTRETCH;
+                                if (Query.Info.u.out.caps & VBOXVHWA_CAPS_COLORKEY)
+                                {
+                                    if (Query.Info.u.out.colorKeyCaps & VBOXVHWA_CKEYCAPS_DESTOVERLAY)
+                                    {
+                                        pCaps->CKeyCaps |= MODE_CKEYCAPS_DESTOVERLAY
+                                                | MODE_CKEYCAPS_DESTOVERLAYYUV /* ?? */;
+                                    }
+                                }
+
+                                pCaps->FxCaps = MODE_FXCAPS_OVERLAYSHRINKX
+                                        | MODE_FXCAPS_OVERLAYSHRINKY
+                                        | MODE_FXCAPS_OVERLAYSTRETCHX
+                                        | MODE_FXCAPS_OVERLAYSTRETCHY;
+
+                                pCaps->MaxVisibleOverlays = Query.Info.u.out.numOverlays;
+                                pCaps->MinOverlayStretch = 1;
+                                pCaps->MaxOverlayStretch = 32000;
+                            }
+                        }
+                    }
+                }
+#endif
+            }
             else
                 hr = E_INVALIDARG;
             break;
+        }
         case D3DDDICAPS_GETFORMATCOUNT:
             *((uint32_t*)pData->pData) = 0;
@@ -114,10 +204,26 @@
             break;
         case D3DDDICAPS_GETD3D9CAPS:
+        {
             Assert(pData->DataSize >= sizeof (D3DCAPS9));
             if (pData->DataSize >= sizeof (D3DCAPS9))
+            {
+                if (pAdapter->pD3D9If)
+                {
+                    hr = pAdapter->pD3D9If->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, (D3DCAPS9*)pData->pData);
+                    Assert(hr == S_OK);
+                    if (hr == S_OK)
+                        break;
+
+                    vboxVDbgPrintR((__FUNCTION__": GetDeviceCaps hr(%d)\n", hr));
+                    /* let's fall back to the 3D disabled case */
+                    hr = S_OK;
+                }
+
                 memset(pData->pData, 0, sizeof (D3DCAPS9));
+            }
             else
                 hr = E_INVALIDARG;
             break;
+        }
         case D3DDDICAPS_GETGAMMARAMPCAPS:
             *((uint32_t*)pData->pData) = 0;
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 29487)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 29488)
@@ -115,4 +115,5 @@
 #else
 #include <VBox/VBoxVideo.h>
+#include "wddm/VBoxVideoIf.h"
 #include "wddm/VBoxVideoWddm.h"
 #include "wddm/VBoxVideoShgsmi.h"
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 29488)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoIf.h	(revision 29488)
@@ -0,0 +1,94 @@
+/** @file
+ * Contains base definitions of constants & structures used
+ * to control & perform rendering,
+ * such as DMA commands types, allocation types, escape codes, etc.
+ * used by both miniport & display drivers.
+ *
+ * The latter uses these and only these defs to communicate with the former
+ * by posting appropriate requests via D3D RT Krnl Svc accessing callbacks.
+ */
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___VBoxVideoIf_h___
+#define ___VBoxVideoIf_h___
+
+#include <VBox/VBoxVideo.h>
+
+/* create allocation func */
+typedef enum
+{
+    VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
+    VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
+    VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
+    VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
+    /* this one is win 7-specific and hence unused for now */
+    VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
+    /* custom allocation types requested from user-mode d3d module will go here */
+} VBOXWDDM_ALLOC_TYPE;
+
+typedef struct VBOXWDDM_SURFACE_DESC
+{
+    UINT width;
+    UINT height;
+    D3DDDIFORMAT format;
+    UINT bpp;
+    UINT pitch;
+} VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
+
+typedef struct VBOXWDDM_ALLOCINFO
+{
+    VBOXWDDM_ALLOC_TYPE enmType;
+    union
+    {
+        VBOXWDDM_SURFACE_DESC SurfInfo;
+    } u;
+} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
+
+#define VBOXWDDM_ALLOCINFO_HEADSIZE() (sizeof (VBOXWDDM_ALLOCINFO))
+#define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s))
+#define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
+#define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ( (_t*)(((uint8_t*)(_p)) + VBOXWDDM_ALLOCINFO_HEADSIZE()) )
+#define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - VBOXWDDM_ALLOCATION_HEADSIZE()))
+
+/* query info func */
+typedef enum
+{
+    VBOXWDDM_QI_TYPE_UNEFINED = 0,
+#ifdef VBOX_WITH_VIDEOHWACCEL
+    /* VBOXVHWACMD_QUERYINFO1 */
+    VBOXWDDM_QI_TYPE_2D_1,
+    /* VBOXVHWACMD_QUERYINFO2 */
+    VBOXWDDM_QI_TYPE_2D_2
+#endif
+} VBOXWDDM_QI_TYPE;
+
+typedef struct VBOXWDDM_QI
+{
+    VBOXWDDM_QI_TYPE enmType;
+    int rc;
+} VBOXWDDM_QI;
+
+typedef struct VBOXWDDM_QI_2D_1
+{
+    VBOXWDDM_QI hdr;
+    VBOXVHWACMD_QUERYINFO1 Info;
+} VBOXWDDM_QI_2D_1;
+
+typedef struct VBOXWDDM_QI_2D_2
+{
+    VBOXWDDM_QI hdr;
+    VBOXVHWACMD_QUERYINFO2 Info;
+} VBOXWDDM_QI_2D_2;
+
+/* submit cmd func */
+
+#endif /* #ifndef ___VBoxVideoIf_h___ */
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 29487)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 29488)
@@ -1280,7 +1280,59 @@
         }
         case DXGKQAITYPE_UMDRIVERPRIVATE:
-            drprintf((__FUNCTION__ ": we do not support DXGKQAITYPE_UMDRIVERPRIVATE\n"));
             AssertBreakpoint();
-            Status = STATUS_NOT_SUPPORTED;
+            Assert(pQueryAdapterInfo->InputDataSize > sizeof (VBOXWDDM_QI));
+            if (pQueryAdapterInfo->InputDataSize > sizeof (VBOXWDDM_QI)
+                    && pQueryAdapterInfo->OutputDataSize > sizeof (VBOXWDDM_QI))
+            {
+                VBOXWDDM_QI * pQi = (VBOXWDDM_QI*)pQueryAdapterInfo->pInputData;
+                switch (pQi->enmType)
+                {
+#ifdef VBOX_WITH_VIDEOHWACCEL
+                    case VBOXWDDM_QI_TYPE_2D_1:
+                    {
+                        if (pQueryAdapterInfo->InputDataSize >= sizeof (VBOXWDDM_QI_2D_1)
+                                && pQueryAdapterInfo->OutputDataSize >= sizeof (VBOXWDDM_QI_2D_1))
+                        {
+                            VBOXWDDM_QI_2D_1 * pQueryIn = (VBOXWDDM_QI_2D_1*)pQueryAdapterInfo->pInputData;
+                            VBOXWDDM_QI_2D_1 * pQueryOut = (VBOXWDDM_QI_2D_1*)pQueryAdapterInfo->pOutputData;
+                            /* @todo: submit to the host */
+#if 0
+                            VBOXVHWACMD *pCmd = create-cmd;
+                            VBOXVHWACMD_QUERYINFO1 *pQueryCmd = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_QUERYINFO1);
+                            pQueryCmd->u.in.guestVersion = pQueryIn->Info.in.guestVersion;
+                            int rc = submit-cmd;
+                            pQueryOut->hdr.rc = rc;
+                            if (RT_SUCCESS(rc))
+                            {
+                                memcpy(&pQueryOut->Info, pQueryCmd, sizeof(VBOXVHWACMD_QUERYINFO1));
+                            }
+#else
+                            pQueryOut->hdr.rc = VERR_NOT_SUPPORTED;
+#endif
+                        }
+                        else
+                        {
+                            drprintf((__FUNCTION__ ": in or out buffer for VBOXWDDM_QI_TYPE_2D_1 too small\n"));
+                            Status = STATUS_BUFFER_TOO_SMALL;
+                        }
+                        break;
+                    }
+                    case VBOXWDDM_QI_TYPE_2D_2:
+                    {
+                        /* @todo: submit to the host */
+                        break;
+                    }
+#endif
+                    default:
+                        drprintf((__FUNCTION__ ": unsupported qi (%d)\n", pQi->enmType));
+                        AssertBreakpoint();
+                        Status = STATUS_INVALID_PARAMETER;
+                }
+            }
+            else
+            {
+                drprintf((__FUNCTION__ ": in or out buffer too small\n"));
+                Status = STATUS_BUFFER_TOO_SMALL;
+            }
             break;
         default:
@@ -1790,5 +1842,5 @@
     dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
 
-    vboxVDbgBreakF();
+    vboxVDbgBreakFv();
 
     /* Value == 2 is Present
@@ -1897,5 +1949,5 @@
 //    dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
 
-    vboxVDbgBreakF();
+    vboxVDbgBreakFv();
 
     PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
@@ -3752,5 +3804,5 @@
     PAGED_CODE();
 
-    AssertBreakpoint();
+    vboxVDbgBreakFv();
 
     drprintf(("VBoxVideoWddm::DriverEntry. Built %s %s\n", __DATE__, __TIME__));
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h	(revision 29487)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h	(revision 29488)
@@ -34,40 +34,4 @@
 PVOID vboxWddmMemAllocZero(IN SIZE_T cbSize);
 VOID vboxWddmMemFree(PVOID pvMem);
-
-typedef enum
-{
-    VBOXWDDM_ALLOC_TYPE_UNEFINED = 0,
-    VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE,
-    VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE,
-    VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE,
-    /* this one is win 7-specific and hence unused for now */
-    VBOXWDDM_ALLOC_TYPE_STD_GDISURFACE
-    /* custom allocation types requested from user-mode d3d module will go here */
-} VBOXWDDM_ALLOC_TYPE;
-
-typedef struct VBOXWDDM_SURFACE_DESC
-{
-    UINT width;
-    UINT height;
-    D3DDDIFORMAT format;
-    UINT bpp;
-    UINT pitch;
-} VBOXWDDM_SURFACE_DESC, *PVBOXWDDM_SURFACE_DESC;
-
-typedef struct VBOXWDDM_ALLOCINFO
-{
-    VBOXWDDM_ALLOC_TYPE enmType;
-    union
-    {
-        VBOXWDDM_SURFACE_DESC SurfInfo;
-    } u;
-} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
-
-#define VBOXWDDM_ALLOCINFO_HEADSIZE() (sizeof (VBOXWDDM_ALLOCINFO))
-#define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s))
-#define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
-#define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ( (_t*)(((uint8_t*)(_p)) + VBOXWDDM_ALLOCINFO_HEADSIZE()) )
-#define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - VBOXWDDM_ALLOCATION_HEADSIZE()))
-
 
 typedef struct VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE
