Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
VulkanComputePipeline.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #ifdef USING_VULKAN
6 
7 #include <ThirdParty/Vulkan/Include/vulkan/vulkan.h>
8 #include <ThirdParty/EASTL-master/include/EASTL/string.h>
9 #include <ThirdParty/EASTL-master/include/EASTL/vector.h>
10 
11 namespace Engine {
12  class VulkanLogicalDevice;
13  class VulkanRenderer;
14 
15  class VulkanComputePipeline
16  {
17  public:
18  typedef size_t descriptorSetHandle;
19 
20  VulkanComputePipeline(VulkanLogicalDevice* logicalDevice);
21  ~VulkanComputePipeline();
22 
23  void SetComputeShader(eastl::string name);
24 
25  void AddSpecializationMapEntry(uint32_t constantID, eastl::vector<uint32_t> data);
26 
27  void AddDescriptorSetBinding(descriptorSetHandle set, uint32_t binding, VkDescriptorType type, uint32_t descriptorCount, VkShaderStageFlags shaderStage, const VkSampler* immutableSamplers);
28 
29  descriptorSetHandle CreateDescriptorSet();
30  descriptorSetHandle AddDescriptorSetLayout(VkDescriptorSetLayout layout);
31 
32  VkDescriptorSetLayout GetDescriptorSetLayout(descriptorSetHandle handle);
33 
34  void AddPushConstantRange(VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size);
35 
36  VkPipelineLayout GetPipelineLayout() const;
37 
38  void Compile();
39 
40  VkPipeline GetPipeline() const;
41 
42  protected:
43  struct DescriptorSet {
44  eastl::vector<VkDescriptorSetLayoutBinding> descriptionSetLayoutBindings;
45  VkDescriptorSetLayout descriptorSet;
46  bool external;
47  };
48 
49  eastl::vector<char> computeShaderData_;
50 
51  VkShaderModule computeShader_;
52 
53  VkPipeline pipeline_;
54 
55  VkSpecializationInfo computeShaderSpecializationInfo_;
56 
57  eastl::vector<VkSpecializationMapEntry> specializationMapEntries_;
58  eastl::vector<uint32_t> specializationData_;
59 
60  eastl::vector<DescriptorSet> descriptorSets_;
61 
62  eastl::vector<VkPushConstantRange> pushConstantRanges_;
63 
64  VkPipelineLayout pipelineLayout_;
65 
66  VkPipelineLayoutCreateInfo pipelineLayoutInfo_;
67 
68  VulkanLogicalDevice * device_;
69  };
70 
71 } // namespace Engine
72 
73 #endif // USING_VULKAN