From: Mikko Rasa Date: Thu, 9 Dec 2021 11:43:16 +0000 (+0200) Subject: Track different kinds of bindings separately X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2c060874dcf5cee7ffa52e3d2caee505371fa1a8;p=libs%2Fgl.git Track different kinds of bindings separately --- diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index efcc9613..013e34c2 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -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(); diff --git a/source/core/program.h b/source/core/program.h index 9d5b8b2b..e8487e09 100644 --- a/source/core/program.h +++ b/source/core/program.h @@ -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 &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; diff --git a/source/core/reflectdata.cpp b/source/core/reflectdata.cpp index 93ecee5f..c4c24f7b 100644 --- a/source/core/reflectdata.cpp +++ b/source/core/reflectdata.cpp @@ -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); } diff --git a/source/core/reflectdata.h b/source/core/reflectdata.h index ba86dd33..ee98634b 100644 --- a/source/core/reflectdata.h +++ b/source/core/reflectdata.h @@ -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;