]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/pipelinestate_backend.cpp
Only set pipeline resources as used when the resource changes
[libs/gl.git] / source / backends / vulkan / pipelinestate_backend.cpp
index 172386d6eee9c8bcf85d4e41dfc91b55551d1f70..84609ab03666370a0ce0793f3e6bdc4e9961daaf 100644 (file)
@@ -49,7 +49,8 @@ void VulkanPipelineState::update() const
                for(const PipelineState::BoundUniformBlock &u: self.uniform_blocks)
                        if(u.changed || changed_sets==~0U)
                        {
-                               u.used = self.shprog->uses_uniform_block_binding(u.binding);
+                               if(u.block)
+                                       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 +58,8 @@ void VulkanPipelineState::update() const
                for(const PipelineState::BoundTexture &t: self.textures)
                        if(t.changed || changed_sets==~0U)
                        {
-                               t.used = self.shprog->uses_texture_binding(t.binding);
+                               if(t.texture && t.sampler)
+                                       t.used = self.shprog->uses_texture_binding(t.binding);
                                changed_sets |= 1<<(t.binding>>20);
                                if(t.texture && t.level>=0)
                                        t.texture->refresh_mip_views();
@@ -275,14 +277,14 @@ uint64_t VulkanPipelineState::compute_descriptor_set_hash(unsigned index) const
                {
                        result = hash_update<64>(result, b.binding);
                        result = hash_update<64>(result, reinterpret_cast<uintptr_t>(b.block));
-                       result = hash_update<64>(result, reinterpret_cast<uintptr_t>(b.buffer));
+                       result = hash_update<64>(result, reinterpret_cast<uintptr_t>(b.buffer->handle));
                }
        for(const PipelineState::BoundTexture &t: self.textures)
                if(t.used && (t.binding>>20)==index)
                {
                        result = hash_update<64>(result, t.binding);
-                       result = hash_update<64>(result, reinterpret_cast<uintptr_t>(t.texture));
-                       result = hash_update<64>(result, reinterpret_cast<uintptr_t>(t.sampler));
+                       result = hash_update<64>(result, reinterpret_cast<uintptr_t>(t.texture->handle));
+                       result = hash_update<64>(result, reinterpret_cast<uintptr_t>(t.sampler->handle));
                        result = hash_update<64>(result, t.level);
                }