From 2d476f27841a879da98684618b7319bccc70ba8f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 4 Nov 2012 23:37:14 +0000 Subject: [PATCH] d3d10: Trace UpdateSubResource blobs. --- helpers/d3d10size.hpp | 66 +++++++++++++++++++++++++++++++++++++++++++ specs/d3d10.py | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/helpers/d3d10size.hpp b/helpers/d3d10size.hpp index 81285e4..dbcab6a 100644 --- a/helpers/d3d10size.hpp +++ b/helpers/d3d10size.hpp @@ -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(pDstResource)->GetDesc(&Desc); + return Desc.ByteWidth; + } + case D3D10_RESOURCE_DIMENSION_TEXTURE1D: + { + D3D10_TEXTURE1D_DESC Desc; + static_cast(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(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(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_ */ diff --git a/specs/d3d10.py b/specs/d3d10.py index 0002f65..7b0f182 100644 --- a/specs/d3d10.py +++ b/specs/d3d10.py @@ -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")]), -- 2.43.0