MythTV  master
mythshadervulkan.h
Go to the documentation of this file.
1 #ifndef MYTHSHADERVULKAN_H
2 #define MYTHSHADERVULKAN_H
3 
4 // MythTV
6 
7 using MythShaderMap = std::map<int, std::pair<QString, std::vector<uint32_t>>>;
8 using MythGLSLStage = std::pair<VkShaderStageFlags, QString>;
9 using MythSPIRVStage = std::pair<VkShaderStageFlags, const std::vector<uint32_t>>;
10 using MythVertexAttrs = std::vector<VkVertexInputAttributeDescription>;
11 using MythSetLayout = std::pair<int, VkDescriptorSetLayoutBinding>;
12 using MythStageLayout = std::vector<MythSetLayout>;
13 using MythBindingDesc = std::tuple<VkPrimitiveTopology,
15  VkVertexInputBindingDescription,
17  VkPushConstantRange>;
18 using MythBindingMap = std::map<int, MythBindingDesc>;
19 
21 {
22  public:
24  const std::vector<int> &Stages,
25  const MythShaderMap *Sources = nullptr,
26  const MythBindingMap *Bindings = nullptr);
28 
29  VkPrimitiveTopology GetTopology () const;
30  VkPipelineLayout GetPipelineLayout (void) const;
31  const MythVertexAttrs& GetVertexAttributes (void) const;
32  const VkVertexInputBindingDescription& GetVertexBindingDesc(void) const;
33  const std::vector<VkPipelineShaderStageCreateInfo>& Stages(void) const;
34  const std::vector<VkDescriptorPoolSize>& GetPoolSizes(size_t Set) const;
35  VkDescriptorSetLayout GetDescSetLayout(size_t Set) const;
36 
37 #ifdef USING_GLSLANG
38  static bool InitGLSLang(bool Release = false);
39 #endif
40 
41  protected:
43  const std::vector<int> &Stages,
44  const MythShaderMap *Sources = nullptr,
45  const MythBindingMap *Bindings = nullptr);
46 
47  private:
48  Q_DISABLE_COPY(MythShaderVulkan)
49 #ifdef USING_GLSLANG
50  bool CreateShaderFromGLSL (const std::vector<MythGLSLStage> &Stages);
51 #endif
52  bool CreateShaderFromSPIRV (const std::vector<MythSPIRVStage> &Stages);
53 
54  VkPrimitiveTopology m_topology { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP };
55  VkVertexInputBindingDescription m_vertexBindingDesc { };
57  std::vector<VkPipelineShaderStageCreateInfo> m_stages;
58  std::vector<uint32_t*> m_spirv;
59  VkPipelineLayout m_pipelineLayout { MYTH_NULL_DISPATCH };
60 
61  // these are per set
62  std::vector<VkDescriptorSetLayout> m_descriptorSetLayouts;
63  std::vector<std::vector<VkDescriptorPoolSize>> m_descriptorPoolSizes;
64 };
65 
66 #endif
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythBindingDesc
std::tuple< VkPrimitiveTopology, MythStageLayout, VkVertexInputBindingDescription, MythVertexAttrs, VkPushConstantRange > MythBindingDesc
Definition: mythshadervulkan.h:17
MythVulkanObject
Definition: mythrendervulkan.h:32
MythShaderVulkan::m_descriptorSetLayouts
std::vector< VkDescriptorSetLayout > m_descriptorSetLayouts
Definition: mythshadervulkan.h:62
MYTH_NULL_DISPATCH
#define MYTH_NULL_DISPATCH
Definition: mythrendervulkan.h:29
MythSetLayout
std::pair< int, VkDescriptorSetLayoutBinding > MythSetLayout
Definition: mythshadervulkan.h:11
MythVulkanObject::Create
static MythVulkanObject * Create(MythRenderVulkan *Render)
Definition: mythrendervulkan.cpp:16
MythSPIRVStage
std::pair< VkShaderStageFlags, const std::vector< uint32_t > > MythSPIRVStage
Definition: mythshadervulkan.h:9
MythShaderVulkan::m_stages
std::vector< VkPipelineShaderStageCreateInfo > m_stages
Definition: mythshadervulkan.h:57
MythShaderVulkan::m_spirv
std::vector< uint32_t * > m_spirv
Definition: mythshadervulkan.h:58
MythStageLayout
std::vector< MythSetLayout > MythStageLayout
Definition: mythshadervulkan.h:12
MythBindingMap
std::map< int, MythBindingDesc > MythBindingMap
Definition: mythshadervulkan.h:18
MythShaderVulkan::m_vertexAttributes
MythVertexAttrs m_vertexAttributes
Definition: mythshadervulkan.h:56
MythShaderVulkan::m_descriptorPoolSizes
std::vector< std::vector< VkDescriptorPoolSize > > m_descriptorPoolSizes
Definition: mythshadervulkan.h:63
MythGLSLStage
std::pair< VkShaderStageFlags, QString > MythGLSLStage
Definition: mythshadervulkan.h:8
MythShaderMap
std::map< int, std::pair< QString, std::vector< uint32_t > >> MythShaderMap
Definition: mythshadervulkan.h:7
MythVertexAttrs
std::vector< VkVertexInputAttributeDescription > MythVertexAttrs
Definition: mythshadervulkan.h:10
mythrendervulkan.h
MythShaderVulkan
Creates shader objects suitable for use with the Vulkan API.
Definition: mythshadervulkan.h:20