Loading...
Searching...
No Matches
shaderFunctionDesc.h
1//
2// Copyright 2020 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_IMAGING_HGI_SHADERFUNCTIONDESC_H
9#define PXR_IMAGING_HGI_SHADERFUNCTIONDESC_H
10
11#include "pxr/pxr.h"
12#include "pxr/imaging/hgi/api.h"
13#include "pxr/imaging/hgi/enums.h"
14#include "pxr/imaging/hgi/types.h"
15
16#include <string>
17#include <vector>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21
49{
50 HGI_API
52
53 std::string nameInShader;
54 uint32_t dimensions;
55 HgiFormat format;
56 HgiShaderTextureType textureType;
57 uint32_t bindIndex;
58 size_t arraySize;
59 bool writable;
60};
61
62using HgiShaderFunctionTextureDescVector =
63 std::vector<HgiShaderFunctionTextureDesc>;
64
65HGI_API
66bool operator==(
69
70HGI_API
71bool operator!=(
74
95{
96 HGI_API
98
99 std::string nameInShader;
100 std::string type;
101 uint32_t bindIndex;
102 uint32_t arraySize;
103 HgiBindingType binding;
104 bool writable;
105};
106
107using HgiShaderFunctionBufferDescVector =
108 std::vector<HgiShaderFunctionBufferDesc>;
109
110HGI_API
111bool operator==(
113 const HgiShaderFunctionBufferDesc& rhs);
114
115HGI_API
116bool operator!=(
118 const HgiShaderFunctionBufferDesc& rhs);
119
147{
148 HGI_API
150
151 std::string nameInShader;
152 std::string type;
153 int32_t location;
154 int32_t interstageSlot;
155 HgiInterpolationType interpolation;
156 HgiSamplingType sampling;
157 HgiStorageType storage;
158 std::string role;
159 std::string arraySize;
160};
161
162using HgiShaderFunctionParamDescVector =
163 std::vector<HgiShaderFunctionParamDesc>;
164
165HGI_API
166bool operator==(
168 const HgiShaderFunctionParamDesc& rhs);
169
170HGI_API
171bool operator!=(
173 const HgiShaderFunctionParamDesc& rhs);
174
194{
195 HGI_API
197
198 struct Member {
199 std::string name;
200 std::string type;
201 HgiInterpolationType interpolation;
202 HgiSamplingType sampling;
203 };
204 using MemberVector = std::vector<Member>;
205
206 std::string blockName;
207 std::string instanceName;
208 MemberVector members;
209 std::string arraySize;
210 int32_t interstageSlot;
211};
212
213using HgiShaderFunctionParamBlockDescVector =
214 std::vector<HgiShaderFunctionParamBlockDesc>;
215
216HGI_API
217bool operator==(
220
221HGI_API
222bool operator!=(
225
226HGI_API
227bool operator==(
228 const HgiShaderFunctionParamBlockDesc::Member& lhs,
229 const HgiShaderFunctionParamBlockDesc::Member& rhs);
230
231HGI_API
232bool operator!=(
233 const HgiShaderFunctionParamBlockDesc::Member& lhs,
234 const HgiShaderFunctionParamBlockDesc::Member& rhs);
235
253{
254 HGI_API
256
257 GfVec3i localSize;
258};
259
260HGI_API
261bool operator==(
264
265HGI_API
266bool operator!=(
269
288{
289 enum class PatchType { Triangles, Quads, Isolines };
290 enum class Spacing { Equal, FractionalEven, FractionalOdd };
291 enum class Ordering { CW, CCW };
292 HGI_API
294
295 PatchType patchType;
296 Spacing spacing;
297 Ordering ordering;
298 std::string numVertsPerPatchIn;
299 std::string numVertsPerPatchOut;
300};
301
302HGI_API
303bool operator==(
306
307HGI_API
308bool operator!=(
311
327{
328 enum class InPrimitiveType {
329 Points, Lines, LinesAdjacency, Triangles, TrianglesAdjacency };
330 enum class OutPrimitiveType {
331 Points, LineStrip, TriangleStrip };
332
333 HGI_API
335
336 InPrimitiveType inPrimitiveType;
337 OutPrimitiveType outPrimitiveType;
338 std::string outMaxVertices;
339};
340
341HGI_API
342bool operator==(
345
346HGI_API
347bool operator!=(
350
361{
362 HGI_API
364
365 bool earlyFragmentTests;
366
367};
368
369HGI_API
370bool operator==(
373
374HGI_API
375bool operator!=(
378
423{
424 HGI_API
426 std::string debugName;
427 HgiShaderStage shaderStage;
428 const char *shaderCodeDeclarations;
429 const char *shaderCode;
430 std::string *generatedShaderCodeOut;
431 std::vector<HgiShaderFunctionTextureDesc> textures;
432 std::vector<HgiShaderFunctionBufferDesc> buffers;
433 std::vector<HgiShaderFunctionParamDesc> constantParams;
434 std::vector<HgiShaderFunctionParamDesc> stageGlobalMembers;
435 std::vector<HgiShaderFunctionParamDesc> stageInputs;
436 std::vector<HgiShaderFunctionParamDesc> stageOutputs;
437 std::vector<HgiShaderFunctionParamBlockDesc> stageInputBlocks;
438 std::vector<HgiShaderFunctionParamBlockDesc> stageOutputBlocks;
439 HgiShaderFunctionComputeDesc computeDescriptor;
440 HgiShaderFunctionTessellationDesc tessellationDescriptor;
441 HgiShaderFunctionGeometryDesc geometryDescriptor;
442 HgiShaderFunctionFragmentDesc fragmentDescriptor;
443};
444
445using HgiShaderFunctionDescVector =
446 std::vector<HgiShaderFunctionDesc>;
447
448HGI_API
449bool operator==(
450 const HgiShaderFunctionDesc& lhs,
451 const HgiShaderFunctionDesc& rhs);
452
453HGI_API
454bool operator!=(
455 const HgiShaderFunctionDesc& lhs,
456 const HgiShaderFunctionDesc& rhs);
457
459HGI_API
460void
461HgiShaderFunctionAddTexture(
463 const std::string &nameInShader,
464 const uint32_t bindIndex = 0,
465 uint32_t dimensions = 2,
466 const HgiFormat &format = HgiFormatFloat32Vec4,
467 const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
468
470HGI_API
471void
472HgiShaderFunctionAddArrayOfTextures(
474 const std::string &nameInShader,
475 const uint32_t arraySize,
476 const uint32_t bindIndex = 0,
477 const uint32_t dimensions = 2,
478 const HgiFormat &format = HgiFormatFloat32Vec4,
479 const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
480
482HGI_API
483void
484HgiShaderFunctionAddWritableTexture(
486 const std::string &nameInShader,
487 const uint32_t bindIndex = 0,
488 const uint32_t dimensions = 2,
489 const HgiFormat &format = HgiFormatFloat32Vec4,
490 const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
491
493HGI_API
494void
495HgiShaderFunctionAddBuffer(
497 const std::string &nameInShader,
498 const std::string &type,
499 const uint32_t bindIndex,
500 HgiBindingType binding,
501 const uint32_t arraySize = 0);
502
504HGI_API
505void
506HgiShaderFunctionAddWritableBuffer(
508 const std::string &nameInShader,
509 const std::string &type,
510 const uint32_t bindIndex);
511
514HGI_API
515void
516HgiShaderFunctionAddConstantParam(
518 const std::string &nameInShader,
519 const std::string &type,
520 const std::string &role = std::string());
521
525HGI_API
526void
527HgiShaderFunctionAddStageInput(
529 const std::string &nameInShader,
530 const std::string &type,
531 const std::string &role = std::string());
532
535HGI_API
536void
537HgiShaderFunctionAddStageInput(
538 HgiShaderFunctionDesc *functionDesc,
539 HgiShaderFunctionParamDesc const &paramDesc);
540
542HGI_API
543void
544HgiShaderFunctionAddGlobalVariable(
546 const std::string &nameInShader,
547 const std::string &type,
548 const std::string &arraySize);
549
552HGI_API
553void
554HgiShaderFunctionAddStageOutput(
556 const std::string &nameInShader,
557 const std::string &type,
558 const std::string &role = std::string(),
559 const std::string &arraySize = std::string());
560
563HGI_API
564void
565HgiShaderFunctionAddStageOutput(
567 const std::string &nameInShader,
568 const std::string &type,
569 const uint32_t location);
570
573HGI_API
574void
575HgiShaderFunctionAddStageOutput(
576 HgiShaderFunctionDesc *functionDesc,
577 HgiShaderFunctionParamDesc const &paramDesc);
578
579PXR_NAMESPACE_CLOSE_SCOPE
580
581#endif
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
Describes a buffer to be passed into a shader.
Describes a compute function's description.
Describes the properties needed to create a GPU shader function.
Describes a fragment function's description.
Describes a geometry function's description.
Describes an interstage param block between shader stages.
Describes a param passed into a shader or between shader stages.
Describes a tessellation function's description.
Describes a texture to be passed into a shader.