]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/pipelinestate_backend.h
Apply only changed parts of VulkanPipelineState
[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 PipelineCache;
15         friend class VulkanCommands;
16
17 protected:
18         Device &device;
19         mutable unsigned changes = 0;
20         mutable unsigned unapplied = 0;
21         mutable VkPipeline handle;
22         mutable std::vector<VkDescriptorSet> descriptor_set_handles;
23
24         VulkanPipelineState();
25         VulkanPipelineState(VulkanPipelineState &&);
26
27         static bool can_bind_tex_level(unsigned) { return true; }
28
29         void update() const;
30         void refresh() const { if(changes) update(); }
31         std::uint64_t compute_hash() const;
32         void fill_creation_info(std::vector<char> &) const;
33         std::uint64_t compute_descriptor_set_hash(unsigned) const;
34         VkDescriptorSetLayout get_descriptor_set_layout(unsigned) const;
35         unsigned fill_descriptor_writes(unsigned, std::vector<char> &) const;
36
37         void apply(VkCommandBuffer, const VulkanPipelineState *, unsigned, bool) const;
38 };
39
40 using PipelineStateBackend = VulkanPipelineState;
41
42 } // namespace GL
43 } // namespace Msp
44
45 #endif