]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/pipelinestate_backend.h
Rebind all descriptor sets if push constant layout changes
[libs/gl.git] / source / backends / vulkan / pipelinestate_backend.h
1 #ifndef MSP_GL_PIPELINESTATE_BACKEND_H_
2 #define MSP_GL_PIPELINESTATE_BACKEND_H_
3
4 #include <msp/core/noncopyable.h>
5 #include "handles.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Device;
11
12 class VulkanPipelineState: public NonCopyable
13 {
14         friend class DescriptorPool;
15         friend class PipelineCache;
16         friend class VulkanCommands;
17
18 protected:
19         Device &device;
20         mutable unsigned changes = 0;
21         mutable unsigned unapplied = 0;
22         mutable VkPipeline handle = 0;
23         mutable std::vector<unsigned> descriptor_set_slots;
24         mutable unsigned first_changed_desc_set = 0;
25         mutable std::uint32_t push_const_compat = 0;
26
27         VulkanPipelineState();
28         VulkanPipelineState(VulkanPipelineState &&);
29
30         static bool can_bind_tex_level(unsigned) { return true; }
31
32         void update() const;
33         void refresh() const { if(changes) update(); }
34         std::uint64_t compute_hash() const;
35         void fill_creation_info(std::vector<char> &) const;
36         std::uint64_t compute_descriptor_set_hash(unsigned) const;
37         bool is_descriptor_set_dynamic(unsigned) const;
38         VkDescriptorSetLayout get_descriptor_set_layout(unsigned) const;
39         unsigned fill_descriptor_writes(unsigned, unsigned, std::vector<char> &) const;
40
41         void apply(VkCommandBuffer, const VulkanPipelineState *, unsigned, bool) const;
42 };
43
44 using PipelineStateBackend = VulkanPipelineState;
45
46 } // namespace GL
47 } // namespace Msp
48
49 #endif