From 7a7ec99b9c0b8928ec74df94a1fef8ac3955cd8d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 4 Sep 2014 18:33:06 +0100 Subject: dxgitrace: Fix UpdateSubresource's blob size calculation for non-null pDstBox. The box dimensions where being incorrectly minified. --- helpers/d3d10size.hpp | 18 +++++++++++++----- helpers/d3d11size.hpp | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'helpers') diff --git a/helpers/d3d10size.hpp b/helpers/d3d10size.hpp index 96727a3e..c9785615 100644 --- a/helpers/d3d10size.hpp +++ b/helpers/d3d10size.hpp @@ -193,7 +193,7 @@ _calcSubresourceSize(ID3D10Resource *pDstResource, UINT DstSubresource, const D3 UINT Width; UINT Height = 1; UINT Depth = 1; - UINT MipLevel = 0; + UINT MipLevels = 1; switch (Type) { case D3D10_RESOURCE_DIMENSION_BUFFER: @@ -210,7 +210,7 @@ _calcSubresourceSize(ID3D10Resource *pDstResource, UINT DstSubresource, const D3 static_cast(pDstResource)->GetDesc(&Desc); Format = Desc.Format; Width = Desc.Width; - MipLevel = DstSubresource % Desc.MipLevels; + MipLevels = Desc.MipLevels; } break; case D3D10_RESOURCE_DIMENSION_TEXTURE2D: @@ -220,7 +220,7 @@ _calcSubresourceSize(ID3D10Resource *pDstResource, UINT DstSubresource, const D3 Format = Desc.Format; Width = Desc.Width; Height = Desc.Height; - MipLevel = DstSubresource % Desc.MipLevels; + MipLevels = Desc.MipLevels; } break; case D3D10_RESOURCE_DIMENSION_TEXTURE3D: @@ -231,7 +231,7 @@ _calcSubresourceSize(ID3D10Resource *pDstResource, UINT DstSubresource, const D3 Width = Desc.Width; Height = Desc.Height; Depth = Desc.Depth; - MipLevel = DstSubresource % Desc.MipLevels; + MipLevels = Desc.MipLevels; } break; case D3D10_RESOURCE_DIMENSION_UNKNOWN: @@ -244,9 +244,17 @@ _calcSubresourceSize(ID3D10Resource *pDstResource, UINT DstSubresource, const D3 Width = pDstBox->right - pDstBox->left; Height = pDstBox->bottom - pDstBox->top; Depth = pDstBox->back - pDstBox->front; + } else { + assert(Width > 0); + assert(Height > 0); + assert(Depth > 0); + UINT MipLevel = DstSubresource % MipLevels; + Width = std::max(Width >> MipLevel, UINT(1)); + Height = std::max(Height >> MipLevel, UINT(1)); + Depth = std::max(Depth >> MipLevel, UINT(1)); } - return _calcMipDataSize(MipLevel, Format, Width, Height, SrcRowPitch, Depth, SrcDepthPitch); + return _calcDataSize(Format, Width, Height, SrcRowPitch, Depth, SrcDepthPitch); } diff --git a/helpers/d3d11size.hpp b/helpers/d3d11size.hpp index fcab7a7b..4c59510f 100644 --- a/helpers/d3d11size.hpp +++ b/helpers/d3d11size.hpp @@ -124,7 +124,7 @@ _calcSubresourceSize(ID3D11Resource *pDstResource, UINT DstSubresource, const D3 UINT Width; UINT Height = 1; UINT Depth = 1; - UINT MipLevel = 0; + UINT MipLevels = 1; switch (Type) { case D3D11_RESOURCE_DIMENSION_BUFFER: @@ -141,7 +141,7 @@ _calcSubresourceSize(ID3D11Resource *pDstResource, UINT DstSubresource, const D3 static_cast(pDstResource)->GetDesc(&Desc); Format = Desc.Format; Width = Desc.Width; - MipLevel = DstSubresource % Desc.MipLevels; + MipLevels = Desc.MipLevels; } break; case D3D11_RESOURCE_DIMENSION_TEXTURE2D: @@ -151,7 +151,7 @@ _calcSubresourceSize(ID3D11Resource *pDstResource, UINT DstSubresource, const D3 Format = Desc.Format; Width = Desc.Width; Height = Desc.Height; - MipLevel = DstSubresource % Desc.MipLevels; + MipLevels = Desc.MipLevels; } break; case D3D11_RESOURCE_DIMENSION_TEXTURE3D: @@ -162,7 +162,7 @@ _calcSubresourceSize(ID3D11Resource *pDstResource, UINT DstSubresource, const D3 Width = Desc.Width; Height = Desc.Height; Depth = Desc.Depth; - MipLevel = DstSubresource % Desc.MipLevels; + MipLevels = Desc.MipLevels; } break; case D3D11_RESOURCE_DIMENSION_UNKNOWN: @@ -175,9 +175,17 @@ _calcSubresourceSize(ID3D11Resource *pDstResource, UINT DstSubresource, const D3 Width = pDstBox->right - pDstBox->left; Height = pDstBox->bottom - pDstBox->top; Depth = pDstBox->back - pDstBox->front; + } else { + assert(Width > 0); + assert(Height > 0); + assert(Depth > 0); + UINT MipLevel = DstSubresource % MipLevels; + Width = std::max(Width >> MipLevel, UINT(1)); + Height = std::max(Height >> MipLevel, UINT(1)); + Depth = std::max(Depth >> MipLevel, UINT(1)); } - return _calcMipDataSize(MipLevel, Format, Width, Height, SrcRowPitch, Depth, SrcDepthPitch); + return _calcDataSize(Format, Width, Height, SrcRowPitch, Depth, SrcDepthPitch); } -- cgit v1.2.3