]> git.cworth.org Git - apitrace/commitdiff
d3d10: Trace UpdateSubResource blobs.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 4 Nov 2012 23:37:14 +0000 (23:37 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 4 Nov 2012 23:37:14 +0000 (23:37 +0000)
helpers/d3d10size.hpp
specs/d3d10.py

index 81285e4aecadda6d0f3bac5df6ebfcd654343026..dbcab6a899b05e05c0c2f0ecefe9d798d9120a4b 100644 (file)
@@ -378,4 +378,70 @@ _getMapInfo(IDXGISurface *pResource, DXGI_MAPPED_RECT * pLockedRect, UINT MapFla
 }
 
 
+static inline size_t
+_calcSubresourceSize(ID3D10Resource *pDstResource, UINT DstSubresource, const D3D10_BOX *pDstBox, UINT SrcRowPitch, UINT SrcDepthPitch) {
+    if (pDstBox &&
+        (pDstBox->left  >= pDstBox->right ||
+         pDstBox->top   >= pDstBox->bottom ||
+         pDstBox->front >= pDstBox->back)) {
+        return 0;
+    }
+
+    D3D10_RESOURCE_DIMENSION Type = D3D10_RESOURCE_DIMENSION_UNKNOWN;
+    pDstResource->GetType(&Type);
+
+    DXGI_FORMAT Format;
+    UINT Width;
+    UINT Height = 1;
+    UINT Depth = 1;
+    UINT MipLevel = 0;
+
+    switch (Type) {
+    case D3D10_RESOURCE_DIMENSION_BUFFER:
+        if (pDstBox) {
+            return pDstBox->right - pDstBox->left;
+        } else {
+            D3D10_BUFFER_DESC Desc;
+            static_cast<ID3D10Buffer *>(pDstResource)->GetDesc(&Desc);
+            return Desc.ByteWidth;
+        }
+    case D3D10_RESOURCE_DIMENSION_TEXTURE1D:
+        {
+            D3D10_TEXTURE1D_DESC Desc;
+            static_cast<ID3D10Texture1D *>(pDstResource)->GetDesc(&Desc);
+            Format = Desc.Format;
+            Width = Desc.Width;
+            MipLevel = DstSubresource % Desc.MipLevels;
+        }
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
+        {
+            D3D10_TEXTURE2D_DESC Desc;
+            static_cast<ID3D10Texture2D *>(pDstResource)->GetDesc(&Desc);
+            Format = Desc.Format;
+            Width = Desc.Width;
+            Height = Desc.Height;
+            MipLevel = DstSubresource % Desc.MipLevels;
+        }
+        break;
+    case D3D10_RESOURCE_DIMENSION_TEXTURE3D:
+        {
+            D3D10_TEXTURE3D_DESC Desc;
+            static_cast<ID3D10Texture3D *>(pDstResource)->GetDesc(&Desc);
+            Format = Desc.Format;
+            Width = Desc.Width;
+            Height = Desc.Height;
+            Depth = Desc.Depth;
+        }
+        break;
+    case D3D10_RESOURCE_DIMENSION_UNKNOWN:
+    default:
+        assert(0);
+        return 0;
+    }
+
+    return _calcMipDataSize(MipLevel, Format, Width, Height, SrcRowPitch, Depth, SrcDepthPitch);
+}
+
+
 #endif /* _D3D10SIZE_HPP_ */
index 0002f65dece013ad28547f056151f366339107d2..7b0f1824158405aa7b7bc535764baebd9d3681a7 100644 (file)
@@ -824,7 +824,7 @@ ID3D10Device.methods += [
     Method(Void, "RSSetScissorRects", [(UINT, "NumRects"), (Array(Const(D3D10_RECT), "NumRects"), "pRects")]),
     Method(Void, "CopySubresourceRegion", [(ObjPointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (UINT, "DstX"), (UINT, "DstY"), (UINT, "DstZ"), (ObjPointer(ID3D10Resource), "pSrcResource"), (UINT, "SrcSubresource"), (Pointer(Const(D3D10_BOX)), "pSrcBox")]),
     Method(Void, "CopyResource", [(ObjPointer(ID3D10Resource), "pDstResource"), (ObjPointer(ID3D10Resource), "pSrcResource")]),
-    Method(Void, "UpdateSubresource", [(ObjPointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D10_BOX)), "pDstBox"), (OpaquePointer(Const(Void)), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch")]),
+    Method(Void, "UpdateSubresource", [(ObjPointer(ID3D10Resource), "pDstResource"), (UINT, "DstSubresource"), (Pointer(Const(D3D10_BOX)), "pDstBox"), (Blob(Const(Void), "_calcSubresourceSize(pDstResource, DstSubresource, pDstBox, SrcRowPitch, SrcDepthPitch)"), "pSrcData"), (UINT, "SrcRowPitch"), (UINT, "SrcDepthPitch")]),
     Method(Void, "ClearRenderTargetView", [(ObjPointer(ID3D10RenderTargetView), "pRenderTargetView"), (Array(Const(FLOAT), 4), "ColorRGBA")]),
     Method(Void, "ClearDepthStencilView", [(ObjPointer(ID3D10DepthStencilView), "pDepthStencilView"), (D3D10_CLEAR_FLAG, "ClearFlags"), (FLOAT, "Depth"), (UINT8, "Stencil")]),
     Method(Void, "GenerateMips", [(ObjPointer(ID3D10ShaderResourceView), "pShaderResourceView")]),