Index: trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
===================================================================
--- trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp	(revision 93355)
+++ trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp	(revision 93357)
@@ -44,4 +44,15 @@
 #include <d3d11.h>
 
+
+#ifdef RT_OS_WINDOWS
+# define VBOX_D3D11_LIBRARY_NAME "d3d11"
+#else
+# define VBOX_D3D11_LIBRARY_NAME "VBoxDxVk"
+#endif
+
+/* This is not available on non Windows hosts. */
+#ifndef D3D_RELEASE
+# define D3D_RELEASE(a_Ptr) do { if ((a_Ptr)) (a_Ptr)->Release(); (a_Ptr) = NULL; } while (0)
+#endif
 
 /** Fake ID for the backend DX context. The context creates all shared textures. */
@@ -217,4 +228,17 @@
 static int dxDeviceFlush(DXDEVICE *pDevice);
 static DECLCALLBACK(void) vmsvga3dBackSurfaceDestroy(PVGASTATECC pThisCC, PVMSVGA3DSURFACE pSurface);
+
+
+/* This is not available with the DXVK headers for some reason. */
+#ifndef RT_OS_WINDOWS
+typedef enum D3D11_TEXTURECUBE_FACE {
+  D3D11_TEXTURECUBE_FACE_POSITIVE_X,
+  D3D11_TEXTURECUBE_FACE_NEGATIVE_X,
+  D3D11_TEXTURECUBE_FACE_POSITIVE_Y,
+  D3D11_TEXTURECUBE_FACE_NEGATIVE_Y,
+  D3D11_TEXTURECUBE_FACE_POSITIVE_Z,
+  D3D11_TEXTURECUBE_FACE_NEGATIVE_Z
+} D3D11_TEXTURECUBE_FACE;
+#endif
 
 
@@ -1000,5 +1024,5 @@
     AssertReturn(pState, VERR_INVALID_STATE);
 
-    for (int i = 0; i < RT_ELEMENTS(pDXContext->svgaDXContext.renderState.renderTargetViewIds); ++i)
+    for (unsigned long i = 0; i < RT_ELEMENTS(pDXContext->svgaDXContext.renderState.renderTargetViewIds); ++i)
     {
         uint32_t const renderTargetViewId = pDXContext->svgaDXContext.renderState.renderTargetViewIds[i];
@@ -2316,4 +2340,5 @@
 }
 
+#if 0 /*unused*/
 /** @todo Not needed */
 static int vmsvga3dBackSurfaceCreateConstantBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface)
@@ -2481,4 +2506,5 @@
     return VERR_NO_MEMORY;
 }
+#endif
 
 
@@ -2524,4 +2550,14 @@
     RT_NOREF(pDevIns, pThis);
 
+    int rc;
+#ifdef RT_OS_LINUX /** @todo Remove, this is currently needed for loading the X11 library in order to call XInitThreads(). */
+    rc = glLdrInit(pDevIns);
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("VMSVGA3d: Error loading OpenGL library and resolving necessary functions: %Rrc\n", rc));
+        return rc;
+    }
+#endif
+
     PVMSVGA3DSTATE pState = (PVMSVGA3DSTATE)RTMemAllocZ(sizeof(VMSVGA3DSTATE));
     AssertReturn(pState, VERR_NO_MEMORY);
@@ -2532,5 +2568,5 @@
     pState->pBackend = pBackend;
 
-    int rc = RTLdrLoadSystem("d3d11", /* fNoUnload = */ true, &pBackend->hD3D11);
+    rc = RTLdrLoadSystem(VBOX_D3D11_LIBRARY_NAME, /* fNoUnload = */ true, &pBackend->hD3D11);
     AssertRC(rc);
     if (RT_SUCCESS(rc))
@@ -2602,18 +2638,19 @@
 
 
+/** @todo Such structures must be in VBoxVideo3D.h */
+typedef struct VBOX3DNOTIFYDEFINESCREEN
+{
+    VBOX3DNOTIFY Core;
+    uint32_t cWidth;
+    uint32_t cHeight;
+    int32_t  xRoot;
+    int32_t  yRoot;
+    uint32_t fPrimary;
+    uint32_t cDpi;
+} VBOX3DNOTIFYDEFINESCREEN;
+
+
 static int vmsvga3dDrvNotifyDefineScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen)
 {
-    /** @todo Such structures must be in VBoxVideo3D.h */
-    typedef struct VBOX3DNOTIFYDEFINESCREEN
-    {
-        VBOX3DNOTIFY Core;
-        uint32_t cWidth;
-        uint32_t cHeight;
-        int32_t  xRoot;
-        int32_t  yRoot;
-        uint32_t fPrimary;
-        uint32_t cDpi;
-    } VBOX3DNOTIFYDEFINESCREEN;
-
     VBOX3DNOTIFYDEFINESCREEN n;
     n.Core.enmNotification = VBOX3D_NOTIFY_TYPE_HW_SCREEN_CREATED;
@@ -2659,16 +2696,17 @@
 
 
+typedef struct VBOX3DNOTIFYUPDATE
+{
+    VBOX3DNOTIFY Core;
+    uint32_t x;
+    uint32_t y;
+    uint32_t w;
+    uint32_t h;
+} VBOX3DNOTIFYUPDATE;
+
+
 static int vmsvga3dDrvNotifyUpdate(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen,
                                    uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 {
-    typedef struct VBOX3DNOTIFYUPDATE
-    {
-        VBOX3DNOTIFY Core;
-        uint32_t x;
-        uint32_t y;
-        uint32_t w;
-        uint32_t h;
-    } VBOX3DNOTIFYUPDATE;
-
     VBOX3DNOTIFYUPDATE n;
     n.Core.enmNotification = VBOX3D_NOTIFY_TYPE_HW_SCREEN_UPDATE_END;
@@ -3310,5 +3348,5 @@
     /* Copy the screen texture to the shared surface. */
     DWORD result = pHwScreen->pDXGIKeyedMutex->AcquireSync(0, 10000);
-    if (result == WAIT_OBJECT_0)
+    if (result == S_OK)
     {
         pBackend->device.pImmediateContext->CopyResource(pHwScreen->pTexture, pBackendSurface->u.pTexture2D);
@@ -4020,4 +4058,5 @@
 
 
+#if 0 /*unused*/
 /**
  * Create a new 3d context
@@ -4285,4 +4324,5 @@
     return VINF_SUCCESS;
 }
+#endif
 
 
@@ -4583,4 +4623,5 @@
 
 
+#if 0 /*unused*/
 static DECLCALLBACK(int) vmsvga3dBackOcclusionQueryCreate(PVGASTATECC pThisCC, PVMSVGA3DCONTEXT pContext)
 {
@@ -4622,4 +4663,5 @@
     return VINF_SUCCESS;
 }
+#endif
 
 
@@ -5572,5 +5614,8 @@
 
     pDXContext->svgaDXContext.renderState.blendStateId = blendId;
-    memcpy(pDXContext->svgaDXContext.renderState.blendFactor, blendFactor, sizeof(blendFactor));
+    pDXContext->svgaDXContext.renderState.blendFactor[0] = blendFactor[0];
+    pDXContext->svgaDXContext.renderState.blendFactor[1] = blendFactor[1];
+    pDXContext->svgaDXContext.renderState.blendFactor[2] = blendFactor[2];
+    pDXContext->svgaDXContext.renderState.blendFactor[3] = blendFactor[3];
     pDXContext->svgaDXContext.renderState.sampleMask = sampleMask;
 
