}
+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_ */
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")]),