Common/D3D11: Stride should be byte width

This commit is contained in:
Connor McLaughlin 2021-03-06 02:10:06 +10:00
parent bf5f53e1d1
commit 757bef7b6d
3 changed files with 13 additions and 12 deletions

View File

@ -55,18 +55,18 @@ public:
{ {
const u8* src_ptr = static_cast<u8*>(m_map.pData) + (y * m_map.RowPitch) + (x * sizeof(T)); const u8* src_ptr = static_cast<u8*>(m_map.pData) + (y * m_map.RowPitch) + (x * sizeof(T));
u8* dst_ptr = reinterpret_cast<u8*>(data); u8* dst_ptr = reinterpret_cast<u8*>(data);
if (m_map.RowPitch != (sizeof(T) * stride)) if (m_map.RowPitch != stride)
{ {
for (u32 row = 0; row < height; row++) for (u32 row = 0; row < height; row++)
{ {
std::memcpy(dst_ptr, src_ptr, sizeof(T) * width); std::memcpy(dst_ptr, src_ptr, sizeof(T) * width);
src_ptr += m_map.RowPitch; src_ptr += m_map.RowPitch;
dst_ptr += sizeof(T) * stride; dst_ptr += stride;
} }
} }
else else
{ {
std::memcpy(dst_ptr, src_ptr, (sizeof(T) * stride) * height); std::memcpy(dst_ptr, src_ptr, stride * height);
} }
} }
@ -89,18 +89,18 @@ public:
{ {
const u8* src_ptr = reinterpret_cast<const u8*>(data); const u8* src_ptr = reinterpret_cast<const u8*>(data);
u8* dst_ptr = static_cast<u8*>(m_map.pData) + (y * m_map.RowPitch) + (x * sizeof(T)); u8* dst_ptr = static_cast<u8*>(m_map.pData) + (y * m_map.RowPitch) + (x * sizeof(T));
if (m_map.RowPitch != (sizeof(T) * stride)) if (m_map.RowPitch != stride)
{ {
for (u32 row = 0; row < height; row++) for (u32 row = 0; row < height; row++)
{ {
std::memcpy(dst_ptr, src_ptr, sizeof(T) * width); std::memcpy(dst_ptr, src_ptr, sizeof(T) * width);
src_ptr += sizeof(T) * stride; src_ptr += stride;
dst_ptr += m_map.RowPitch; dst_ptr += m_map.RowPitch;
} }
} }
else else
{ {
std::memcpy(dst_ptr, src_ptr, (sizeof(T) * stride) * height); std::memcpy(dst_ptr, src_ptr, stride * height);
} }
} }

View File

@ -961,8 +961,9 @@ void GPU_HW_D3D11::ReadVRAM(u32 x, u32 y, u32 width, u32 height)
// And copy it into our shadow buffer. // And copy it into our shadow buffer.
if (m_vram_readback_texture.Map(m_context.Get(), false)) if (m_vram_readback_texture.Map(m_context.Get(), false))
{ {
m_vram_readback_texture.ReadPixels(0, 0, encoded_width * 2, encoded_height, VRAM_WIDTH, m_vram_readback_texture.ReadPixels<u32>(
&m_vram_shadow[copy_rect.top * VRAM_WIDTH + copy_rect.left]); 0, 0, encoded_width, encoded_height, VRAM_WIDTH * sizeof(u16),
reinterpret_cast<u32*>(&m_vram_shadow[copy_rect.top * VRAM_WIDTH + copy_rect.left]));
m_vram_readback_texture.Unmap(m_context.Get()); m_vram_readback_texture.Unmap(m_context.Get());
} }
else else

View File

@ -157,13 +157,13 @@ bool D3D11HostDisplay::DownloadTexture(const void* texture_handle, HostDisplayPi
if (srv_desc.Format == DXGI_FORMAT_B5G6R5_UNORM || srv_desc.Format == DXGI_FORMAT_B5G5R5A1_UNORM) if (srv_desc.Format == DXGI_FORMAT_B5G6R5_UNORM || srv_desc.Format == DXGI_FORMAT_B5G5R5A1_UNORM)
{ {
return m_readback_staging_texture.ReadPixels<u16>(m_context.Get(), 0, 0, width, height, return m_readback_staging_texture.ReadPixels<u16>(m_context.Get(), 0, 0, width, height, out_data_stride,
out_data_stride / sizeof(u16), static_cast<u16*>(out_data)); static_cast<u16*>(out_data));
} }
else else
{ {
return m_readback_staging_texture.ReadPixels<u32>(m_context.Get(), 0, 0, width, height, return m_readback_staging_texture.ReadPixels<u32>(m_context.Get(), 0, 0, width, height, out_data_stride,
out_data_stride / sizeof(u32), static_cast<u32*>(out_data)); static_cast<u32*>(out_data));
} }
} }