Loading...
Searching...
No Matches
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
36PXR_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
79using HgiShaderFunctionTextureDescVector =
80 std::vector<HgiShaderFunctionTextureDesc>;
81
82HGI_API
83bool operator==(
86
87HGI_API
88bool operator!=(
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
124using HgiShaderFunctionBufferDescVector =
125 std::vector<HgiShaderFunctionBufferDesc>;
126
127HGI_API
128bool operator==(
130 const HgiShaderFunctionBufferDesc& rhs);
131
132HGI_API
133bool operator!=(
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
179using HgiShaderFunctionParamDescVector =
180 std::vector<HgiShaderFunctionParamDesc>;
181
182HGI_API
183bool operator==(
185 const HgiShaderFunctionParamDesc& rhs);
186
187HGI_API
188bool operator!=(
190 const HgiShaderFunctionParamDesc& rhs);
191
211{
212 HGI_API
214
215 struct Member {
216 std::string name;
217 std::string type;
218 HgiInterpolationType interpolation;
219 HgiSamplingType sampling;
220 };
221 using MemberVector = std::vector<Member>;
222
223 std::string blockName;
224 std::string instanceName;
225 MemberVector members;
226 std::string arraySize;
227 int32_t interstageSlot;
228};
229
230using HgiShaderFunctionParamBlockDescVector =
231 std::vector<HgiShaderFunctionParamBlockDesc>;
232
233HGI_API
234bool operator==(
237
238HGI_API
239bool operator!=(
242
243HGI_API
244bool operator==(
245 const HgiShaderFunctionParamBlockDesc::Member& lhs,
246 const HgiShaderFunctionParamBlockDesc::Member& rhs);
247
248HGI_API
249bool operator!=(
250 const HgiShaderFunctionParamBlockDesc::Member& lhs,
251 const HgiShaderFunctionParamBlockDesc::Member& rhs);
252
270{
271 HGI_API
273
274 GfVec3i localSize;
275};
276
277HGI_API
278bool operator==(
281
282HGI_API
283bool operator!=(
286
305{
306 enum class PatchType { Triangles, Quads, Isolines };
307 enum class Spacing { Equal, FractionalEven, FractionalOdd };
308 enum class Ordering { CW, CCW };
309 HGI_API
311
312 PatchType patchType;
313 Spacing spacing;
314 Ordering ordering;
315 std::string numVertsPerPatchIn;
316 std::string numVertsPerPatchOut;
317};
318
319HGI_API
320bool operator==(
323
324HGI_API
325bool operator!=(
328
344{
345 enum class InPrimitiveType {
346 Points, Lines, LinesAdjacency, Triangles, TrianglesAdjacency };
347 enum class OutPrimitiveType {
348 Points, LineStrip, TriangleStrip };
349
350 HGI_API
352
353 InPrimitiveType inPrimitiveType;
354 OutPrimitiveType outPrimitiveType;
355 std::string outMaxVertices;
356};
357
358HGI_API
359bool operator==(
362
363HGI_API
364bool operator!=(
367
378{
379 HGI_API
381
382 bool earlyFragmentTests;
383
384};
385
386HGI_API
387bool operator==(
390
391HGI_API
392bool operator!=(
395
440{
441 HGI_API
443 std::string debugName;
444 HgiShaderStage shaderStage;
445 const char *shaderCodeDeclarations;
446 const char *shaderCode;
447 std::string *generatedShaderCodeOut;
448 std::vector<HgiShaderFunctionTextureDesc> textures;
449 std::vector<HgiShaderFunctionBufferDesc> buffers;
450 std::vector<HgiShaderFunctionParamDesc> constantParams;
451 std::vector<HgiShaderFunctionParamDesc> stageGlobalMembers;
452 std::vector<HgiShaderFunctionParamDesc> stageInputs;
453 std::vector<HgiShaderFunctionParamDesc> stageOutputs;
454 std::vector<HgiShaderFunctionParamBlockDesc> stageInputBlocks;
455 std::vector<HgiShaderFunctionParamBlockDesc> stageOutputBlocks;
456 HgiShaderFunctionComputeDesc computeDescriptor;
457 HgiShaderFunctionTessellationDesc tessellationDescriptor;
458 HgiShaderFunctionGeometryDesc geometryDescriptor;
459 HgiShaderFunctionFragmentDesc fragmentDescriptor;
460};
461
462using HgiShaderFunctionDescVector =
463 std::vector<HgiShaderFunctionDesc>;
464
465HGI_API
466bool operator==(
467 const HgiShaderFunctionDesc& lhs,
468 const HgiShaderFunctionDesc& rhs);
469
470HGI_API
471bool operator!=(
472 const HgiShaderFunctionDesc& lhs,
473 const HgiShaderFunctionDesc& rhs);
474
476HGI_API
477void
478HgiShaderFunctionAddTexture(
480 const std::string &nameInShader,
481 const uint32_t bindIndex = 0,
482 uint32_t dimensions = 2,
483 const HgiFormat &format = HgiFormatFloat32Vec4,
484 const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
485
487HGI_API
488void
489HgiShaderFunctionAddArrayOfTextures(
491 const std::string &nameInShader,
492 const uint32_t arraySize,
493 const uint32_t bindIndex = 0,
494 const uint32_t dimensions = 2,
495 const HgiFormat &format = HgiFormatFloat32Vec4,
496 const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
497
499HGI_API
500void
501HgiShaderFunctionAddWritableTexture(
503 const std::string &nameInShader,
504 const uint32_t bindIndex = 0,
505 const uint32_t dimensions = 2,
506 const HgiFormat &format = HgiFormatFloat32Vec4,
507 const HgiShaderTextureType textureType = HgiShaderTextureTypeTexture);
508
510HGI_API
511void
512HgiShaderFunctionAddBuffer(
514 const std::string &nameInShader,
515 const std::string &type,
516 const uint32_t bindIndex,
517 HgiBindingType binding,
518 const uint32_t arraySize = 0);
519
521HGI_API
522void
523HgiShaderFunctionAddWritableBuffer(
525 const std::string &nameInShader,
526 const std::string &type,
527 const uint32_t bindIndex);
528
531HGI_API
532void
533HgiShaderFunctionAddConstantParam(
535 const std::string &nameInShader,
536 const std::string &type,
537 const std::string &role = std::string());
538
542HGI_API
543void
544HgiShaderFunctionAddStageInput(
546 const std::string &nameInShader,
547 const std::string &type,
548 const std::string &role = std::string());
549
552HGI_API
553void
554HgiShaderFunctionAddStageInput(
555 HgiShaderFunctionDesc *functionDesc,
556 HgiShaderFunctionParamDesc const &paramDesc);
557
559HGI_API
560void
561HgiShaderFunctionAddGlobalVariable(
563 const std::string &nameInShader,
564 const std::string &type,
565 const std::string &arraySize);
566
569HGI_API
570void
571HgiShaderFunctionAddStageOutput(
573 const std::string &nameInShader,
574 const std::string &type,
575 const std::string &role = std::string(),
576 const std::string &arraySize = std::string());
577
580HGI_API
581void
582HgiShaderFunctionAddStageOutput(
584 const std::string &nameInShader,
585 const std::string &type,
586 const uint32_t location);
587
590HGI_API
591void
592HgiShaderFunctionAddStageOutput(
593 HgiShaderFunctionDesc *functionDesc,
594 HgiShaderFunctionParamDesc const &paramDesc);
595
596PXR_NAMESPACE_CLOSE_SCOPE
597
598#endif
Basic type for a vector of 3 int components.
Definition: vec3i.h:61
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.