From ba3c60b6cd8a99482b39d8d82313966a2d01dd9c Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Fri, 16 Jul 2021 15:19:07 -0700 Subject: [PATCH] fixed d3d11 Texture::get_data, which didn't use RowPitch --- src/internal/graphics_d3d11.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/internal/graphics_d3d11.cpp b/src/internal/graphics_d3d11.cpp index fb27ee3..9fc4d24 100644 --- a/src/internal/graphics_d3d11.cpp +++ b/src/internal/graphics_d3d11.cpp @@ -257,12 +257,20 @@ namespace Blah } } + D3D11_BOX box; + box.left = 0; + box.right = m_width; + box.bottom = m_height; + box.top = 0; + box.front = 0; + box.back = 1; + // copy data to staging texture state.context->CopySubresourceRegion( staging, 0, 0, 0, 0, texture, 0, - nullptr); + &box); // get data D3D11_MAPPED_SUBRESOURCE map; @@ -274,7 +282,11 @@ namespace Blah return; } - memcpy(data, map.pData, m_size); + int bytes_per_pixel = m_size / (m_width * m_height); + int bytes_per_row = m_width * bytes_per_pixel; + for (int y = 0; y < m_height; y++) + memcpy(data + y * bytes_per_row, (unsigned char*)map.pData + map.RowPitch * y, bytes_per_row); + state.context->Unmap(staging, 0); }