graphicsPipeline.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 #ifndef PXR_IMAGING_HGI_GRAPHICS_PIPELINE_H
8 #define PXR_IMAGING_HGI_GRAPHICS_PIPELINE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hgi/api.h"
12 #include "pxr/imaging/hgi/attachmentDesc.h"
13 #include "pxr/imaging/hgi/enums.h"
14 #include "pxr/imaging/hgi/handle.h"
15 #include "pxr/imaging/hgi/resourceBindings.h"
16 #include "pxr/imaging/hgi/shaderProgram.h"
17 #include "pxr/imaging/hgi/types.h"
18 
19 #include "pxr/base/gf/vec2f.h"
20 
21 #include <string>
22 #include <vector>
23 
24 PXR_NAMESPACE_OPEN_SCOPE
25 
26 
41 {
42  HGI_API
44 
45  HgiFormat format;
46  uint32_t offset;
47  uint32_t shaderBindLocation;
48 };
49 using HgiVertexAttributeDescVector = std::vector<HgiVertexAttributeDesc>;
50 
51 HGI_API
52 bool operator==(
53  const HgiVertexAttributeDesc& lhs,
54  const HgiVertexAttributeDesc& rhs);
55 
56 HGI_API
57 bool operator!=(
58  const HgiVertexAttributeDesc& lhs,
59  const HgiVertexAttributeDesc& rhs);
60 
61 
78 {
79  HGI_API
81 
82  uint32_t bindingIndex;
83  HgiVertexAttributeDescVector vertexAttributes;
84  HgiVertexBufferStepFunction vertexStepFunction;
85  uint32_t vertexStride;
86 };
87 using HgiVertexBufferDescVector = std::vector<HgiVertexBufferDesc>;
88 
89 HGI_API
90 bool operator==(
91  const HgiVertexBufferDesc& lhs,
92  const HgiVertexBufferDesc& rhs);
93 
94 HGI_API
95 inline bool operator!=(
96  const HgiVertexBufferDesc& lhs,
97  const HgiVertexBufferDesc& rhs);
98 
99 
119 {
120  HGI_API
122 
123  bool multiSampleEnable;
124  bool alphaToCoverageEnable;
125  bool alphaToOneEnable;
126  HgiSampleCount sampleCount;
127 };
128 
129 HGI_API
130 bool operator==(
131  const HgiMultiSampleState& lhs,
132  const HgiMultiSampleState& rhs);
133 
134 HGI_API
135 bool operator!=(
136  const HgiMultiSampleState& lhs,
137  const HgiMultiSampleState& rhs);
138 
139 
168 {
169  HGI_API
171 
172  HgiPolygonMode polygonMode;
173  float lineWidth;
174  HgiCullMode cullMode;
175  HgiWinding winding;
176  bool rasterizerEnabled;
177  bool depthClampEnabled;
178  GfVec2f depthRange;
179  bool conservativeRaster;
180  size_t numClipDistances;
181 };
182 
183 HGI_API
184 bool operator==(
185  const HgiRasterizationState& lhs,
186  const HgiRasterizationState& rhs);
187 
188 HGI_API
189 bool operator!=(
190  const HgiRasterizationState& lhs,
191  const HgiRasterizationState& rhs);
192 
202 //. The reference value used by the stencil test function.</li>
217 {
218  HGI_API
219  HgiStencilState();
220 
221  HgiCompareFunction compareFn;
222  uint32_t referenceValue;
223  HgiStencilOp stencilFailOp;
224  HgiStencilOp depthFailOp;
225  HgiStencilOp depthStencilPassOp;
226  uint32_t readMask;
227  uint32_t writeMask;
228 };
229 
230 HGI_API
231 bool operator==(
232  const HgiStencilState& lhs,
233  const HgiStencilState& rhs);
234 
235 HGI_API
236 bool operator!=(
237  const HgiStencilState& lhs,
238  const HgiStencilState& rhs);
239 
270 {
271  HGI_API
273 
274  bool depthTestEnabled;
275  bool depthWriteEnabled;
276  HgiCompareFunction depthCompareFn;
277 
278  bool depthBiasEnabled;
279  float depthBiasConstantFactor;
280  float depthBiasSlopeFactor;
281 
282  bool stencilTestEnabled;
283  HgiStencilState stencilFront;
284  HgiStencilState stencilBack;
285 };
286 
287 HGI_API
288 bool operator==(
289  const HgiDepthStencilState& lhs,
290  const HgiDepthStencilState& rhs);
291 
292 HGI_API
293 bool operator!=(
294  const HgiDepthStencilState& lhs,
295  const HgiDepthStencilState& rhs);
296 
309  HGI_API
311 
312  uint32_t byteSize;
313  HgiShaderStage stageUsage;
314 };
315 
316 HGI_API
317 bool operator==(
319  const HgiGraphicsShaderConstantsDesc& rhs);
320 
321 HGI_API
322 bool operator!=(
324  const HgiGraphicsShaderConstantsDesc& rhs);
325 
326 struct HgiTessellationLevel
327 {
328  HGI_API
329  HgiTessellationLevel();
330 
331  float innerTessLevel[2];
332  float outerTessLevel[4];
333 };
334 
349 {
350  enum PatchType {
351  Triangle,
352  Quad,
353  Isoline
354  };
355 
356  enum TessFactorMode {
357  Constant,
358  TessControl,
359  TessVertex
360  };
361 
362  HGI_API
364 
365  PatchType patchType;
366  int primitiveIndexSize;
367  TessFactorMode tessFactorMode = TessFactorMode::Constant;
368  HgiTessellationLevel tessellationLevel;
369 };
370 
403 {
404  HGI_API
406 
407  std::string debugName;
408  HgiPrimitiveType primitiveType;
409  HgiShaderProgramHandle shaderProgram;
410  HgiDepthStencilState depthState;
411  HgiMultiSampleState multiSampleState;
412  HgiRasterizationState rasterizationState;
413  HgiVertexBufferDescVector vertexBuffers;
414  HgiAttachmentDescVector colorAttachmentDescs;
415  HgiAttachmentDesc depthAttachmentDesc;
416  bool resolveAttachments;
417  HgiGraphicsShaderConstantsDesc shaderConstantsDesc;
418  HgiTessellationState tessellationState;
419 };
420 
421 HGI_API
422 bool operator==(
423  const HgiGraphicsPipelineDesc& lhs,
424  const HgiGraphicsPipelineDesc& rhs);
425 
426 HGI_API
427 bool operator!=(
428  const HgiGraphicsPipelineDesc& lhs,
429  const HgiGraphicsPipelineDesc& rhs);
430 
431 
443 {
444 public:
445  HGI_API
446  virtual ~HgiGraphicsPipeline();
447 
449  HGI_API
450  HgiGraphicsPipelineDesc const& GetDescriptor() const;
451 
452 protected:
453  HGI_API
455 
456  HgiGraphicsPipelineDesc _descriptor;
457 
458 private:
459  HgiGraphicsPipeline() = delete;
460  HgiGraphicsPipeline & operator=(const HgiGraphicsPipeline&) = delete;
461  HgiGraphicsPipeline(const HgiGraphicsPipeline&) = delete;
462 };
463 
465 using HgiGraphicsPipelineHandleVector = std::vector<HgiGraphicsPipelineHandle>;
466 
467 
468 PXR_NAMESPACE_CLOSE_SCOPE
469 
470 #endif
Describes the properties of a framebuffer attachment.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
A small, but fast buffer of uniform data for shaders.
Properties to configure multi sampling.
Describes one attribute of a vertex.
Represents a graphics platform independent GPU graphics pipeline resource.
stencilFailOp: The operation executed when the stencil test fails.
Properties to configure tessellation.
HGI_API HgiGraphicsPipelineDesc const & GetDescriptor() const
The descriptor describes the object.
Properties to configure the rasterization state.
Basic type for a vector of 2 float components.
Definition: vec2f.h:45
Properties to configure depth and stencil test.
Describes the attributes of a vertex buffer.
Describes the properties needed to create a GPU pipeline.