]> git.cworth.org Git - apitrace/blobdiff - retrace/d3dretrace.hpp
d3dretrace: Basic D3D11 snap-shooting.
[apitrace] / retrace / d3dretrace.hpp
index 5a45d36191b431fe0d5f3c2938781125ac940238..144a5c454b1dcdf80d24013e175e354433c17b6b 100644 (file)
@@ -30,6 +30,7 @@
 #include <windows.h>
 
 #include "retrace.hpp"
+#include "d3dstate.hpp"
 
 
 namespace d3dretrace {
@@ -39,6 +40,47 @@ extern const retrace::Entry d3d9_callbacks[];
 extern const retrace::Entry d3d10_callbacks[];
 
 
+template< class Device >
+class D3DDumper : public retrace::Dumper {
+public:
+    Device *pLastDevice;
+
+    D3DDumper() :
+        pLastDevice(NULL)
+    {}
+
+    image::Image *
+    getSnapshot(void) {
+        if (!pLastDevice) {
+            return NULL;
+        }
+        return d3dstate::getRenderTargetImage(pLastDevice);
+    }
+
+    bool
+    dumpState(std::ostream &os) {
+        if (!pLastDevice) {
+            return false;
+        }
+        d3dstate::dumpDevice(os, pLastDevice);
+        return true;
+    }
+
+    inline void
+    bindDevice(Device *pDevice) {
+        pLastDevice = pDevice;
+        retrace::dumper = this;
+    }
+    
+    inline void
+    unbindDevice(Device *pDevice) {
+        if (pLastDevice == pDevice) {
+            pLastDevice = NULL;
+        }
+    }
+};
+
+
 HWND
 createWindow(int width, int height);