]> git.tdb.fi Git - libs/gl.git/commitdiff
Track the number of layers in Framebuffer
authorMikko Rasa <tdb@tdb.fi>
Thu, 9 Dec 2021 13:34:27 +0000 (15:34 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 9 Dec 2021 13:46:09 +0000 (15:46 +0200)
source/backends/vulkan/framebuffer_backend.cpp
source/core/framebuffer.cpp
source/core/framebuffer.h

index 8ef69ecd72a206c87db8b3997afecc250d7dc063..61ab1caeef75504063f4f3a34475056ac292b142 100644 (file)
@@ -74,7 +74,7 @@ void VulkanFramebuffer::update(unsigned) const
        framebuffer_info.pAttachments = handle_cast<::VkImageView *>(vk_attachments);
        framebuffer_info.width = self.width;
        framebuffer_info.height = self.height;
-       framebuffer_info.layers = 1;
+       framebuffer_info.layers = self.layers;
 
        vk.CreateFramebuffer(framebuffer_info, handle);
 
index 8a1a52316f9fa6835e685570f6357d14955389d0..97cc905d5bfb107d9af7dc3101333218ea0301f7 100644 (file)
@@ -60,6 +60,7 @@ void Framebuffer::check_size()
                {
                        unsigned w = 0;
                        unsigned h = 0;
+                       unsigned l = 1;
                        if(const Texture2D *tex2d = dynamic_cast<const Texture2D *>(a.tex))
                        {
                                w = max(tex2d->get_width()>>a.level, 1U);
@@ -74,6 +75,7 @@ void Framebuffer::check_size()
                        {
                                w = max(tex3d->get_width()>>a.level, 1U);
                                h = max(tex3d->get_height()>>a.level, 1U);
+                               l = (a.layer<0 ? tex3d->get_depth() : 1);
                        }
                        else if(const TextureCube *tex_cube = dynamic_cast<const TextureCube *>(a.tex))
                        {
@@ -85,12 +87,14 @@ void Framebuffer::check_size()
                        {
                                width = w;
                                height = h;
+                               layers = l;
                                first = false;
                        }
                        else
                        {
                                width = min(width, w);
                                height = min(height, h);
+                               layers = min(layers, l);
                        }
                }
 }
index b805721640f26f5ce764cf867f689a2a9411cb69..1a13ca5bc9dbc979fa4d9bbcfcee47a1eed9e831 100644 (file)
@@ -49,6 +49,7 @@ protected:
        std::vector<Attachment> attachments;
        unsigned width = 0;
        unsigned height = 0;
+       unsigned layers = 0;
        mutable unsigned dirty = 0;
 
        Framebuffer(bool);
@@ -71,6 +72,7 @@ public:
 
        unsigned get_width() const { return width; }
        unsigned get_height() const { return height; }
+       unsigned get_layers() const { return layers; }
 
 protected:
        void update() const;