]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/framebuffer_backend.cpp
Rename VulkanFramebuffer::prepare_image_layouts to synchronize_resources
[libs/gl.git] / source / backends / vulkan / framebuffer_backend.cpp
index 9af8a2f7b1a7a9e52464d6d0027da801bee96700..9395635476025473e182653becb57316737006ed 100644 (file)
@@ -3,6 +3,7 @@
 #include "framebuffer.h"
 #include "framebuffer_backend.h"
 #include "renderpass.h"
+#include "swapchaintexture.h"
 #include "vulkan.h"
 
 using namespace std;
@@ -32,7 +33,7 @@ VulkanFramebuffer::~VulkanFramebuffer()
                        dq.destroy(h);
 }
 
-bool VulkanFramebuffer::is_format_supported(const FrameFormat &fmt)
+bool VulkanFramebuffer::is_format_supported(const FrameFormat &fmt) const
 {
        const VulkanFunctions &vk = device.get_functions();
        for(FrameAttachment a: fmt)
@@ -53,6 +54,13 @@ bool VulkanFramebuffer::is_format_supported(const FrameFormat &fmt)
        return true;
 }
 
+bool VulkanFramebuffer::is_presentable() const
+{
+       const Framebuffer &self = *static_cast<const Framebuffer *>(this);
+       return std::any_of(self.attachments.begin(), self.attachments.end(),
+               [](const Framebuffer::Attachment &a){ return dynamic_cast<const SwapChainTexture *>(a.tex); });
+}
+
 void VulkanFramebuffer::update(unsigned mask) const
 {
        const Framebuffer &self = *static_cast<const Framebuffer *>(this);
@@ -122,6 +130,7 @@ void VulkanFramebuffer::update(unsigned mask) const
 
        RenderPass render_pass;
        render_pass.framebuffer = &self;
+       render_pass.to_present = is_presentable();
        render_pass.update(device);
 
        VkFramebufferCreateInfo framebuffer_info = { };
@@ -139,7 +148,7 @@ void VulkanFramebuffer::update(unsigned mask) const
                set_vulkan_object_name();
 }
 
-void VulkanFramebuffer::prepare_image_layouts(bool discard) const
+void VulkanFramebuffer::synchronize_resources(bool discard) const
 {
        for(const Framebuffer::Attachment &a: static_cast<const Framebuffer *>(this)->attachments)
        {