Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.cpp	(revision 102145)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.cpp	(revision 102253)
@@ -2783,7 +2783,33 @@
 
 void vboxDXSetShaderResourceViews(PVBOXDX_DEVICE pDevice, SVGA3dShaderType enmShaderType, uint32_t StartSlot,
-                                  uint32_t NumViews, uint32_t *paViewIds)
-{
-    vgpu10SetShaderResources(pDevice, enmShaderType, StartSlot, NumViews, paViewIds);
+                                  uint32_t NumViews, PVBOXDXSHADERRESOURCEVIEW const *papViews)
+{
+    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
+    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
+
+    /* Update the pipeline state. */
+    PVBOXDXSRVSTATE pSRVS = &pDevice->pipeline.aSRVs[enmShaderType - SVGA3D_SHADERTYPE_MIN];
+
+    for (unsigned i = 0; i < NumViews; ++i)
+        pSRVS->apShaderResourceView[StartSlot + i] = papViews[i];
+
+    uint32_t cSRV = RT_MAX(pSRVS->cShaderResourceView, StartSlot + NumViews);
+    while (cSRV)
+    {
+        if (pSRVS->apShaderResourceView[cSRV - 1])
+            break;
+        --cSRV;
+    }
+    pSRVS->cShaderResourceView = cSRV;
+
+    /* Fetch View ids. */
+    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
+    for (unsigned i = 0; i < NumViews; ++i)
+    {
+        VBOXDXSHADERRESOURCEVIEW *pView = papViews[i];
+        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
+    }
+
+    vgpu10SetShaderResources(pDevice, enmShaderType, StartSlot, NumViews, aViewIds);
 }
 
@@ -2911,5 +2937,34 @@
     }
 
-    /** @todo UAV */
+    VBOXDXUNORDEREDACCESSVIEW *pUnorderedAccessView;
+    RTListForEach(&pResource->listUAV, pUnorderedAccessView, VBOXDXUNORDEREDACCESSVIEW, nodeView)
+    {
+        if (pUnorderedAccessView->fDefined)
+        {
+            vgpu10DestroyUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId);
+            pUnorderedAccessView->fDefined = false;
+        }
+    }
+
+    VBOXDXVIDEODECODEROUTPUTVIEW *pVDOV;
+    RTListForEach(&pResource->listVDOV, pVDOV, VBOXDXVIDEODECODEROUTPUTVIEW, nodeView)
+    {
+        if (pVDOV->fDefined)
+        {
+            vgpu10DestroyVideoDecoderOutputView(pDevice, pVDOV->uVideoDecoderOutputViewId);
+            pVDOV->fDefined = false;
+        }
+    }
+
+    VBOXDXVIDEOPROCESSORINPUTVIEW *pVPIV;
+    RTListForEach(&pResource->listVPIV, pVPIV, VBOXDXVIDEOPROCESSORINPUTVIEW, nodeView)
+    {
+        if (pVPIV->fDefined)
+        {
+            vgpu10DestroyVideoProcessorInputView(pDevice, pVPIV->uVideoProcessorInputViewId);
+            pVPIV->fDefined = false;
+        }
+    }
+
 
     VBOXDXVIDEOPROCESSOROUTPUTVIEW *pVPOV;
@@ -2964,5 +3019,39 @@
     }
 
-    /** @todo UAV */
+    VBOXDXUNORDEREDACCESSVIEW *pUnorderedAccessView;
+    RTListForEach(&pResource->listUAV, pUnorderedAccessView, VBOXDXUNORDEREDACCESSVIEW, nodeView)
+    {
+        if (!pUnorderedAccessView->fDefined)
+        {
+            vgpu10DefineUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId, vboxDXGetAllocation(pUnorderedAccessView->pResource),
+                               pUnorderedAccessView->svga.format, pUnorderedAccessView->svga.resourceDimension,
+                               pUnorderedAccessView->svga.desc);
+            pUnorderedAccessView->fDefined = true;
+        }
+    }
+
+    VBOXDXVIDEODECODEROUTPUTVIEW *pVDOV;
+    RTListForEach(&pResource->listVDOV, pVDOV, VBOXDXVIDEODECODEROUTPUTVIEW, nodeView)
+    {
+        if (!pVDOV->fDefined)
+        {
+            vgpu10DefineVideoDecoderOutputView(pDevice, pVDOV->uVideoDecoderOutputViewId,
+                                               vboxDXGetAllocation(pVDOV->pResource),
+                                               pVDOV->svga.desc);
+            pVDOV->fDefined = true;
+        }
+    }
+
+    VBOXDXVIDEOPROCESSORINPUTVIEW *pVPIV;
+    RTListForEach(&pResource->listVPIV, pVPIV, VBOXDXVIDEOPROCESSORINPUTVIEW, nodeView)
+    {
+        if (!pVPIV->fDefined)
+        {
+            vgpu10DefineVideoProcessorInputView(pDevice, pVPIV->uVideoProcessorInputViewId,
+                                                vboxDXGetAllocation(pVPIV->pResource),
+                                                pVPIV->svga.ContentDesc, pVPIV->svga.VPIVDesc);
+            pVPIV->fDefined = true;
+        }
+    }
 
     VBOXDXVIDEOPROCESSOROUTPUTVIEW *pVPOV;
@@ -2980,7 +3069,78 @@
 
 
+static void vboxdxUnbindResourceViews(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pResource)
+{
+    VBOXDXSHADERRESOURCEVIEW *pShaderResourceView;
+    RTListForEach(&pResource->listSRV, pShaderResourceView, VBOXDXSHADERRESOURCEVIEW, nodeView)
+    {
+        /* Search this view in the pipeline state. */
+        for (unsigned idxShaderType = 0; idxShaderType < RT_ELEMENTS(pDevice->pipeline.aSRVs); ++idxShaderType)
+        {
+            SVGA3dShaderType const enmShaderType = (SVGA3dShaderType)(idxShaderType + SVGA3D_SHADERTYPE_MIN);
+
+            PVBOXDXSRVSTATE pSRVS = &pDevice->pipeline.aSRVs[idxShaderType];
+            for (unsigned i = 0; i < pSRVS->cShaderResourceView; ++i)
+            {
+                if (pSRVS->apShaderResourceView[i] == pShaderResourceView)
+                {
+                    uint32_t id = SVGA3D_INVALID_ID;
+                    vgpu10SetShaderResources(pDevice, enmShaderType, i, 1, &id);
+                }
+            }
+        }
+    }
+}
+
+
 HRESULT vboxDXRotateResourceIdentities(PVBOXDX_DEVICE pDevice, UINT cResources, PVBOXDX_RESOURCE *papResources)
 {
-    /** @todo Rebind SRVs, UAVs which are currently bound to pipeline stages. */
+#ifdef LOG_ENABLED
+    for (unsigned i = 0; i < cResources; ++i)
+    {
+        PVBOXDX_RESOURCE pResource = papResources[i];
+        LogFlowFunc(("Resources[%d]: pResource %p, hAllocation 0x%08x\n", i, pResource, vboxDXGetAllocation(pResource)));
+
+        unsigned iV = 0;
+        VBOXDXRENDERTARGETVIEW *pRTV;
+        RTListForEach(&pResource->listRTV, pRTV, VBOXDXRENDERTARGETVIEW, nodeView)
+        {
+            LogFlowFunc(("  RTV[%d]: %p\n", iV, pRTV));
+            ++iV;
+        }
+
+        iV = 0;
+        VBOXDXSHADERRESOURCEVIEW *pSRV;
+        RTListForEach(&pResource->listSRV, pSRV, VBOXDXSHADERRESOURCEVIEW, nodeView)
+        {
+            LogFlowFunc(("  SRV[%d]: %p\n", iV, pSRV));
+            ++iV;
+        }
+    }
+
+    LogFlowFunc(("Pipeline: cRTV %u, cSRV VS %u, PS %u, GS %u, HS %u, DS %u, CS %u\n",
+                 pDevice->pipeline.cRenderTargetViews,
+                 pDevice->pipeline.aSRVs[0].cShaderResourceView,
+                 pDevice->pipeline.aSRVs[1].cShaderResourceView,
+                 pDevice->pipeline.aSRVs[2].cShaderResourceView,
+                 pDevice->pipeline.aSRVs[3].cShaderResourceView,
+                 pDevice->pipeline.aSRVs[4].cShaderResourceView,
+                 pDevice->pipeline.aSRVs[5].cShaderResourceView));
+    for (unsigned i = 0; i < pDevice->pipeline.cRenderTargetViews; ++i)
+        LogFlowFunc(("  RTV[%d]: %p\n", i, pDevice->pipeline.apRenderTargetViews[i]));
+    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[0].cShaderResourceView; ++i)
+        LogFlowFunc(("  SRV VS[%d]: %p\n", i, pDevice->pipeline.aSRVs[0].apShaderResourceView[i]));
+    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[1].cShaderResourceView; ++i)
+        LogFlowFunc(("  SRV PS[%d]: %p\n", i, pDevice->pipeline.aSRVs[1].apShaderResourceView[i]));
+    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[2].cShaderResourceView; ++i)
+        LogFlowFunc(("  SRV GS[%d]: %p\n", i, pDevice->pipeline.aSRVs[2].apShaderResourceView[i]));
+    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[3].cShaderResourceView; ++i)
+        LogFlowFunc(("  SRV HS[%d]: %p\n", i, pDevice->pipeline.aSRVs[3].apShaderResourceView[i]));
+    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[4].cShaderResourceView; ++i)
+        LogFlowFunc(("  SRV DS[%d]: %p\n", i, pDevice->pipeline.aSRVs[4].apShaderResourceView[i]));
+    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[5].cShaderResourceView; ++i)
+        LogFlowFunc(("  SRV CS[%d]: %p\n", i, pDevice->pipeline.aSRVs[5].apShaderResourceView[i]));
+#endif
+
+    /** @todo Rebind UAVs which are currently bound to pipeline. */
 
     /* Unbind current render targets, if a resource is bound as a render target. */
@@ -3029,4 +3189,5 @@
     {
         PVBOXDX_RESOURCE pResource = papResources[i];
+        vboxdxUnbindResourceViews(pDevice, pResource);
         vboxDXUndefineResourceViews(pDevice, pResource);
     }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.h	(revision 102145)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.h	(revision 102253)
@@ -506,4 +506,12 @@
 } VBOXDXINDEXBUFFERSTATE, *PVBOXDXINDEXBUFFERSTATE;
 
+
+typedef struct VBOXDXSRVSTATE
+{
+    uint32_t cShaderResourceView;
+    PVBOXDXSHADERRESOURCEVIEW apShaderResourceView[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
+} VBOXDXSRVSTATE, *PVBOXDXSRVSTATE;
+
+
 typedef struct VBOXDX_DEVICE
 {
@@ -587,4 +595,5 @@
         VBOXDXVERTEXBUFFERSSTATE   VertexBuffers;
         VBOXDXINDEXBUFFERSTATE     IndexBuffer;
+        VBOXDXSRVSTATE             aSRVs[SVGA3D_SHADERTYPE_MAX - SVGA3D_SHADERTYPE_MIN]; /* For each shader type. */
     } pipeline;
 
@@ -698,5 +707,5 @@
                             uint32_t NumRTVs, UINT ClearSlots, PVBOXDXRENDERTARGETVIEW *papRenderTargetViews);
 void vboxDXSetShaderResourceViews(PVBOXDX_DEVICE pDevice, SVGA3dShaderType enmShaderType, uint32_t StartSlot,
-                                  uint32_t NumViews, uint32_t *paViewIds);
+                                  uint32_t NumViews, PVBOXDXSHADERRESOURCEVIEW const *papViews);
 void vboxDXSetConstantBuffers(PVBOXDX_DEVICE pDevice, SVGA3dShaderType enmShaderType, UINT StartSlot, UINT NumBuffers,
                               PVBOXDX_RESOURCE *papBuffers, const UINT *pFirstConstant, const UINT *pNumConstants);
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXDDI.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXDDI.cpp	(revision 102145)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXDDI.cpp	(revision 102253)
@@ -209,16 +209,5 @@
     LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
 
-    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-
-    /* Fetch View ids. */
-    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
-    for (unsigned i = 0; i < NumViews; ++i)
-    {
-        VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
-        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
-    }
-
-    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_PS, StartSlot, NumViews, aViewIds);
+    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_PS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
 }
 
@@ -618,16 +607,5 @@
     LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
 
-    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-
-    /* Fetch View ids. */
-    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
-    for (unsigned i = 0; i < NumViews; ++i)
-    {
-        VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
-        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
-    }
-
-    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_VS, StartSlot, NumViews, aViewIds);
+    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_VS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
 }
 
@@ -668,16 +646,5 @@
     LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
 
-    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-
-    /* Fetch View ids. */
-    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
-    for (unsigned i = 0; i < NumViews; ++i)
-    {
-        VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
-        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
-    }
-
-    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_GS, StartSlot, NumViews, aViewIds);
+    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_GS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
 }
 
@@ -2957,16 +2924,5 @@
     LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
 
-    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-
-    /* Fetch View ids. */
-    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
-    for (unsigned i = 0; i < NumViews; ++i)
-    {
-        VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
-        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
-    }
-
-    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_HS, StartSlot, NumViews, aViewIds);
+    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_HS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
 }
 
@@ -3050,16 +3006,5 @@
     LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
 
-    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-
-    /* Fetch View ids. */
-    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
-    for (unsigned i = 0; i < NumViews; ++i)
-    {
-        VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
-        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
-    }
-
-    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_DS, StartSlot, NumViews, aViewIds);
+    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_DS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
 }
 
@@ -3449,16 +3394,5 @@
     LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
 
-    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
-
-    /* Fetch View ids. */
-    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
-    for (unsigned i = 0; i < NumViews; ++i)
-    {
-        VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
-        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
-    }
-
-    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_CS, StartSlot, NumViews, aViewIds);
+    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_CS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
 }
 
@@ -3921,12 +3855,4 @@
     if (pRotateResourceIdentities->Resources <= 1)
         return S_OK;
-
-#ifdef LOG_ENABLED
-    for (unsigned i = 0; i < pRotateResourceIdentities->Resources; ++i)
-    {
-        PVBOXDX_RESOURCE pResource = (PVBOXDX_RESOURCE)pRotateResourceIdentities->pResources[i];
-        LogFlowFunc(("Resources[%d]: pResource %p, hAllocation 0x%08x", i, pResource, vboxDXGetAllocation(pResource)));
-    }
-#endif
 
     return vboxDXRotateResourceIdentities(pDevice, pRotateResourceIdentities->Resources, (PVBOXDX_RESOURCE *)pRotateResourceIdentities->pResources);
