]> git.tdb.fi Git - libs/gl.git/commitdiff
Make framebuffer attachment accessors public
authorMikko Rasa <tdb@tdb.fi>
Sun, 21 Nov 2021 10:10:11 +0000 (12:10 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 21 Nov 2021 23:03:09 +0000 (01:03 +0200)
source/backends/vulkan/commands_backend.cpp
source/backends/vulkan/framebuffer_backend.cpp
source/backends/vulkan/framebuffer_backend.h
source/core/framebuffer.cpp
source/core/framebuffer.h

index c2c86307f8bb668d3a3d8d13f06d050ae8e6bab6..a5f2ceb5ad9dcd38789c14801cf0ca759a83b2ce 100644 (file)
@@ -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<n_attachments; ++i)
-               if(dynamic_cast<const SwapChainTexture *>(framebuffer->VulkanFramebuffer::get_attachment(i)))
+               if(dynamic_cast<const SwapChainTexture *>(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);
 
index 52857351c3e3237bd72425764ef4d073f4b8767f..96653fe1d084444b625297cd9651ff2dea0f8b90 100644 (file)
@@ -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<const Framebuffer *>(this)->attachments[i].tex;
-}
-
 void VulkanFramebuffer::update(unsigned) const
 {
        const Framebuffer &self = *static_cast<const Framebuffer *>(this);
index cb11004299692b01a1becdb0e4068b9af8b7c121..d9d7cc90d69f655d72b1b8bc42f8354ee58b72bc 100644 (file)
@@ -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 { }
 
index b0777171448b5a27222e4b631e8d04cc52143ae6..8a1a52316f9fa6835e685570f6357d14955389d0 100644 (file)
@@ -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<attachments.size() ? attachments[i].tex : 0);
+}
+
 void Framebuffer::require_complete() const
 {
        bool layered = (!attachments.empty() && attachments.front().layer<0);
index 920d9422fae0c103d0a492c81e9024b9f3a595ae..b805721640f26f5ce764cf867f689a2a9411cb69 100644 (file)
@@ -99,6 +99,9 @@ public:
        void attach_layered(FrameAttachment attch, TextureCube &, unsigned level = 0);
        void detach(FrameAttachment attch);
 
+       const Texture *get_attachment(FrameAttachment) const;
+       const Texture *get_attachment(unsigned) const;
+
        /** Ensures that the framebuffer is complete, throwing an exception if it
        isn't. */
        void require_complete() const;