Index: trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
===================================================================
--- trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp	(revision 91506)
+++ trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp	(revision 91507)
@@ -37,8 +37,6 @@
 #include "DevVGA-SVGA-internal.h"
 
-#ifdef DUMP_BITMAPS
-# include <iprt/formats/bmp.h>
-# include <stdio.h>
-#endif
+#include <iprt/formats/bmp.h>
+#include <stdio.h>
 
 #if defined(LOG_ENABLED) || defined(VBOX_STRICT)
@@ -1405,5 +1403,4 @@
 
 
-#ifdef DUMP_BITMAPS
 static int vmsvga3dBmpWrite(const char *pszFilename, VMSVGA3D_MAPPED_SURFACE const *pMap)
 {
@@ -1465,5 +1462,4 @@
     RTStrFree(pszFilename);
 }
-#endif /* DUMP_BITMAPS */
 
 
Index: trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp
===================================================================
--- trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp	(revision 91506)
+++ trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp	(revision 91507)
@@ -350,4 +350,18 @@
 
     rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexed(pThisCC, pDXContext, pCmd->indexCount, pCmd->startIndexLocation, pCmd->baseVertexLocation);
+#ifdef DUMP_BITMAPS
+    SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
+    SVGA3dSurfaceImageId image;
+    image.sid = pRTViewEntry->sid;
+    image.face = 0;
+    image.mipmap = 0;
+    VMSVGA3D_MAPPED_SURFACE map;
+    int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
+    if (RT_SUCCESS(rc2))
+    {
+        vmsvga3dMapWriteBmpFile(&map, "rt-");
+        vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten =  */ false);
+    }
+#endif
     return rc;
 }
@@ -368,4 +382,18 @@
     rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstanced(pThisCC, pDXContext,
              pCmd->vertexCountPerInstance, pCmd->instanceCount, pCmd->startVertexLocation, pCmd->startInstanceLocation);
+#ifdef DUMP_BITMAPS
+    SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
+    SVGA3dSurfaceImageId image;
+    image.sid = pRTViewEntry->sid;
+    image.face = 0;
+    image.mipmap = 0;
+    VMSVGA3D_MAPPED_SURFACE map;
+    int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
+    if (RT_SUCCESS(rc2))
+    {
+        vmsvga3dMapWriteBmpFile(&map, "rt-");
+        vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten =  */ false);
+    }
+#endif
     return rc;
 }
@@ -386,4 +414,18 @@
     rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstanced(pThisCC, pDXContext,
              pCmd->indexCountPerInstance, pCmd->instanceCount, pCmd->startIndexLocation, pCmd->baseVertexLocation, pCmd->startInstanceLocation);
+#ifdef DUMP_BITMAPS
+    SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
+    SVGA3dSurfaceImageId image;
+    image.sid = pRTViewEntry->sid;
+    image.face = 0;
+    image.mipmap = 0;
+    VMSVGA3D_MAPPED_SURFACE map;
+    int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
+    if (RT_SUCCESS(rc2))
+    {
+        vmsvga3dMapWriteBmpFile(&map, "rt-");
+        vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten =  */ false);
+    }
+#endif
     return rc;
 }
@@ -403,4 +445,18 @@
 
     rc = pSvgaR3State->pFuncsDX->pfnDXDrawAuto(pThisCC, pDXContext);
+#ifdef DUMP_BITMAPS
+    SVGACOTableDXRTViewEntry *pRTViewEntry = &pDXContext->cot.paRTView[pDXContext->svgaDXContext.renderState.renderTargetViewIds[0]];
+    SVGA3dSurfaceImageId image;
+    image.sid = pRTViewEntry->sid;
+    image.face = 0;
+    image.mipmap = 0;
+    VMSVGA3D_MAPPED_SURFACE map;
+    int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);
+    if (RT_SUCCESS(rc2))
+    {
+        vmsvga3dMapWriteBmpFile(&map, "rt-");
+        vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten =  */ false);
+    }
+#endif
     return rc;
 }
Index: trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
===================================================================
--- trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h	(revision 91506)
+++ trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h	(revision 91507)
@@ -62,7 +62,5 @@
 /* Write render targets to bitmaps. */
 //#define DUMP_BITMAPS
-#ifdef DUMP_BITMAPS
 void vmsvga3dMapWriteBmpFile(VMSVGA3D_MAPPED_SURFACE const *pMap, char const *pszPrefix);
-#endif
 
 /* DevVGA-SVGA.cpp: */
