From abd8bbd6efbd3afd33afb6f099c30ae1a3d64b73 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Mon, 26 Jul 2021 19:14:18 +0300 Subject: [PATCH] vk: Allocate enough scratch memory for GPU deswizzle - Forgot to take alignment into account. --- rpcs3/Emu/RSX/VK/VKTexture.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index cb71fb615c..1cd4dea8ef 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -968,7 +968,9 @@ namespace vk { if (!scratch_buf) { - scratch_buf = vk::get_scratch_buffer(image_linear_size * 2); + // Calculate enough scratch memory. We need 2x the size of layer 0 to fit all the mip levels and an extra 128 bytes per level as alignment overhead. + const auto scratch_buf_size = 128u * ::size32(subresource_layout) + image_linear_size + image_linear_size; + scratch_buf = vk::get_scratch_buffer(scratch_buf_size); buffer_copies.reserve(subresource_layout.size()); }