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