X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fd3d9retrace.py;h=9884d92d4f8fe602f31e662e802a6e8f2fc21da5;hb=3db54523afd7c8daa0812c12119717be1e667021;hp=4b5853bdd3e2be3e0b987cbe2c9a9daf4b429a61;hpb=e6bde441dbb59572b0c7b27cf2d799c51317668b;p=apitrace diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py index 4b5853b..9884d92 100644 --- a/retrace/d3d9retrace.py +++ b/retrace/d3d9retrace.py @@ -36,27 +36,47 @@ class D3DRetracer(Retracer): def retraceApi(self, api): print ''' -static IDirect3DDevice9 * -pLastDirect3DDevice9 = NULL; -image::Image * -retrace::getSnapshot(void) { - if (!pLastDirect3DDevice9) { - return NULL; +class D3D9Dumper : public retrace::Dumper { +public: + IDirect3DDevice9 *pLastDirect3DDevice9; + + D3D9Dumper() : + pLastDirect3DDevice9(NULL) + {} + + image::Image * + getSnapshot(void) { + if (!pLastDirect3DDevice9) { + return NULL; + } + return d3dstate::getRenderTargetImage(pLastDirect3DDevice9); } - return d3dstate::getRenderTargetImage(pLastDirect3DDevice9); -} + bool + dumpState(std::ostream &os) { + if (!pLastDirect3DDevice9) { + return false; + } + d3dstate::dumpDevice(os, pLastDirect3DDevice9); + return true; + } -bool -retrace::dumpState(std::ostream &os) -{ - if (!pLastDirect3DDevice9) { - return false; + inline void + bindDevice(IDirect3DDevice9 *pDevice) { + pLastDirect3DDevice9 = pDevice; + retrace::dumper = this; } - d3dstate::dumpDevice(os, pLastDirect3DDevice9); - return true; -} + + inline void + unbindDevice(IDirect3DDevice9 *pDevice) { + if (pLastDirect3DDevice9 == pDevice) { + pLastDirect3DDevice9 = NULL; + } + } +}; + +static D3D9Dumper d3d9Dumper; ''' print '// Swizzling mapping for lock addresses' @@ -84,7 +104,10 @@ retrace::dumpState(std::ostream &os) def invokeInterfaceMethod(self, interface, method): # keep track of the last used device for state dumping if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'): - print r' pLastDirect3DDevice9 = _this;' + if method.name == 'Release': + print r' d3d9Dumper.unbindDevice(_this);' + else: + print r' d3d9Dumper.bindDevice(_this);' # create windows as neccessary if method.name in ('CreateDevice', 'CreateDeviceEx', 'CreateAdditionalSwapChain'):