RasterizerCache: Swizzle to a staging buffer before copying it to memory when flushing a texture.

This gives us slightly increased memory safety, writing to out of bounds memory will be caught at the point of write instead of several calls down the line as memory corruption
This commit is contained in:
Subv
2018-09-21 13:52:36 -05:00
parent 2fd06acc8f
commit 51d4c772a2

View File

@@ -275,9 +275,12 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, std::si
const std::size_t size_to_copy{std::min(gl_buffer_size, data.size())};
memcpy(gl_buffer, data.data(), size_to_copy);
} else {
std::vector<u8> data(height * stride * bytes_per_pixel);
Tegra::Texture::CopySwizzledData(stride / tile_size, height / tile_size, bytes_per_pixel,
bytes_per_pixel, Memory::GetPointer(addr), gl_buffer,
false, block_height);
bytes_per_pixel, data.data(), gl_buffer, false,
block_height);
const std::size_t size_to_copy{std::min(gl_buffer_size, data.size())};
memcpy(Memory::GetPointer(addr), data.data(), size_to_copy);
}
}