summaryrefslogtreecommitdiffstats
path: root/tools/gfx/d3d12/render-d3d12.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-12-13 12:40:52 -0800
committerGitHub <noreply@github.com>2021-12-13 12:40:52 -0800
commitf024d7299831c0312877e315e8d78b920aaafbaf (patch)
tree51bf3b01e98a8a3d351a2ed313f15a614a2a5c78 /tools/gfx/d3d12/render-d3d12.cpp
parent7c1ca35c96096cb0059f0ef23a799bf5952810c5 (diff)
Fixes to `uploadTextureData`. (#2058)
* Fixes to `uploadTextureData`. * Fix, Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tools/gfx/d3d12/render-d3d12.cpp')
-rw-r--r--tools/gfx/d3d12/render-d3d12.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/gfx/d3d12/render-d3d12.cpp b/tools/gfx/d3d12/render-d3d12.cpp
index 25caa84a2..3daddc73f 100644
--- a/tools/gfx/d3d12/render-d3d12.cpp
+++ b/tools/gfx/d3d12/render-d3d12.cpp
@@ -3717,7 +3717,7 @@ public:
aspectMask = (int32_t)TextureAspect::Color;
while (aspectMask)
{
- auto aspect = (int32_t)aspectMask & (-(int32_t)aspectMask); // get lowest bit of aspectMask.
+ auto aspect = Math::getLowestBit((int32_t)aspectMask);
aspectMask &= ~aspect;
auto planeIndex = D3DUtil::getPlaneSlice(d3dFormat, (TextureAspect)aspect);
for (uint32_t layer = 0; layer < dstSubresource.layerCount; layer++)
@@ -3770,7 +3770,7 @@ public:
ITextureResource* dst,
SubresourceRange subResourceRange,
ITextureResource::Offset3D offset,
- ITextureResource::Offset3D extent,
+ ITextureResource::Size extent,
ITextureResource::SubresourceData* subResourceData,
size_t subResourceDataCount) override
{
@@ -3804,35 +3804,36 @@ public:
footprint.Footprint.Format = texDesc.Format;
uint32_t mipLevel = D3DUtil::getSubresourceMipLevel(
subresourceIndex, dstTexture->getDesc()->numMipLevels);
- if (extent.x != 0xFFFFFFFF)
+ if (extent.width != ITextureResource::kRemainingTextureSize)
{
- footprint.Footprint.Width = extent.x;
+ footprint.Footprint.Width = extent.width;
}
else
{
footprint.Footprint.Width = Math::Max(1, (textureSize.width >> mipLevel)) - offset.x;
}
- if (extent.y != 0xFFFFFFFF)
+ if (extent.height != ITextureResource::kRemainingTextureSize)
{
- footprint.Footprint.Height = extent.y;
+ footprint.Footprint.Height = extent.height;
}
else
{
footprint.Footprint.Height =
Math::Max(1, (textureSize.height >> mipLevel)) - offset.y;
}
- if (extent.z != 0xFFFFFFFF)
+ if (extent.depth != ITextureResource::kRemainingTextureSize)
{
- footprint.Footprint.Depth = extent.z;
+ footprint.Footprint.Depth = extent.depth;
}
else
{
footprint.Footprint.Depth =
Math::Max(1, (textureSize.depth >> mipLevel)) - offset.z;
}
+ auto rowSize = (footprint.Footprint.Width + formatInfo.blockWidth - 1) /
+ formatInfo.blockWidth * formatInfo.blockSizeInBytes;
footprint.Footprint.RowPitch = (UINT)D3DUtil::calcAligned(
- footprint.Footprint.Width * (UInt)formatInfo.blockSizeInBytes,
- (uint32_t)D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
+ rowSize, (uint32_t)D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
auto bufferSize = footprint.Footprint.RowPitch * footprint.Footprint.Height *
footprint.Footprint.Depth;
@@ -3856,7 +3857,7 @@ public:
memcpy(
imageStart + row * (size_t)footprint.Footprint.RowPitch,
srcData + subResourceData->strideY * row,
- subResourceData->strideY);
+ rowSize);
}
}
bufferImpl->m_resource.getResource()->Unmap(0, nullptr);
@@ -4104,8 +4105,7 @@ public:
aspectMask = (int32_t)TextureAspect::Color;
while (aspectMask)
{
- auto aspect = (int32_t)aspectMask &
- (-(int32_t)aspectMask); // get lowest bit of aspectMask.
+ auto aspect = Math::getLowestBit((int32_t)aspectMask);
aspectMask &= ~aspect;
auto planeIndex = D3DUtil::getPlaneSlice(d3dFormat, (TextureAspect)aspect);
for (uint32_t layer = 0; layer < subresourceRange.baseArrayLayer; layer++)