Skip to content

Commit

Permalink
Fixed incorrect texture extents in copyTexture functions involving st…
Browse files Browse the repository at this point in the history
…aging textures on Vulkan (NVIDIAGameWorks#41)
  • Loading branch information
apanteleev authored and GaelCathelin committed Jan 11, 2024
1 parent 1fce557 commit b74bf82
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/vulkan/vulkan-staging-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ namespace nvrhi::vulkan
auto resolvedSrcSlice = srcSlice.resolve(src->desc);

assert(resolvedDstSlice.depth == 1);

vk::Extent3D srcMipSize = src->imageInfo.extent;
srcMipSize.width = std::max(srcMipSize.width >> resolvedDstSlice.mipLevel, 1u);
srcMipSize.height = std::max(srcMipSize.height >> resolvedDstSlice.mipLevel, 1u);


auto dstRegion = dst->getSliceRegion(resolvedDstSlice.mipLevel, resolvedDstSlice.arraySlice, resolvedDstSlice.z);
assert((dstRegion.offset & 0x3) == 0); // per Vulkan spec

Expand All @@ -199,7 +195,7 @@ namespace nvrhi::vulkan
.setBaseArrayLayer(resolvedSrcSlice.arraySlice)
.setLayerCount(1))
.setImageOffset(vk::Offset3D(resolvedSrcSlice.x, resolvedSrcSlice.y, resolvedSrcSlice.z))
.setImageExtent(srcMipSize);
.setImageExtent(vk::Extent3D(resolvedSrcSlice.width, resolvedSrcSlice.height, resolvedSrcSlice.depth));

assert(m_CurrentCmdBuf);

Expand All @@ -225,11 +221,7 @@ namespace nvrhi::vulkan

auto resolvedDstSlice = dstSlice.resolve(dst->desc);
auto resolvedSrcSlice = srcSlice.resolve(src->desc);

vk::Extent3D dstMipSize = dst->imageInfo.extent;
dstMipSize.width = std::max(dstMipSize.width >> resolvedDstSlice.mipLevel, 1u);
dstMipSize.height = std::max(dstMipSize.height >> resolvedDstSlice.mipLevel, 1u);


auto srcRegion = src->getSliceRegion(resolvedSrcSlice.mipLevel, resolvedSrcSlice.arraySlice, resolvedSrcSlice.z);

assert((srcRegion.offset & 0x3) == 0); // per vulkan spec
Expand All @@ -252,7 +244,7 @@ namespace nvrhi::vulkan
.setBaseArrayLayer(resolvedDstSlice.arraySlice)
.setLayerCount(1))
.setImageOffset(dstOffset)
.setImageExtent(dstMipSize);
.setImageExtent(vk::Extent3D(resolvedDstSlice.width, resolvedDstSlice.height, resolvedDstSlice.depth));

assert(m_CurrentCmdBuf);

Expand Down

0 comments on commit b74bf82

Please sign in to comment.