15 #include <vsg/core/compare.h>
16 #include <vsg/state/ArrayState.h>
17 #include <vsg/state/GraphicsPipeline.h>
18 #include <vsg/state/Sampler.h>
19 #include <vsg/state/ShaderStage.h>
28 uint32_t location = 0;
29 VkFormat format = VK_FORMAT_UNDEFINED;
34 explicit operator bool()
const noexcept {
return !name.empty(); }
44 VkDescriptorType descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
45 uint32_t descriptorCount = 0;
46 VkShaderStageFlags stageFlags = 0;
51 explicit operator bool()
const noexcept {
return !name.empty(); }
59 VkPushConstantRange range;
67 std::set<std::string> defines;
84 std::vector<AttributeBinding> attributeBindings;
85 std::vector<UniformBinding> uniformBindings;
86 std::vector<PushConstantRange> pushConstantRanges;
87 std::vector<DefinesArrayState> definesArrayStates;
88 std::set<std::string> optionalDefines;
89 GraphicsPipelineStates defaultGraphicsPipelineStates;
102 void addUniformBinding(std::string name, std::string define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags,
ref_ptr<Data> data);
105 void addPushConstantRange(std::string name, std::string define, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size);
127 void read(
Input& input)
override;
128 void write(
Output& output)
const override;
142 extern VSG_DECLSPEC ref_ptr<ShaderSet> createPhongShaderSet(ref_ptr<const Options> options = {});
145 extern VSG_DECLSPEC ref_ptr<ShaderSet> createPhysicsBasedRenderingShaderSet(ref_ptr<const Options> options = {});
ShaderSet provides collection of shader related settings to provide a form of shader introspection.
Definition: ShaderSet.h:76
UniformBinding & getUniformBinding(const std::string &name)
get the UniformBinding associated with name
std::mutex mutex
mutex used be getShaderStages(..) so ensure the variants map can be used from multiple threads.
Definition: ShaderSet.h:96
void addPushConstantRange(std::string name, std::string define, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size)
add an uniform binding. Not thread safe, should only be called when initially setting up the ShaderSe...
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
void addAttributeBinding(std::string name, std::string define, uint32_t location, VkFormat format, ref_ptr< Data > data)
add an attribute binding, Not thread safe, should only be called when initially setting up the Shader...
ShaderStages getShaderStages(ref_ptr< ShaderCompileSettings > scs={})
get the ShaderStages variant that uses specified ShaderCompileSettings.
ShaderStages stages
base ShaderStages that other variants as based on.
Definition: ShaderSet.h:82
ref_ptr< ArrayState > getSuitableArrayState(const std::set< std::string > &defines) const
get the first ArrayState that has matches with defines in the specified list of defines.
const UniformBinding & getUniformBinding(const std::string &name) const
get the const UniformBinding associated with name
std::map< ref_ptr< ShaderCompileSettings >, ShaderStages, DereferenceLess > variants
variants of the rootShaderModule compiled for different combinations of ShaderCompileSettings
Definition: ShaderSet.h:93
AttributeBinding & getAttributeBinding(const std::string &name)
get the AttributeBinding associated with name
void addUniformBinding(std::string name, std::string define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, ref_ptr< Data > data)
add an uniform binding. Not thread safe, should only be called when initially setting up the ShaderSe...
const AttributeBinding & getAttributeBinding(const std::string &name) const
get the const AttributeBinding associated with name
Definition: ShaderSet.h:25
Definition: ShaderSet.h:66
less functor for comparing ref_ptr<Object> typically used with std::set<> etc.
Definition: compare.h:107
Definition: ShaderSet.h:56