diff --git a/src/common/d3d11/staging_texture.h b/src/common/d3d11/staging_texture.h index 04a77c163..cb703d6b0 100644 --- a/src/common/d3d11/staging_texture.h +++ b/src/common/d3d11/staging_texture.h @@ -55,18 +55,18 @@ public: { const u8* src_ptr = static_cast<u8*>(m_map.pData) + (y * m_map.RowPitch) + (x * sizeof(T)); 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++) { std::memcpy(dst_ptr, src_ptr, sizeof(T) * width); src_ptr += m_map.RowPitch; - dst_ptr += sizeof(T) * stride; + dst_ptr += stride; } } 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); 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++) { std::memcpy(dst_ptr, src_ptr, sizeof(T) * width); - src_ptr += sizeof(T) * stride; + src_ptr += stride; dst_ptr += m_map.RowPitch; } } else { - std::memcpy(dst_ptr, src_ptr, (sizeof(T) * stride) * height); + std::memcpy(dst_ptr, src_ptr, stride * height); } } diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index 11b398623..2e7a9c10f 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -961,8 +961,9 @@ void GPU_HW_D3D11::ReadVRAM(u32 x, u32 y, u32 width, u32 height) // And copy it into our shadow buffer. 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_shadow[copy_rect.top * VRAM_WIDTH + copy_rect.left]); + m_vram_readback_texture.ReadPixels<u32>( + 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()); } else diff --git a/src/frontend-common/d3d11_host_display.cpp b/src/frontend-common/d3d11_host_display.cpp index ad1e6821a..b9a35d6ff 100644 --- a/src/frontend-common/d3d11_host_display.cpp +++ b/src/frontend-common/d3d11_host_display.cpp @@ -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) { - return m_readback_staging_texture.ReadPixels<u16>(m_context.Get(), 0, 0, width, height, - out_data_stride / sizeof(u16), static_cast<u16*>(out_data)); + return m_readback_staging_texture.ReadPixels<u16>(m_context.Get(), 0, 0, width, height, out_data_stride, + static_cast<u16*>(out_data)); } else { - return m_readback_staging_texture.ReadPixels<u32>(m_context.Get(), 0, 0, width, height, - out_data_stride / sizeof(u32), static_cast<u32*>(out_data)); + return m_readback_staging_texture.ReadPixels<u32>(m_context.Get(), 0, 0, width, height, out_data_stride, + static_cast<u32*>(out_data)); } }