From: Mikko Rasa Date: Sun, 21 Nov 2021 10:10:11 +0000 (+0200) Subject: Make framebuffer attachment accessors public X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=f4f81f1d86d50b29b9a44b237f67c6f5ad8f0523 Make framebuffer attachment accessors public --- diff --git a/source/backends/vulkan/commands_backend.cpp b/source/backends/vulkan/commands_backend.cpp index c2c86307..a5f2ceb5 100644 --- a/source/backends/vulkan/commands_backend.cpp +++ b/source/backends/vulkan/commands_backend.cpp @@ -76,7 +76,7 @@ void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_value bool to_present = false; unsigned n_attachments = framebuffer->get_format().size(); for(unsigned i=0; i(framebuffer->VulkanFramebuffer::get_attachment(i))) + if(dynamic_cast(framebuffer->get_attachment(i))) to_present = true; VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, !clear_values, to_present); diff --git a/source/backends/vulkan/framebuffer_backend.cpp b/source/backends/vulkan/framebuffer_backend.cpp index 52857351..96653fe1 100644 --- a/source/backends/vulkan/framebuffer_backend.cpp +++ b/source/backends/vulkan/framebuffer_backend.cpp @@ -48,11 +48,6 @@ 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 cb110042..d9d7cc90 100644 --- a/source/backends/vulkan/framebuffer_backend.h +++ b/source/backends/vulkan/framebuffer_backend.h @@ -28,7 +28,6 @@ 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 { } diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index b0777171..8a1a5231 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -165,6 +165,20 @@ void Framebuffer::detach(FrameAttachment attch) } } +const Texture *Framebuffer::get_attachment(FrameAttachment attch) const +{ + if(attachments.empty()) + return 0; + + int i = format.index(attch); + return (i>=0 ? attachments[i].tex : 0); +} + +const Texture *Framebuffer::get_attachment(unsigned i) const +{ + return (i