HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderFunctionDesc.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_SHADERFUNCTIONDESC_H
26 #define PXR_IMAGING_HGI_SHADERFUNCTIONDESC_H
27 
28 #include "pxr/pxr.h"
29 #include "pxr/imaging/hgi/api.h"
30 #include "pxr/imaging/hgi/enums.h"
31 #include "pxr/imaging/hgi/types.h"
32 
33 #include <string>
34 #include <vector>
35 
37 
38 
39 /// \struct HgiShaderFunctionTextureDesc
40 ///
41 /// Describes a texture to be passed into a shader
42 ///
43 /// <ul>
44 /// <li>nameInShader:
45 /// The name written from the codegen into shader file for the texture.</li>
46 /// <li>dimensions:
47 /// 1d, 2d or 3d texture declaration.</li>
48 /// <li>format
49 /// Format of the texture. This is required in APIs where sampler types depend
50 /// on the texture (e.g., GL) </li>
51 /// </ul>
52 ///
54 {
55  HGI_API
57 
59  uint32_t dimensions;
61 };
62 
64  std::vector<HgiShaderFunctionTextureDesc>;
65 
66 HGI_API
67 bool operator==(
69  const HgiShaderFunctionTextureDesc& rhs);
70 
71 HGI_API
72 bool operator!=(
74  const HgiShaderFunctionTextureDesc& rhs);
75 
76 /// \struct HgiShaderFunctionBufferDesc
77 ///
78 /// Describes a buffer to be passed into a shader
79 ///
80 /// <ul>
81 /// <li>nameInShader:
82 /// The name written from the codegen into shader file for the texture.</li>
83 /// <li>type:
84 /// Type of the param within the shader file.</li>
85 /// </ul>
86 ///
88 {
89  HGI_API
91 
94 };
95 
97  std::vector<HgiShaderFunctionBufferDesc>;
98 
99 HGI_API
100 bool operator==(
101  const HgiShaderFunctionBufferDesc& lhs,
102  const HgiShaderFunctionBufferDesc& rhs);
103 
104 HGI_API
105 bool operator!=(
106  const HgiShaderFunctionBufferDesc& lhs,
107  const HgiShaderFunctionBufferDesc& rhs);
108 
109 /// \struct HgiShaderFunctionParamDesc
110 ///
111 /// Describes a constant param passed into a shader
112 ///
113 /// <ul>
114 /// <li>nameInShader:
115 /// The name written from the codegen into the shader file for the param.</li>
116 /// <li>type:
117 /// Type of the param within the shader file.</li>
118 /// <li>role:
119 /// Optionally a role can be specified, like position, uv, color.</li>
120 /// <li>attribute:
121 /// Optionally an attribute can be specified, like versions or addresses.</li>
122 /// <li>attributeIndex:
123 /// Used in metal, to specify indicies of attributes.</li>
124 /// </ul>
125 ///
127 {
128  HGI_API
130 
136 };
137 
139  std::vector<HgiShaderFunctionParamDesc>;
140 
141 HGI_API
142 bool operator==(
143  const HgiShaderFunctionParamDesc& lhs,
144  const HgiShaderFunctionParamDesc& rhs);
145 
146 HGI_API
147 bool operator!=(
148  const HgiShaderFunctionParamDesc& lhs,
149  const HgiShaderFunctionParamDesc& rhs);
150 
151 /// \struct HgiShaderFunctionDesc
152 ///
153 /// Describes the properties needed to create a GPU shader function.
154 ///
155 /// <ul>
156 /// <li>debugName:
157 /// This label can be applied as debug label for gpu debugging.</li>
158 /// <li>shaderStage:
159 /// The shader stage this function represents.</li>
160 /// <li>shaderCode:
161 /// The ascii shader code used to compile the shader.</li>
162 /// <li>textures:
163 /// List of texture descriptions to be passed into a shader.</li>
164 /// <li>buffers:
165 /// List of buffer descriptions to be passed into a shader.</li>
166 /// <li>constantParams:
167 /// List of descriptions of constant params passed into a shader.</li>
168 /// <li>stageInputs:
169 /// List of descriptions of the inputs of the shader.</li>
170 /// <li>stageOutputs:
171 /// List of descriptions of the outputs of the shader.</li>
172 /// </ul>
173 ///
175 {
176  HGI_API
180  const char* shaderCode;
181  std::vector<HgiShaderFunctionTextureDesc> textures;
182  std::vector<HgiShaderFunctionBufferDesc> buffers;
183  std::vector<HgiShaderFunctionParamDesc> constantParams;
184  std::vector<HgiShaderFunctionParamDesc> stageInputs;
185  std::vector<HgiShaderFunctionParamDesc> stageOutputs;
186 };
187 
189  std::vector<HgiShaderFunctionDesc>;
190 
191 HGI_API
192 bool operator==(
193  const HgiShaderFunctionDesc& lhs,
194  const HgiShaderFunctionDesc& rhs);
195 
196 HGI_API
197 bool operator!=(
198  const HgiShaderFunctionDesc& lhs,
199  const HgiShaderFunctionDesc& rhs);
200 
201 /// Adds texture descriptor to given shader function descriptor.
202 HGI_API
203 void
205  HgiShaderFunctionDesc *desc,
206  const std::string &nameInShader,
207  uint32_t dimensions = 2,
209 
210 /// Adds buffer descriptor to given shader function descriptor.
211 HGI_API
212 void
214  HgiShaderFunctionDesc *desc,
215  const std::string &nameInShader,
216  const std::string &type);
217 
218 /// Adds constant function param descriptor to given shader function
219 /// descriptor.
220 HGI_API
221 void
223  HgiShaderFunctionDesc *desc,
224  const std::string &nameInShader,
225  const std::string &type,
226  const std::string &role = std::string(),
227  const std::string &attribute = std::string(),
228  const std::string &attributeIndex = std::string());
229 
230 /// Adds stage input function param descriptor to given shader function
231 /// descriptor.
232 HGI_API
233 void
235  HgiShaderFunctionDesc *desc,
236  const std::string &nameInShader,
237  const std::string &type,
238  const std::string &role = std::string(),
239  const std::string &attribute = std::string(),
240  const std::string &attributeIndex = std::string());
241 
242 /// Adds stage output function param descriptor to given shader function
243 /// descriptor.
244 HGI_API
245 void
247  HgiShaderFunctionDesc *desc,
248  const std::string &nameInShader,
249  const std::string &type,
250  const std::string &role = std::string(),
251  const std::string &attribute = std::string(),
252  const std::string &attributeIndex = std::string());
253 
255 
256 #endif
std::vector< HgiShaderFunctionParamDesc > HgiShaderFunctionParamDescVector
std::vector< HgiShaderFunctionParamDesc > constantParams
std::vector< HgiShaderFunctionTextureDesc > textures
std::vector< HgiShaderFunctionParamDesc > stageOutputs
HGI_API void HgiShaderFunctionAddStageOutput(HgiShaderFunctionDesc *desc, const std::string &nameInShader, const std::string &type, const std::string &role=std::string(), const std::string &attribute=std::string(), const std::string &attributeIndex=std::string())
std::vector< HgiShaderFunctionTextureDesc > HgiShaderFunctionTextureDescVector
HgiFormat
Definition: types.h:45
std::vector< HgiShaderFunctionDesc > HgiShaderFunctionDescVector
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
HGI_API HgiShaderFunctionDesc()
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:570
HGI_API void HgiShaderFunctionAddBuffer(HgiShaderFunctionDesc *desc, const std::string &nameInShader, const std::string &type)
Adds buffer descriptor to given shader function descriptor.
HGI_API void HgiShaderFunctionAddConstantParam(HgiShaderFunctionDesc *desc, const std::string &nameInShader, const std::string &type, const std::string &role=std::string(), const std::string &attribute=std::string(), const std::string &attributeIndex=std::string())
HGI_API void HgiShaderFunctionAddStageInput(HgiShaderFunctionDesc *desc, const std::string &nameInShader, const std::string &type, const std::string &role=std::string(), const std::string &attribute=std::string(), const std::string &attributeIndex=std::string())
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
#define HGI_API
Definition: api.h:40
HGI_API HgiShaderFunctionParamDesc()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
std::vector< HgiShaderFunctionBufferDesc > HgiShaderFunctionBufferDescVector
std::vector< HgiShaderFunctionBufferDesc > buffers
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::vector< HgiShaderFunctionParamDesc > stageInputs
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
HgiBits HgiShaderStage
Definition: enums.h:292
HGI_API void HgiShaderFunctionAddTexture(HgiShaderFunctionDesc *desc, const std::string &nameInShader, uint32_t dimensions=2, const HgiFormat &format=HgiFormatFloat32Vec4)
Adds texture descriptor to given shader function descriptor.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:556