Skip to content

Commit

Permalink
[D3D11] Fixed image buffer size in D3D11RenderSystem::ReadTexture().
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Feb 13, 2025
1 parent 521bf73 commit 6813059
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions sources/Core/ImageFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,16 @@ LLGL_EXPORT std::size_t ConvertImageBuffer(
{
const std::size_t numPixels = (extent.width * extent.height * extent.depth);
const std::size_t requiredImageSize = GetMemoryFootprint(dstImageView.format, dstImageView.dataType, numPixels);
LLGL_ASSERT(dstImageView.dataSize >= requiredImageSize);
LLGL_ASSERT(srcImageView.dataSize >= requiredImageSize);
LLGL_ASSERT(
dstImageView.dataSize >= requiredImageSize,
"dstImageView.dataSize must be at least %zu, but %zu was specified",
requiredImageSize, dstImageView.dataSize
);
LLGL_ASSERT(
srcImageView.dataSize >= requiredImageSize,
"srcImageView.dataSize must be at least %zu, but %zu was specified",
requiredImageSize, srcImageView.dataSize
);
::memcpy(dstImageView.data, srcImageView.data, requiredImageSize);
return requiredImageSize;
}
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/Direct3D11/D3D11RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void D3D11RenderSystem::ReadTexture(Texture& texture, const TextureRegion& textu
formatAttribs.format,
formatAttribs.dataType,
mappedSubresource.pData,
mappedSubresource.DepthPitch,
mappedSubresource.DepthPitch * extent.depth,
mappedSubresource.RowPitch
};
const std::size_t bytesWritten = ConvertImageBuffer(intermediateSrcView, intermediateDstView, extent, LLGL_MAX_THREAD_COUNT, true);
Expand Down

0 comments on commit 6813059

Please sign in to comment.