summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-07-16 12:31:10 +0100
committerJose Fonseca <jfonseca@vmware.com>2015-07-16 12:31:54 +0100
commite39d56edca49495aa401ffd22a35da4a10a1fd38 (patch)
treedf115fcf67d0b550efeb52500866c462d3db650c
parent7d810e5c522d146a3ee6d13b9422110119a3689f (diff)
d3dretrace: Fetch snapshots from swapchain.
Instead of current rendertarget.
-rw-r--r--retrace/d3d9retrace.py3
-rw-r--r--retrace/d3d9state.cpp10
-rw-r--r--retrace/d3d9state_images.cpp22
-rw-r--r--retrace/d3dstate.hpp9
4 files changed, 43 insertions, 1 deletions
diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py
index 0850e057..3f2754af 100644
--- a/retrace/d3d9retrace.py
+++ b/retrace/d3d9retrace.py
@@ -164,6 +164,8 @@ class D3DRetracer(Retracer):
# notify frame has been completed
if method.name in ('Present', 'PresentEx'):
+ if interface.name.startswith('IDirect3DSwapChain9'):
+ print r' d3d9scDumper.bindDevice(_this);'
print r' retrace::frameComplete(call);'
print r' hDestWindowOverride = NULL;'
@@ -254,6 +256,7 @@ def main():
api.addModule(d3d9)
print
print '''static d3dretrace::D3DDumper<IDirect3DDevice9> d3d9Dumper;'''
+ print '''static d3dretrace::D3DDumper<IDirect3DSwapChain9> d3d9scDumper;'''
print
elif moduleName == 'd3d8':
from specs.d3d8 import d3d8
diff --git a/retrace/d3d9state.cpp b/retrace/d3d9state.cpp
index 29851f9b..0717c102 100644
--- a/retrace/d3d9state.cpp
+++ b/retrace/d3d9state.cpp
@@ -110,5 +110,15 @@ dumpDevice(StateWriter &writer, IDirect3DDevice9 *pDevice)
dumpFramebuffer(writer, pDevice);
}
+void
+dumpDevice(StateWriter &writer, IDirect3DSwapChain9 *pSwapChain)
+{
+ com_ptr<IDirect3DDevice9> pDevice;
+ HRESULT hr = pSwapChain->GetDevice(&pDevice);
+ if (SUCCEEDED(hr)) {
+ dumpDevice(writer, pDevice);
+ }
+}
+
} /* namespace d3dstate */
diff --git a/retrace/d3d9state_images.cpp b/retrace/d3d9state_images.cpp
index ef919592..79ad0744 100644
--- a/retrace/d3d9state_images.cpp
+++ b/retrace/d3d9state_images.cpp
@@ -110,6 +110,28 @@ getRenderTargetImage(IDirect3DDevice9 *pDevice) {
}
+image::Image *
+getRenderTargetImage(IDirect3DSwapChain9 *pSwapChain) {
+ HRESULT hr;
+
+ com_ptr<IDirect3DDevice9> pDevice;
+ hr = pSwapChain->GetDevice(&pDevice);
+ if (FAILED(hr)) {
+ return NULL;
+ }
+
+ // TODO: Use GetFrontBufferData instead??
+ com_ptr<IDirect3DSurface9> pBackBuffer;
+ hr = pSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer);
+ if (FAILED(hr)) {
+ return NULL;
+ }
+ assert(pBackBuffer);
+
+ return getRenderTargetImage(pDevice, pBackBuffer);
+}
+
+
static image::Image *
getTextureImage(IDirect3DDevice9 *pDevice,
IDirect3DBaseTexture9 *pTexture,
diff --git a/retrace/d3dstate.hpp b/retrace/d3dstate.hpp
index f7276b15..c06b2fdd 100644
--- a/retrace/d3dstate.hpp
+++ b/retrace/d3dstate.hpp
@@ -38,6 +38,7 @@
struct IDirect3DDevice7;
struct IDirect3DDevice8;
struct IDirect3DDevice9;
+struct IDirect3DSwapChain9;
struct IDXGISwapChain;
struct ID3D10Device;
struct ID3D10Resource;
@@ -91,7 +92,7 @@ dumpDevice(StateWriter &writer, IDirect3DDevice8 *pDevice);
*/
image::Image *
-getRenderTargetImage(IDirect3DDevice9 *pDevice);
+getRenderTargetImage(IDirect3DSwapChain9 *pSwapChain);
void
dumpTextures(StateWriter &writer, IDirect3DDevice9 *pDevice);
@@ -102,6 +103,12 @@ dumpFramebuffer(StateWriter &writer, IDirect3DDevice9 *pDevice);
void
dumpDevice(StateWriter &writer, IDirect3DDevice9 *pDevice);
+image::Image *
+getRenderTargetImage(IDirect3DDevice9 *pDevice);
+
+void
+dumpDevice(StateWriter &writer, IDirect3DSwapChain9 *pSwapChain);
+
#ifdef HAVE_DXGI