shaderFunctionDesc.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_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 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 
66 {
67  HGI_API
69 
70  std::string nameInShader;
71  uint32_t dimensions;
72  HgiFormat format;
73  HgiShaderTextureType textureType;
74  uint32_t bindIndex;
75  size_t arraySize;
76  bool writable;
77 };
78 
79 using HgiShaderFunctionTextureDescVector =
80  std::vector<HgiShaderFunctionTextureDesc>;
81 
82 HGI_API
83 bool operator==(
85  const HgiShaderFunctionTextureDesc& rhs);
86 
87 HGI_API
88 bool operator!=(
90  const HgiShaderFunctionTextureDesc& rhs);
91 
112 {
113  HGI_API
115 
116  std::string nameInShader;
117  std::string type;
118  uint32_t bindIndex;
119  uint32_t arraySize;
120  HgiBindingType binding;
121  bool writable;
122 };
123 
124 using HgiShaderFunctionBufferDescVector =
125  std::vector<HgiShaderFunctionBufferDesc>;
126 
127 HGI_API
128 bool operator==(
129  const HgiShaderFunctionBufferDesc& lhs,
130  const HgiShaderFunctionBufferDesc& rhs);
131 
132 HGI_API
133 bool operator!=(
134  const HgiShaderFunctionBufferDesc& lhs,
135  const HgiShaderFunctionBufferDesc& rhs);
136 
164 {
165  HGI_API
167 
168  std::string nameInShader;
169  std::string type;
170  int32_t location;
171  int32_t interstageSlot;
172  HgiInterpolationType interpolation;
173  HgiSamplingType sampling;
174  HgiStorageType storage;
175  std::string role;
176  std::string arraySize;
177 };
178 
179 using HgiShaderFunctionParamDescVector =
180  std::vector<HgiShaderFunctionParamDesc>;
181 
182 HGI_API
183 bool operator==(
184  const HgiShaderFunctionParamDesc& lhs,
185  const HgiShaderFunctionParamDesc& rhs);
186 
187 HGI_API
188 bool operator!=(
189  const HgiShaderFunctionParamDesc& lhs,
190  const HgiShaderFunctionParamDesc& rhs);
191 
211 {
212  HGI_API
214 
215  struct Member {
216  std::string name;
217  std::string type;
218  };
219  using MemberVector = std::vector<Member>;
220 
221  std::string blockName;
222  std::string instanceName;
223  MemberVector members;
224  std::string arraySize;
225  int32_t interstageSlot;
226 };
227 
228 using HgiShaderFunctionParamBlockDescVector =
229  std::vector<HgiShaderFunctionParamBlockDesc>;
230 
231 HGI_API
232 bool operator==(
235 
236 HGI_API
237 bool operator!=(
240 
241 HGI_API
242 bool operator==(
243  const HgiShaderFunctionParamBlockDesc::Member& lhs,
244  const HgiShaderFunctionParamBlockDesc::Member& rhs);
245 
246 HGI_API
247 bool operator!=(
248  const HgiShaderFunctionParamBlockDesc::Member& lhs,
249  const HgiShaderFunctionParamBlockDesc::Member& rhs);
250 
268 {
269  HGI_API
271 
272  GfVec3i localSize;
273 };
274 
275 HGI_API
276 bool operator==(
277  const HgiShaderFunctionComputeDesc& lhs,
278  const HgiShaderFunctionComputeDesc& rhs);
279 
280 HGI_API
281 bool operator!=(
282  const HgiShaderFunctionComputeDesc& lhs,
283  const HgiShaderFunctionComputeDesc& rhs);
284 
303 {
304  enum class PatchType { Triangles, Quads, Isolines };
305  enum class Spacing { Equal, FractionalEven, FractionalOdd };
306  enum class Ordering { CW, CCW };
307  HGI_API
309 
310  PatchType patchType;
311  Spacing spacing;
312  Ordering ordering;
313  std::string numVertsPerPatchIn;
314  std::string numVertsPerPatchOut;
315 };
316 
317 HGI_API
318 bool operator==(
321 
322 HGI_API
323 bool operator!=(
326 
342 {
343  enum class InPrimitiveType {
344  Points, Lines, LinesAdjacency, Triangles, TrianglesAdjacency };
345  enum class OutPrimitiveType {
346  Points, LineStrip, TriangleStrip };
347 
348  HGI_API
350 
351  InPrimitiveType inPrimitiveType;
352  OutPrimitiveType outPrimitiveType;
353  std::string outMaxVertices;
354 };
355 
356 HGI_API
357 bool operator==(
359  const HgiShaderFunctionGeometryDesc& rhs);
360 
361 HGI_API
362 bool operator!=(
364  const HgiShaderFunctionGeometryDesc& rhs);
365 
376 {
377  HGI_API
379 
380  bool earlyFragmentTests;
381 
382 };
383 
384 HGI_API
385 bool operator==(
387  const HgiShaderFunctionFragmentDesc& rhs);
388 
389 HGI_API
390 bool operator!=(
392  const HgiShaderFunctionFragmentDesc& rhs);
393 
438 {
439  HGI_API
441  std::string debugName;
442  HgiShaderStage shaderStage;
443  const char *shaderCodeDeclarations;
444  const char *shaderCode;
445  std::string *generatedShaderCodeOut;
446  std::vector<HgiShaderFunctionTextureDesc> textures;
447  std::vector<HgiShaderFunctionBufferDesc> buffers;
448  std::vector<HgiShaderFunctionParamDesc> constantParams;
449  std::vector<HgiShaderFunctionParamDesc> stageGlobalMembers;
450  std::vector<HgiShaderFunctionParamDesc> stageInputs;
451  std::vector<HgiShaderFunctionParamDesc> stageOutputs;
452  std::vector<HgiShaderFunctionParamBlockDesc> stageInputBlocks;
453  std::vector<HgiShaderFunctionParamBlockDesc> stageOutputBlocks;
454  HgiShaderFunctionComputeDesc computeDescriptor;
455  HgiShaderFunctionTessellationDesc tessellationDescriptor;
456  HgiShaderFunctionGeometryDesc geometryDescriptor;
457  HgiShaderFunctionFragmentDesc fragmentDescriptor;
458 };
459 
460 using HgiShaderFunctionDescVector =
461  std::vector<HgiShaderFunctionDesc>;
462 
463 HGI_API
464 bool operator==(
465  const HgiShaderFunctionDesc& lhs,
466  const HgiShaderFunctionDesc& rhs);
467 
468 HGI_API
469 bool operator!=(
470  const HgiShaderFunctionDesc& lhs,
471  const HgiShaderFunctionDesc& rhs);
472 
474 HGI_API
475 void
476 HgiShaderFunctionAddTexture(
477  HgiShaderFunctionDesc *desc,
478  const std::string &nameInShader,
479  const uint32_t bindIndex = 0,
480  uint32_t dimensions = 2,
481  const HgiFormat &format = HgiFormatFloat32Vec4,
482  const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
483 
485 HGI_API
486 void
487 HgiShaderFunctionAddArrayOfTextures(
488  HgiShaderFunctionDesc *desc,
489  const std::string &nameInShader,
490  const uint32_t arraySize,
491  const uint32_t bindIndex = 0,
492  const uint32_t dimensions = 2,
493  const HgiFormat &format = HgiFormatFloat32Vec4,
494  const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
495 
497 HGI_API
498 void
499 HgiShaderFunctionAddWritableTexture(
500  HgiShaderFunctionDesc *desc,
501  const std::string &nameInShader,
502  const uint32_t bindIndex = 0,
503  const uint32_t dimensions = 2,
504  const HgiFormat &format = HgiFormatFloat32Vec4,
505  const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
506 
508 HGI_API
509 void
510 HgiShaderFunctionAddBuffer(
511  HgiShaderFunctionDesc *desc,
512  const std::string &nameInShader,
513  const std::string &type,
514  const uint32_t bindIndex,
515  HgiBindingType binding,
516  const uint32_t arraySize = 0);
517 
519 HGI_API
520 void
521 HgiShaderFunctionAddWritableBuffer(
522  HgiShaderFunctionDesc *desc,
523  const std::string &nameInShader,
524  const std::string &type,
525  const uint32_t bindIndex);
526 
529 HGI_API
530 void
531 HgiShaderFunctionAddConstantParam(
532  HgiShaderFunctionDesc *desc,
533  const std::string &nameInShader,
534  const std::string &type,
535  const std::string &role = std::string());
536 
540 HGI_API
541 void
542 HgiShaderFunctionAddStageInput(
543  HgiShaderFunctionDesc *desc,
544  const std::string &nameInShader,
545  const std::string &type,
546  const std::string &role = std::string());
547 
550 HGI_API
551 void
552 HgiShaderFunctionAddStageInput(
553  HgiShaderFunctionDesc *functionDesc,
554  HgiShaderFunctionParamDesc const &paramDesc);
555 
557 HGI_API
558 void
559 HgiShaderFunctionAddGlobalVariable(
560  HgiShaderFunctionDesc *desc,
561  const std::string &nameInShader,
562  const std::string &type,
563  const std::string &arraySize);
564 
567 HGI_API
568 void
569 HgiShaderFunctionAddStageOutput(
570  HgiShaderFunctionDesc *desc,
571  const std::string &nameInShader,
572  const std::string &type,
573  const std::string &role = std::string());
574 
577 HGI_API
578 void
579 HgiShaderFunctionAddStageOutput(
580  HgiShaderFunctionDesc *desc,
581  const std::string &nameInShader,
582  const std::string &type,
583  const uint32_t location);
584 
587 HGI_API
588 void
589 HgiShaderFunctionAddStageOutput(
590  HgiShaderFunctionDesc *functionDesc,
591  HgiShaderFunctionParamDesc const &paramDesc);
592 
593 PXR_NAMESPACE_CLOSE_SCOPE
594 
595 #endif
Describes a geometry function's description.
Describes a buffer to be passed into a shader.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
Describes a tessellation function's description.
Describes a param passed into a shader or between shader stages.
Describes a compute function's description.
Basic type for a vector of 3 int components.
Definition: vec3i.h:61
Describes an interstage param block between shader stages.
Describes a texture to be passed into a shader.
Describes a fragment function's description.
Describes the properties needed to create a GPU shader function.