From 700d6d10f4d4cbc63f1df9ad2c117f44e479c192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 1 Nov 2017 00:09:04 +0100 Subject: [PATCH] Always recreate DrawPixelsTex to avoid inter-frame races. --- GPU/Vulkan/FramebufferVulkan.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index d1bf945bd0..83bda7596d 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -206,22 +206,17 @@ void FramebufferManagerVulkan::Init() { } void FramebufferManagerVulkan::MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height, float &u1, float &v1) { - if (drawPixelsTex_ && (drawPixelsTexFormat_ != srcPixelFormat || drawPixelsTex_->GetWidth() != width || drawPixelsTex_->GetHeight() != height)) { + if (drawPixelsTex_) { delete drawPixelsTex_; drawPixelsTex_ = nullptr; } VkCommandBuffer initCmd = (VkCommandBuffer)draw_->GetNativeObject(Draw::NativeObject::INIT_COMMANDBUFFER); - if (!drawPixelsTex_) { - drawPixelsTex_ = new VulkanTexture(vulkan_); - drawPixelsTex_->CreateDirect(initCmd, width, height, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT); - // Initialize backbuffer texture for DrawPixels - drawPixelsTexFormat_ = srcPixelFormat; - } else { - // TODO: We may want to double-buffer these, when we have more frames hanging about. - drawPixelsTex_->TransitionForUpload(initCmd); - } + drawPixelsTex_ = new VulkanTexture(vulkan_); + drawPixelsTex_->CreateDirect(initCmd, width, height, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT); + // Initialize backbuffer texture for DrawPixels + drawPixelsTexFormat_ = srcPixelFormat; // TODO: We can just change the texture format and flip some bits around instead of this. // Could share code with the texture cache perhaps.