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;
 
   83         void read(
Input& input) 
override;
 
   84         void write(
Output& output) 
const override;
 
   99         void read(
Input& input) 
override;
 
  100         void write(
Output& output) 
const override;
 
  120         std::vector<AttributeBinding> attributeBindings;
 
  121         std::vector<DescriptorBinding> descriptorBindings;
 
  122         std::vector<PushConstantRange> pushConstantRanges;
 
  123         std::vector<DefinesArrayState> definesArrayStates; 
 
  124         std::set<std::string> optionalDefines;
 
  125         GraphicsPipelineStates defaultGraphicsPipelineStates;
 
  126         std::vector<ref_ptr<CustomDescriptorSetBinding>> customDescriptorSetBindings;
 
  139         void addDescriptorBinding(
const std::string& name, 
const std::string& define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, 
ref_ptr<Data> data);
 
  141         [[deprecated(
"use addDescriptorBinding(..)")]] 
void addUniformBinding(
const std::string& name, 
const std::string& define, uint32_t set, uint32_t binding, VkDescriptorType descriptorType, uint32_t descriptorCount, VkShaderStageFlags stageFlags, 
ref_ptr<Data> data) { addDescriptorBinding(name, define, set, binding, descriptorType, descriptorCount, stageFlags, data); }
 
  144         void addPushConstantRange(
const std::string& name, 
const std::string& define, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size);
 
  158         [[deprecated(
"use getDescriptorBinding(..)")]] 
DescriptorBinding& getUniformBinding(
const std::string& name) { 
return getDescriptorBinding(name); }
 
  160         [[deprecated(
"use getDescriptorBinding(..)")]] 
const DescriptorBinding& getUnifomrBinding(
const std::string& name)
 const { 
return getDescriptorBinding(name); }
 
  192         void read(
Input& input) 
override;
 
  193         void write(
Output& output) 
const override;
 
  207     extern VSG_DECLSPEC ref_ptr<ShaderSet> createPhongShaderSet(ref_ptr<const Options> options = {});
 
  210     extern VSG_DECLSPEC ref_ptr<ShaderSet> createPhysicsBasedRenderingShaderSet(ref_ptr<const Options> options = {});
 
DescriptorSetLayout encapsulates VkDescriptorSetLayout and VkDescriptorSetLayoutCreateInfo settings u...
Definition: DescriptorSetLayout.h:28
PipelineLayout encapsulates VkPipelineLayout and the VkPipelineLayoutCreateInfo settings used to set ...
Definition: PipelineLayout.h:27
ShaderSet provides a collection of shader related settings to provide a form of shader introspection.
Definition: ShaderSet.h:112
std::pair< uint32_t, uint32_t > descriptorSetRange() const
return the <minimum_set, maximum_set+1> range of set numbers encompassing DescriptorBindings
std::mutex mutex
mutex used by getShaderStages(..) to ensure the variants map can be used from multiple threads.
Definition: ShaderSet.h:133
const DescriptorBinding & getDescriptorBinding(const std::string &name) const
get the const DescriptorBinding associated with name
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,...
virtual bool compatibleDescriptorSetLayout(const DescriptorSetLayout &dsl, const std::set< std::string > &defines, uint32_t set) const
return true of specified descriptor set layout is compatible with what is required for this ShaderSet
virtual ref_ptr< PipelineLayout > createPipelineLayout(const std::set< std::string > &defines, std::pair< uint32_t, uint32_t > range) const
DescriptorBinding & getDescriptorBinding(const std::string &name)
get the DescriptorBinding associated with name
void addPushConstantRange(const std::string &name, const std::string &define, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size)
add a push constant range. Not thread safe, should only be called when initially setting up the Shade...
virtual ref_ptr< DescriptorSetLayout > createDescriptorSetLayout(const std::set< std::string > &defines, uint32_t set) const
create the descriptor set layout.
ShaderStages getShaderStages(ref_ptr< ShaderCompileSettings > scs={})
get the ShaderStages variant that uses specified ShaderCompileSettings.
void addDescriptorBinding(const std::string &name, const 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...
ref_ptr< PipelineLayout > createPipelineLayout(const std::set< std::string > &defines)
create the pipeline layout for all descriptor sets enabled by specified defines or required by defaul...
Definition: ShaderSet.h:181
ShaderStages stages
base ShaderStages that other variants are based on.
Definition: ShaderSet.h:118
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.
std::map< ref_ptr< ShaderCompileSettings >, ShaderStages, DereferenceLess > variants
variants of the rootShaderModule compiled for different combinations of ShaderCompileSettings
Definition: ShaderSet.h:130
AttributeBinding & getAttributeBinding(const std::string &name)
get the AttributeBinding associated with name
virtual bool compatiblePipelineLayout(const PipelineLayout &layout, const std::set< std::string > &defines) const
return true of specified pipline layout is compatible with what is required for this ShaderSet
void addAttributeBinding(const std::string &name, const 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...
const AttributeBinding & getAttributeBinding(const std::string &name) const
get the const AttributeBinding associated with name
Definition: ShaderSet.h:25
Base class for specifying custom DescriptorSetLayout and StateCommand.
Definition: ShaderSet.h:76
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,...
Definition: ShaderSet.h:66
less functor for comparing ref_ptr<Object> typically used with std::set<> etc.
Definition: compare.h:107
Definition: ShaderSet.h:39
Definition: ShaderSet.h:56
Custom state binding class for providing the DescriptorSetLayout and StateCommand required to pass vi...
Definition: ShaderSet.h:94
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,...