[PATCH] Key ID3D11DeviceContext::Map on the subresource

Jeff Muizelaar jmuizelaar at mozilla.com
Tue Nov 19 12:17:45 PST 2013


ID3D11DeviceContext::Map maps subresources and not the DeviceContext.
Therefore, we need to key our internal map tracking on the sub-resource
instead of the DeviceContext.

---

diff --git a/retrace/dxgiretrace.py b/retrace/dxgiretrace.py
index 8fa1fdb..f428dbb 100755
--- a/retrace/dxgiretrace.py
+++ b/retrace/dxgiretrace.py
@@ -302,28 +302,39 @@ createWindow(DXGI_SWAP_CHAIN_DESC *pSwapChainDesc) {
         if method.name == 'Present':
             print r'    d3dretrace::processEvents();'
 
         if method.name == 'Map':
             print '    _MAP_DESC _MapDesc;'
             print '    _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames())
             print '    size_t _MappedSize = _MapDesc.Size;'
             print '    if (_MapDesc.Size) {'
-            print '        _maps[_this] = _MapDesc.pData;'
+            if interface.name.startswith('ID3D11DeviceContext'):
+                print '        _maps[pResource] = _MapDesc.pData;'
+            else:
+                print '        _maps[_this] = _MapDesc.pData;'
             print '    } else {'
             print '        return;'
             print '    }'
         
         if method.name == 'Unmap':
-            print '    VOID *_pbData = 0;'
-            print '    _pbData = _maps[_this];'
-            print '    if (_pbData) {'
-            print '        retrace::delRegionByPointer(_pbData);'
-            print '        _maps[_this] = 0;'
-            print '    }'
+            if interface.name.startswith('ID3D11DeviceContext'):
+                print '    VOID *_pbData = 0;'
+                print '    _pbData = _maps[pResource];'
+                print '    if (_pbData) {'
+                print '        retrace::delRegionByPointer(_pbData);'
+                print '        _maps[pResource] = 0;'
+                print '    }'
+            else:
+                print '    VOID *_pbData = 0;'
+                print '    _pbData = _maps[_this];'
+                print '    if (_pbData) {'
+                print '        retrace::delRegionByPointer(_pbData);'
+                print '        _maps[_this] = 0;'
+                print '    }'
 
         # Attach shader byte code for lookup
         if 'pShaderBytecode' in method.argNames():
             ppShader = method.args[-1]
             assert ppShader.output
             print r'    if (retrace::dumpingState && SUCCEEDED(_result)) {'
             print r'        (*%s)->SetPrivateData(d3dstate::GUID_D3DSTATE, BytecodeLength, pShaderBytecode);' % ppShader.name
             print r'    }'



More information about the apitrace mailing list