HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderSection.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_IMAGING_HGI_SHADERSECTION_H
26 #define PXR_IMAGING_HGI_SHADERSECTION_H
27 
28 #include "pxr/pxr.h"
29 #include "pxr/imaging/hgi/api.h"
30 #include <memory>
31 #include <ostream>
32 #include <string>
33 #include <vector>
34 
36 
37 //struct to hold attribute definitions
39 {
42 };
43 
45  std::vector<HgiShaderSectionAttribute>;
46 
47 /// \class HgiShaderSection
48 ///
49 /// A base class for a Shader Section.
50 /// In its simplest form then it is a construct that knows
51 /// how to declare itself, define and pass as param.
52 /// Can be subclassed to add more behaviour for complex cases
53 /// and to hook into the visitor tree.
54 ///
56 {
57 public:
58  HGI_API
59  virtual ~HgiShaderSection();
60 
61  /// Write out the type, shader section does not hold a type
62  /// string as how a type is defined is fully controlled
63  /// by sub classes and no assumptions are made
64  HGI_API
65  virtual void WriteType(std::ostream& ss) const;
66 
67  /// Writes the unique name of an instance of the section
68  HGI_API
69  virtual void WriteIdentifier(std::ostream& ss) const;
70 
71  /// Writes a decleration statement for a member or in global scope
72  HGI_API
73  virtual void WriteDeclaration(std::ostream& ss) const;
74 
75  /// Writes the section as a parameter to a function
76  HGI_API
77  virtual void WriteParameter(std::ostream& ss) const;
78 
79  HGI_API
81 
82 protected:
83  HGI_API
84  explicit HgiShaderSection(
85  const std::string &identifier,
86  const HgiShaderSectionAttributeVector& attributes = {},
87  const std::string &defaultValue = std::string());
88 
89  HGI_API
90  const std::string& _GetDefaultValue() const;
91 
92 private:
93  const std::string _identifierVar;
94  const HgiShaderSectionAttributeVector _attributes;
95  const std::string _defaultValue;
96 };
97 
99 
100 #endif
HGI_API HgiShaderSection(const std::string &identifier, const HgiShaderSectionAttributeVector &attributes={}, const std::string &defaultValue=std::string())
virtual HGI_API void WriteParameter(std::ostream &ss) const
Writes the section as a parameter to a function.
virtual HGI_API void WriteType(std::ostream &ss) const
std::vector< HgiShaderSectionAttribute > HgiShaderSectionAttributeVector
Definition: shaderSection.h:45
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
virtual HGI_API void WriteDeclaration(std::ostream &ss) const
Writes a decleration statement for a member or in global scope.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual HGI_API ~HgiShaderSection()
HGI_API const std::string & _GetDefaultValue() const
virtual HGI_API void WriteIdentifier(std::ostream &ss) const
Writes the unique name of an instance of the section.
HGI_API const HgiShaderSectionAttributeVector & GetAttributes() const