From 6630b1106493e5a072a9a9f212f0d00648dbedd4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 20 Nov 2021 00:39:53 +0200 Subject: [PATCH] Check if render target is swapchain and set to_present accordingly --- source/backends/vulkan/commands_backend.cpp | 9 +++++++-- source/backends/vulkan/framebuffer_backend.cpp | 5 +++++ source/backends/vulkan/framebuffer_backend.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source/backends/vulkan/commands_backend.cpp b/source/backends/vulkan/commands_backend.cpp index 684f0a47..1634863b 100644 --- a/source/backends/vulkan/commands_backend.cpp +++ b/source/backends/vulkan/commands_backend.cpp @@ -9,6 +9,7 @@ #include "pipelinestate.h" #include "rect.h" #include "semaphore.h" +#include "swapchaintexture.h" #include "vulkan.h" using namespace std; @@ -68,8 +69,12 @@ void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_value device.get_transfer_queue().dispatch_transfers(current_buffer); - // TODO Use proper value for to_present - VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(target->get_format(), clear, !clear_values, true); + bool to_present = false; + unsigned n_attachments = target->get_format().size(); + for(unsigned i=0; i(target->VulkanFramebuffer::get_attachment(i))) + to_present = true; + VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(target->get_format(), clear, !clear_values, to_present); target->refresh(); diff --git a/source/backends/vulkan/framebuffer_backend.cpp b/source/backends/vulkan/framebuffer_backend.cpp index 96653fe1..52857351 100644 --- a/source/backends/vulkan/framebuffer_backend.cpp +++ b/source/backends/vulkan/framebuffer_backend.cpp @@ -48,6 +48,11 @@ bool VulkanFramebuffer::is_format_supported(const FrameFormat &fmt) return true; } +const Texture *VulkanFramebuffer::get_attachment(unsigned i) const +{ + return static_cast(this)->attachments[i].tex; +} + void VulkanFramebuffer::update(unsigned) const { const Framebuffer &self = *static_cast(this); diff --git a/source/backends/vulkan/framebuffer_backend.h b/source/backends/vulkan/framebuffer_backend.h index ff15c0d5..cb110042 100644 --- a/source/backends/vulkan/framebuffer_backend.h +++ b/source/backends/vulkan/framebuffer_backend.h @@ -9,6 +9,7 @@ namespace Msp { namespace GL { class Device; +class Texture; class VulkanFramebuffer: public NonCopyable { @@ -27,6 +28,7 @@ protected: bool is_format_supported(const FrameFormat &); static void require_layered() { } + const Texture *get_attachment(unsigned) const; void update(unsigned) const; void require_complete() const { } -- 2.43.0