All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderSection.h
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 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 //struct to hold attribute definitions
38 struct HgiShaderSectionAttribute
39 {
40  std::string identifier;
41  std::string index;
42 };
43 
44 using HgiShaderSectionAttributeVector =
45  std::vector<HgiShaderSectionAttribute>;
46 
56 {
57 public:
58  HGI_API
59  virtual ~HgiShaderSection();
60 
64  HGI_API
65  virtual void WriteType(std::ostream& ss) const;
66 
68  HGI_API
69  virtual void WriteIdentifier(std::ostream& ss) const;
70 
72  HGI_API
73  virtual void WriteDeclaration(std::ostream& ss) const;
74 
76  HGI_API
77  virtual void WriteParameter(std::ostream& ss) const;
78 
79  HGI_API
80  const HgiShaderSectionAttributeVector& GetAttributes() const;
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 
98 PXR_NAMESPACE_CLOSE_SCOPE
99 
100 #endif
virtual HGI_API void WriteIdentifier(std::ostream &ss) const
Writes the unique name of an instance of the section.
virtual HGI_API void WriteDeclaration(std::ostream &ss) const
Writes a decleration statement for a member or in global scope.
virtual HGI_API void WriteType(std::ostream &ss) const
Write out the type, shader section does not hold a type string as how a type is defined is fully cont...
virtual HGI_API void WriteParameter(std::ostream &ss) const
Writes the section as a parameter to a function.
A base class for a Shader Section.
Definition: shaderSection.h:55