From a58ad988bb3c23e5c2ad2ea9142e08a41a7ff1b5 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Wed, 6 Apr 2022 00:40:30 -0700 Subject: [PATCH] Fixed bug with CaptureTexture of 1D textures for Direct3D 11 --- DirectXTex/DirectXTexD3D11.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DirectXTex/DirectXTexD3D11.cpp b/DirectXTex/DirectXTexD3D11.cpp index 254e7b3..735fc57 100644 --- a/DirectXTex/DirectXTexD3D11.cpp +++ b/DirectXTex/DirectXTexD3D11.cpp @@ -171,11 +171,13 @@ namespace return E_UNEXPECTED; } + const size_t msize = (metadata.dimension == TEX_DIMENSION_TEXTURE2D) + ? std::min(img->rowPitch, mapped.RowPitch) : img->rowPitch; + auto sptr = static_cast(mapped.pData); uint8_t* dptr = img->pixels; for (size_t h = 0; h < lines; ++h) { - const size_t msize = std::min(img->rowPitch, mapped.RowPitch); memcpy(dptr, sptr, msize); sptr += mapped.RowPitch; dptr += img->rowPitch;