]> git.tdb.fi Git - libs/gl.git/commitdiff
Track different kinds of bindings separately
authorMikko Rasa <tdb@tdb.fi>
Thu, 9 Dec 2021 11:43:16 +0000 (13:43 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 9 Dec 2021 11:43:16 +0000 (13:43 +0200)
source/backends/vulkan/pipelinestate_backend.cpp
source/core/program.h
source/core/reflectdata.cpp
source/core/reflectdata.h

index efcc961359a547e48721485b49827b4edcc42910..013e34c2636a9e995ab64d9815bc53e14dc80f41 100644 (file)
@@ -49,7 +49,7 @@ void VulkanPipelineState::update() const
                for(const PipelineState::BoundUniformBlock &u: self.uniform_blocks)
                        if(u.changed || changed_sets==~0U)
                        {
-                               u.used = self.shprog->uses_binding(u.binding);
+                               u.used = self.shprog->uses_uniform_block_binding(u.binding);
                                if(u.binding>=0)
                                        changed_sets |= 1<<(u.binding>>20);
                                u.changed = false;
@@ -57,7 +57,7 @@ void VulkanPipelineState::update() const
                for(const PipelineState::BoundTexture &t: self.textures)
                        if(t.changed || changed_sets==~0U)
                        {
-                               t.used = self.shprog->uses_binding(t.binding);
+                               t.used = self.shprog->uses_texture_binding(t.binding);
                                changed_sets |= 1<<(t.binding>>20);
                                if(t.sampler)
                                        t.sampler->refresh();
index 9d5b8b2b6522f4dcc1d19038295abf3d40583e2a..e8487e09d001bfc34acb4f0caab85f21784faf60 100644 (file)
@@ -82,7 +82,11 @@ public:
        int get_uniform_location(const std::string &) const;
        int get_uniform_location(Tag) const;
        int get_uniform_binding(Tag) const;
+       bool uses_uniform_block_binding(int b) const { return uses_binding(b|ReflectData::UNIFORM_BLOCK_BINDING); }
+       bool uses_texture_binding(unsigned b) const { return uses_binding(b|ReflectData::TEXTURE_BINDING); }
+private:
        bool uses_binding(int) const;
+public:
        const std::vector<ReflectData::AttributeInfo> &get_attributes() const { return reflect_data.attributes; }
        const ReflectData::AttributeInfo &get_attribute_info(const std::string &) const;
        int get_attribute_location(const std::string &) const;
index 93ecee5fd2ddafce8e436e6af37c9c9355dc4352..c4c24f7bb21656750edcbd77c693de737ba52360 100644 (file)
@@ -21,10 +21,10 @@ void ReflectData::update_layout_hash()
 void ReflectData::update_used_bindings()
 {
        for(const UniformInfo &u: uniforms)
-               if(u.binding>=0)
-                       used_bindings.push_back(u.binding);
+               if(u.binding>=0 && is_image(u.type))
+                       used_bindings.push_back(u.binding|TEXTURE_BINDING);
        for(const UniformBlockInfo &b: uniform_blocks)
-               used_bindings.push_back(b.bind_point);
+               used_bindings.push_back(b.bind_point|UNIFORM_BLOCK_BINDING);
        sort(used_bindings);
 }
 
index ba86dd333ea442cdad8d593cf6cfe2765b7741b1..ee98634ba6fa187f6607f35caefd3bdf4e63af3a 100644 (file)
@@ -17,7 +17,9 @@ struct ReflectData
        enum
        {
                DEFAULT_BLOCK = -1,
-               PUSH_CONSTANT = -2
+               PUSH_CONSTANT = -2,
+               UNIFORM_BLOCK_BINDING = 0,
+               TEXTURE_BINDING = 0x1000000
        };
 
        typedef unsigned LayoutHash;