X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fvulkan%2Fframebuffer_backend.cpp;h=4c68546f15ed322181aad3ef9c136f92c9892ff3;hb=fcc065736e303088ef121c554318e0cc028a0666;hp=48b25f2ac456dec0e1816308cd16ac2916839804;hpb=d98d835a6359844efcbc13b18ea6c93ace117359;p=libs%2Fgl.git diff --git a/source/backends/vulkan/framebuffer_backend.cpp b/source/backends/vulkan/framebuffer_backend.cpp index 48b25f2a..4c68546f 100644 --- a/source/backends/vulkan/framebuffer_backend.cpp +++ b/source/backends/vulkan/framebuffer_backend.cpp @@ -2,6 +2,8 @@ #include "device.h" #include "framebuffer.h" #include "framebuffer_backend.h" +#include "renderpass.h" +#include "swapchaintexture.h" #include "vulkan.h" using namespace std; @@ -52,6 +54,13 @@ bool VulkanFramebuffer::is_format_supported(const FrameFormat &fmt) return true; } +bool VulkanFramebuffer::is_presentable() const +{ + const Framebuffer &self = *static_cast(this); + return std::any_of(self.attachments.begin(), self.attachments.end(), + [](const Framebuffer::Attachment &a){ return dynamic_cast(a.tex); }); +} + void VulkanFramebuffer::update(unsigned mask) const { const Framebuffer &self = *static_cast(this); @@ -63,8 +72,9 @@ void VulkanFramebuffer::update(unsigned mask) const if(handle) device.get_destroy_queue().destroy(handle); - VkImageView vk_attachments[FrameFormat::MAX_ATTACHMENTS] = { }; + VkImageView vk_attachments[FrameFormat::MAX_ATTACHMENTS*2] = { }; unsigned i = 0; + bool any_resolve = false; for(const Framebuffer::Attachment &a: self.attachments) { bool use_tex_view = (a.tex->view_type==VK_IMAGE_VIEW_TYPE_2D || (a.tex->view_type==VK_IMAGE_VIEW_TYPE_2D_ARRAY && a.layer<0)); @@ -108,15 +118,24 @@ void VulkanFramebuffer::update(unsigned mask) const else throw logic_error("unexpected framebuffer configuration"); + if(a.resolve) + { + a.resolve->refresh_mip_views(); + vk_attachments[self.format.size()+i] = a.resolve->mip_view_handles[0]; + any_resolve = true; + } + ++i; } - VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(self.format, false, false, false); + RenderPass render_pass; + render_pass.framebuffer = &self; + render_pass.update(device); VkFramebufferCreateInfo framebuffer_info = { }; framebuffer_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebuffer_info.renderPass = handle_cast<::VkRenderPass>(render_pass); - framebuffer_info.attachmentCount = self.format.size(); + framebuffer_info.renderPass = handle_cast<::VkRenderPass>(render_pass.handle); + framebuffer_info.attachmentCount = self.format.size()*(1+any_resolve); framebuffer_info.pAttachments = handle_cast<::VkImageView *>(vk_attachments); framebuffer_info.width = self.width; framebuffer_info.height = self.height; @@ -131,7 +150,11 @@ void VulkanFramebuffer::update(unsigned mask) const void VulkanFramebuffer::prepare_image_layouts(bool discard) const { for(const Framebuffer::Attachment &a: static_cast(this)->attachments) + { a.tex->change_layout(a.level, get_vulkan_attachment_layout(get_components(a.tex->get_format())), (discard && a.layer<0)); + if(a.resolve) + a.resolve->change_layout(a.level, get_vulkan_attachment_layout(get_components(a.resolve->get_format())), discard); + } } void VulkanFramebuffer::set_debug_name(const string &name)