]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/pipelinestate_backend.h
Support compute shaders and compute operations
[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 class VulkanCommandRecorder;
12
13 class VulkanPipelineState: public NonCopyable
14 {
15         friend class DescriptorPool;
16         friend class PipelineCache;
17         friend class VulkanCommands;
18
19 protected:
20         Device &device;
21         mutable unsigned changes = 0;
22         mutable unsigned unapplied = 0;
23         mutable VkPipeline handle = 0;
24         mutable std::vector<unsigned> descriptor_set_slots;
25         mutable unsigned first_changed_desc_set = 0;
26         mutable std::uint32_t push_const_compat = 0;
27
28         VulkanPipelineState();
29         VulkanPipelineState(VulkanPipelineState &&);
30
31         static bool can_bind_tex_level(unsigned) { return true; }
32
33         void update() const;
34         void refresh() const { if(changes) update(); }
35         std::uint64_t compute_hash() const;
36         void fill_creation_info(std::vector<char> &) const;
37         void fill_graphics_creation_info(std::vector<char> &) const;
38         void fill_compute_creation_info(std::vector<char> &) const;
39         std::uint64_t compute_descriptor_set_hash(unsigned) const;
40         bool is_descriptor_set_dynamic(unsigned) const;
41         VkDescriptorSetLayout get_descriptor_set_layout(unsigned) const;
42         unsigned fill_descriptor_writes(unsigned, unsigned, std::vector<char> &) const;
43
44         void synchronize_resources(bool) const;
45         void apply(const VulkanCommandRecorder &, const VulkanPipelineState *, unsigned, bool) const;
46 };
47
48 using PipelineStateBackend = VulkanPipelineState;
49
50 } // namespace GL
51 } // namespace Msp
52
53 #endif