vsg: include/vsg/state/ShaderStage.h Source File

vsg 1.1.3 VulkanSceneGraph library

Loading...
Searching...
No Matches
ShaderStage.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/state/ShaderModule.h>
16
17namespace vsg
18{
19 // forward declare
20 class Context;
21
23 class VSG_DECLSPEC ShaderStage : public Inherit<Object, ShaderStage>
24 {
25 public:
26 ShaderStage();
27 ShaderStage(VkShaderStageFlagBits stage, const std::string& entryPointName, ref_ptr<ShaderModule> shaderModule);
28 ShaderStage(VkShaderStageFlagBits stage, const std::string& entryPointName, const std::string& source, ref_ptr<ShaderCompileSettings> hints = {});
29 ShaderStage(VkShaderStageFlagBits stage, const std::string& entryPointName, const ShaderModule::SPIRV& spirv);
30 ShaderStage(VkShaderStageFlagBits stage, const std::string& entryPointName, const std::string& source, const ShaderModule::SPIRV& spirv);
31
32 using SpecializationConstants = std::map<uint32_t, vsg::ref_ptr<vsg::Data>>;
33
35 Mask mask = MASK_ALL;
36
38 VkPipelineShaderStageCreateFlags flags = 0;
39 VkShaderStageFlagBits stage = {};
40 ref_ptr<ShaderModule> module;
41 std::string entryPointName;
42 SpecializationConstants specializationConstants;
43
44 static ref_ptr<ShaderStage> read(VkShaderStageFlagBits stage, const std::string& entryPointName, const Path& filename, ref_ptr<const Options> options = {});
45 static ref_ptr<ShaderStage> read(VkShaderStageFlagBits stage, const std::string& entryPointName, std::istream& fin, ref_ptr<const Options> options = {});
46
47 int compare(const Object& rhs_object) const override;
48
49 void read(Input& input) override;
50 void write(Output& output) const override;
51
52 void apply(Context& context, VkPipelineShaderStageCreateInfo& stageInfo) const;
53
54 // compile the Vulkan object, context parameter used for Device
55 void compile(Context& context);
56
57 protected:
58 virtual ~ShaderStage();
59 };
60 VSG_type_name(vsg::ShaderStage);
61
62 using ShaderStages = std::vector<ref_ptr<ShaderStage>>;
63
64} // namespace vsg
vsg::Context
Definition Context.h:67
vsg::Inherit
Definition Inherit.h:28
vsg::Input
Definition Input.h:44
vsg::Object
Definition Object.h:60
vsg::Output
Definition Output.h:41
vsg::Path
Definition Path.h:34
vsg::ShaderStage
ShaderStage encapsulates VkPipelineShaderStageCreateInfo settings passed when setting up GraphicsPipe...
Definition ShaderStage.h:24
vsg::ShaderStage::compare
int compare(const Object &rhs_object) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
vsg::ref_ptr
Definition ref_ptr.h:22
vsg::spirv
ReaderWriter for reading and writing spirv shader files.
Definition spirv.h:35