]> git.tdb.fi Git - libs/gl.git/commitdiff
Check if render target is swapchain and set to_present accordingly
authorMikko Rasa <tdb@tdb.fi>
Fri, 19 Nov 2021 22:39:53 +0000 (00:39 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 19 Nov 2021 23:04:35 +0000 (01:04 +0200)
source/backends/vulkan/commands_backend.cpp
source/backends/vulkan/framebuffer_backend.cpp
source/backends/vulkan/framebuffer_backend.h

index 684f0a476b723172b5ea7bcfe190ad9c465bf7bd..1634863b49e227057ccf3ceb29435600dcb00704 100644 (file)
@@ -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<n_attachments; ++i)
+               if(dynamic_cast<const SwapChainTexture *>(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();
 
index 96653fe1d084444b625297cd9651ff2dea0f8b90..52857351c3e3237bd72425764ef4d073f4b8767f 100644 (file)
@@ -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<const Framebuffer *>(this)->attachments[i].tex;
+}
+
 void VulkanFramebuffer::update(unsigned) const
 {
        const Framebuffer &self = *static_cast<const Framebuffer *>(this);
index ff15c0d556a8770dc4159e1994404646f04a8b2a..cb11004299692b01a1becdb0e4068b9af8b7c121 100644 (file)
@@ -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 { }