GPU/D3D11: Fix possible buffer overwrite when reading back

This commit is contained in:
Connor McLaughlin 2021-07-04 21:40:44 +10:00
parent 8be2b66ebb
commit 6e9ebfa5b5
2 changed files with 4 additions and 4 deletions

View file

@ -55,7 +55,7 @@ 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 != stride)
if (m_map.RowPitch != stride || width != m_width || x != 0)
{
for (u32 row = 0; row < height; row++)
{
@ -89,7 +89,7 @@ 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 != stride)
if (m_map.RowPitch != stride || width != m_width || x != 0)
{
for (u32 row = 0; row < height; row++)
{

View file

@ -267,9 +267,9 @@ bool GPU_HW_D3D11::CreateFramebuffer()
((m_downsample_mode == GPUDownsampleMode::Adaptive) ? VRAM_WIDTH : GPU_MAX_DISPLAY_WIDTH) * m_resolution_scale,
GPU_MAX_DISPLAY_HEIGHT * m_resolution_scale, 1, 1, texture_format,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET) ||
!m_vram_encoding_texture.Create(m_device.Get(), VRAM_WIDTH, VRAM_HEIGHT, 1, 1, texture_format,
!m_vram_encoding_texture.Create(m_device.Get(), VRAM_WIDTH / 2, VRAM_HEIGHT, 1, 1, texture_format,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET) ||
!m_vram_readback_texture.Create(m_device.Get(), VRAM_WIDTH, VRAM_HEIGHT, texture_format, false))
!m_vram_readback_texture.Create(m_device.Get(), VRAM_WIDTH / 2, VRAM_HEIGHT, texture_format, false))
{
return false;
}