]> git.cworth.org Git - apitrace/commitdiff
dxgi(re)trace: Organize mapping info into a structure.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 29 May 2013 18:59:40 +0000 (19:59 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 30 May 2013 11:07:11 +0000 (12:07 +0100)
helpers/d3d10size.hpp
helpers/d3d11size.hpp
helpers/dxgisize.hpp
retrace/dxgiretrace.py
wrappers/dxgitrace.py
wrappers/trace.py

index 6441bdcb7ae6579e40afcba1eed15f0e47aca7ee..d15e2ec223e76ea1c93973ab7f92444205a7f6ce 100644 (file)
@@ -108,10 +108,10 @@ _calcSubresourceSize(const D3D10_TEXTURE3D_DESC *pDesc, UINT Subresource, UINT R
 }
 
 static inline void
-_getMapInfo(ID3D10Buffer *pResource, D3D10_MAP MapType, UINT MapFlags, void * * ppData,
-            void * & pMappedData, size_t & MappedSize) {
-    pMappedData = 0;
-    MappedSize = 0;
+_getMapDesc(ID3D10Buffer *pResource, D3D10_MAP MapType, UINT MapFlags, void * * ppData,
+            _MAP_DESC & MapDesc) {
+    MapDesc.pData = 0;
+    MapDesc.Size = 0;
 
     if (MapType == D3D10_MAP_READ) {
         return;
@@ -120,15 +120,15 @@ _getMapInfo(ID3D10Buffer *pResource, D3D10_MAP MapType, UINT MapFlags, void * *
     D3D10_BUFFER_DESC Desc;
     pResource->GetDesc(&Desc);
 
-    pMappedData = *ppData;
-    MappedSize = Desc.ByteWidth;
+    MapDesc.pData = *ppData;
+    MapDesc.Size = Desc.ByteWidth;
 }
 
 static inline void
-_getMapInfo(ID3D10Texture1D *pResource, UINT Subresource, D3D10_MAP MapType, UINT MapFlags, void * * ppData,
-            void * & pMappedData, size_t & MappedSize) {
-    pMappedData = 0;
-    MappedSize = 0;
+_getMapDesc(ID3D10Texture1D *pResource, UINT Subresource, D3D10_MAP MapType, UINT MapFlags, void * * ppData,
+            _MAP_DESC & MapDesc) {
+    MapDesc.pData = 0;
+    MapDesc.Size = 0;
 
     if (MapType == D3D10_MAP_READ) {
         return;
@@ -137,15 +137,15 @@ _getMapInfo(ID3D10Texture1D *pResource, UINT Subresource, D3D10_MAP MapType, UIN
     D3D10_TEXTURE1D_DESC Desc;
     pResource->GetDesc(&Desc);
 
-    pMappedData = *ppData;
-    MappedSize = _calcSubresourceSize(&Desc, Subresource);
+    MapDesc.pData = *ppData;
+    MapDesc.Size = _calcSubresourceSize(&Desc, Subresource);
 }
 
 static inline void
-_getMapInfo(ID3D10Texture2D *pResource, UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE2D * pMappedTex2D,
-            void * & pMappedData, size_t & MappedSize) {
-    pMappedData = 0;
-    MappedSize = 0;
+_getMapDesc(ID3D10Texture2D *pResource, UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE2D * pMappedTex2D,
+            _MAP_DESC & MapDesc) {
+    MapDesc.pData = 0;
+    MapDesc.Size = 0;
 
     if (MapType == D3D10_MAP_READ) {
         return;
@@ -154,15 +154,15 @@ _getMapInfo(ID3D10Texture2D *pResource, UINT Subresource, D3D10_MAP MapType, UIN
     D3D10_TEXTURE2D_DESC Desc;
     pResource->GetDesc(&Desc);
 
-    pMappedData = pMappedTex2D->pData;
-    MappedSize = _calcSubresourceSize(&Desc, Subresource, pMappedTex2D->RowPitch);
+    MapDesc.pData = pMappedTex2D->pData;
+    MapDesc.Size = _calcSubresourceSize(&Desc, Subresource, pMappedTex2D->RowPitch);
 }
 
 static inline void
-_getMapInfo(ID3D10Texture3D *pResource, UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE3D * pMappedTex3D,
-            void * & pMappedData, size_t & MappedSize) {
-    pMappedData = 0;
-    MappedSize = 0;
+_getMapDesc(ID3D10Texture3D *pResource, UINT Subresource, D3D10_MAP MapType, UINT MapFlags, D3D10_MAPPED_TEXTURE3D * pMappedTex3D,
+            _MAP_DESC & MapDesc) {
+    MapDesc.pData = 0;
+    MapDesc.Size = 0;
 
     if (MapType == D3D10_MAP_READ) {
         return;
@@ -171,8 +171,8 @@ _getMapInfo(ID3D10Texture3D *pResource, UINT Subresource, D3D10_MAP MapType, UIN
     D3D10_TEXTURE3D_DESC Desc;
     pResource->GetDesc(&Desc);
 
-    pMappedData = pMappedTex3D->pData;
-    MappedSize = _calcSubresourceSize(&Desc, Subresource, pMappedTex3D->RowPitch, pMappedTex3D->DepthPitch);
+    MapDesc.pData = pMappedTex3D->pData;
+    MapDesc.Size = _calcSubresourceSize(&Desc, Subresource, pMappedTex3D->RowPitch, pMappedTex3D->DepthPitch);
 }
 
 
index ed75d64e3ad29f9932ea61309fbca889090c971d..2ac53095c8861c948d8460d2efbddb51a3cf41ce 100644 (file)
@@ -180,17 +180,17 @@ _calcSubresourceSize(ID3D11Resource *pDstResource, UINT DstSubresource, const D3
 
 
 static inline void
-_getMapInfo(ID3D11DeviceContext* pContext, ID3D11Resource * pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, D3D11_MAPPED_SUBRESOURCE * pMappedResource,
-            void * & pMappedData, size_t & MappedSize) {
-    pMappedData = 0;
-    MappedSize = 0;
+_getMapDesc(ID3D11DeviceContext* pContext, ID3D11Resource * pResource, UINT Subresource, D3D11_MAP MapType, UINT MapFlags, D3D11_MAPPED_SUBRESOURCE * pMappedResource,
+            _MAP_DESC & MapDesc) {
+    MapDesc.pData = 0;
+    MapDesc.Size = 0;
 
     if (MapType == D3D11_MAP_READ) {
         return;
     }
 
-    pMappedData = pMappedResource->pData;
-    MappedSize = _calcSubresourceSize(pResource, Subresource, NULL, pMappedResource->RowPitch, pMappedResource->DepthPitch);
+    MapDesc.pData = pMappedResource->pData;
+    MapDesc.Size = _calcSubresourceSize(pResource, Subresource, NULL, pMappedResource->RowPitch, pMappedResource->DepthPitch);
 }
 
 
index a2749ffbe642d9abd6d634f044306279daac6711..cbe526fb589716f95341a13584f74de6b8a281c8 100644 (file)
 #include "os.hpp"
 
 
+/**
+ * Information about active sub-resource maps
+ */
+struct _MAP_DESC
+{
+    VOID * pData;
+    size_t Size;
+
+    _MAP_DESC(void) :
+        pData(0),
+        Size(0)
+    {}
+};
+
+
 static size_t
 _calcDataSize(DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) {
     if (Width == 0 || Height == 0 || Depth == 0) {
@@ -229,10 +244,10 @@ _getNumMipLevels(UINT Width, UINT Height = 1, UINT Depth = 1) {
 
 
 static inline void
-_getMapInfo(IDXGISurface *pResource, DXGI_MAPPED_RECT * pLockedRect, UINT MapFlags,
-            void * & pMappedData, size_t & MappedSize) {
-    pMappedData = 0;
-    MappedSize = 0;
+_getMapDesc(IDXGISurface *pResource, DXGI_MAPPED_RECT * pLockedRect, UINT MapFlags,
+            _MAP_DESC & MapDesc) {
+    MapDesc.pData = 0;
+    MapDesc.Size = 0;
 
     if (!(MapFlags & DXGI_MAP_WRITE)) {
         return;
@@ -244,8 +259,8 @@ _getMapInfo(IDXGISurface *pResource, DXGI_MAPPED_RECT * pLockedRect, UINT MapFla
         return;
     }
 
-    pMappedData = pLockedRect->pBits;
-    MappedSize = _calcDataSize(Desc.Format, Desc.Width, Desc.Height, pLockedRect->Pitch);
+    MapDesc.pData = pLockedRect->pBits;
+    MapDesc.Size = _calcDataSize(Desc.Format, Desc.Width, Desc.Height, pLockedRect->Pitch);
 }
 
 
index 1be70fe9db7e9f3aee46d554dffc2eaa58afa42a..e37e49a5395cae4a2c3b2bbef825db9d0d5f6c66 100644 (file)
@@ -286,11 +286,11 @@ createWindow(DXGI_SWAP_CHAIN_DESC *pSwapChainDesc) {
             print r'    d3dretrace::processEvents();'
 
         if method.name == 'Map':
-            print '    VOID *_pbData = NULL;'
-            print '    size_t _MappedSize = 0;'
-            print '    _getMapInfo(_this, %s, _pbData, _MappedSize);' % ', '.join(method.argNames())
-            print '    if (_MappedSize) {'
-            print '        _maps[_this] = _pbData;'
+            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;'
             print '    } else {'
             print '        return;'
             print '    }'
index 0ecaed254217ad23c54af84a9043cba3c40cbd4e..122b773234149dcd5e8dacba22da2f0d19c8eeca 100644 (file)
@@ -80,16 +80,15 @@ class D3DCommonTracer(DllTracer):
         # Add additional members to track maps
         if interface.getMethodByName('Map') is not None:
             variables += [
-                ('VOID *', '_pMappedData', '0'),
-                ('size_t', '_MappedSize', '0'),
+                ('_MAP_DESC', '_MapDesc', None),
             ]
 
         return variables
 
     def implementWrapperInterfaceMethodBody(self, interface, base, method):
         if method.name == 'Unmap':
-            print '    if (_MappedSize && _pMappedData) {'
-            self.emit_memcpy('_pMappedData', '_pMappedData', '_MappedSize')
+            print '    if (_MapDesc.Size && _MapDesc.pData) {'
+            self.emit_memcpy('_MapDesc.pData', '_MapDesc.pData', '_MapDesc.Size')
             print '    }'
 
         DllTracer.implementWrapperInterfaceMethodBody(self, interface, base, method)
@@ -97,10 +96,10 @@ class D3DCommonTracer(DllTracer):
         if method.name == 'Map':
             # NOTE: recursive locks are explicitely forbidden
             print '    if (SUCCEEDED(_result)) {'
-            print '        _getMapInfo(_this, %s, _pMappedData, _MappedSize);' % ', '.join(method.argNames())
+            print '        _getMapDesc(_this, %s, _MapDesc);' % ', '.join(method.argNames())
             print '    } else {'
-            print '        _pMappedData = NULL;'
-            print '        _MappedSize = 0;'
+            print '        _MapDesc.pData = NULL;'
+            print '        _MapDesc.Size = 0;'
             print '    }'
 
 
index 252db492213e952eed68163af3b3094f8ce09856..4abd20eeb6920f72ca6e80548b1d7c14ebee97cf 100644 (file)
@@ -627,7 +627,8 @@ class Tracer:
         # Private constructor
         print '%s::%s(%s * pInstance) {' % (getWrapperInterfaceName(interface), getWrapperInterfaceName(interface), interface.name)
         for type, name, value in self.enumWrapperInterfaceVariables(interface):
-            print '    %s = %s;' % (name, value)
+            if value is not None:
+                print '    %s = %s;' % (name, value)
         print '}'
         print