graphicsPipeline.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 #ifndef PXR_IMAGING_HGI_GRAPHICS_PIPELINE_H
25 #define PXR_IMAGING_HGI_GRAPHICS_PIPELINE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hgi/api.h"
29 #include "pxr/imaging/hgi/attachmentDesc.h"
30 #include "pxr/imaging/hgi/enums.h"
31 #include "pxr/imaging/hgi/handle.h"
32 #include "pxr/imaging/hgi/resourceBindings.h"
33 #include "pxr/imaging/hgi/shaderProgram.h"
34 #include "pxr/imaging/hgi/types.h"
35 
36 #include "pxr/base/gf/vec2f.h"
37 
38 #include <string>
39 #include <vector>
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
43 
58 {
59  HGI_API
61 
62  HgiFormat format;
63  uint32_t offset;
64  uint32_t shaderBindLocation;
65 };
66 using HgiVertexAttributeDescVector = std::vector<HgiVertexAttributeDesc>;
67 
68 HGI_API
69 bool operator==(
70  const HgiVertexAttributeDesc& lhs,
71  const HgiVertexAttributeDesc& rhs);
72 
73 HGI_API
74 inline bool operator!=(
75  const HgiVertexAttributeDesc& lhs,
76  const HgiVertexAttributeDesc& rhs);
77 
78 
95 {
96  HGI_API
98 
99  uint32_t bindingIndex;
100  HgiVertexAttributeDescVector vertexAttributes;
101  HgiVertexBufferStepFunction vertexStepFunction;
102  uint32_t vertexStride;
103 };
104 using HgiVertexBufferDescVector = std::vector<HgiVertexBufferDesc>;
105 
106 HGI_API
107 bool operator==(
108  const HgiVertexBufferDesc& lhs,
109  const HgiVertexBufferDesc& rhs);
110 
111 HGI_API
112 inline bool operator!=(
113  const HgiVertexBufferDesc& lhs,
114  const HgiVertexBufferDesc& rhs);
115 
116 
136 {
137  HGI_API
139 
140  bool multiSampleEnable;
141  bool alphaToCoverageEnable;
142  bool alphaToOneEnable;
143  HgiSampleCount sampleCount;
144 };
145 
146 HGI_API
147 bool operator==(
148  const HgiMultiSampleState& lhs,
149  const HgiMultiSampleState& rhs);
150 
151 HGI_API
152 bool operator!=(
153  const HgiMultiSampleState& lhs,
154  const HgiMultiSampleState& rhs);
155 
156 
185 {
186  HGI_API
188 
189  HgiPolygonMode polygonMode;
190  float lineWidth;
191  HgiCullMode cullMode;
192  HgiWinding winding;
193  bool rasterizerEnabled;
194  bool depthClampEnabled;
195  GfVec2f depthRange;
196  bool conservativeRaster;
197  size_t numClipDistances;
198 };
199 
200 HGI_API
201 bool operator==(
202  const HgiRasterizationState& lhs,
203  const HgiRasterizationState& rhs);
204 
205 HGI_API
206 bool operator!=(
207  const HgiRasterizationState& lhs,
208  const HgiRasterizationState& rhs);
209 
219 //. The reference value used by the stencil test function.</li>
234 {
235  HGI_API
236  HgiStencilState();
237 
238  HgiCompareFunction compareFn;
239  uint32_t referenceValue;
240  HgiStencilOp stencilFailOp;
241  HgiStencilOp depthFailOp;
242  HgiStencilOp depthStencilPassOp;
243  uint32_t readMask;
244  uint32_t writeMask;
245 };
246 
247 HGI_API
248 bool operator==(
249  const HgiStencilState& lhs,
250  const HgiStencilState& rhs);
251 
252 HGI_API
253 bool operator!=(
254  const HgiStencilState& lhs,
255  const HgiStencilState& rhs);
256 
287 {
288  HGI_API
290 
291  bool depthTestEnabled;
292  bool depthWriteEnabled;
293  HgiCompareFunction depthCompareFn;
294 
295  bool depthBiasEnabled;
296  float depthBiasConstantFactor;
297  float depthBiasSlopeFactor;
298 
299  bool stencilTestEnabled;
300  HgiStencilState stencilFront;
301  HgiStencilState stencilBack;
302 };
303 
304 HGI_API
305 bool operator==(
306  const HgiDepthStencilState& lhs,
307  const HgiDepthStencilState& rhs);
308 
309 HGI_API
310 bool operator!=(
311  const HgiDepthStencilState& lhs,
312  const HgiDepthStencilState& rhs);
313 
326  HGI_API
328 
329  uint32_t byteSize;
330  HgiShaderStage stageUsage;
331 };
332 
333 HGI_API
334 bool operator==(
336  const HgiGraphicsShaderConstantsDesc& rhs);
337 
338 HGI_API
339 bool operator!=(
341  const HgiGraphicsShaderConstantsDesc& rhs);
342 
343 struct HgiTessellationLevel
344 {
345  HGI_API
346  HgiTessellationLevel();
347 
348  float innerTessLevel[2];
349  float outerTessLevel[4];
350 };
351 
366 {
367  enum PatchType {
368  Triangle,
369  Quad
370  };
371 
372  HGI_API
374 
375  PatchType patchType;
376  int primitiveIndexSize;
377  HgiTessellationLevel tessellationLevel;
378 };
379 
415 {
416  HGI_API
418 
419  std::string debugName;
420  HgiPrimitiveType primitiveType;
421  HgiShaderProgramHandle shaderProgram;
422  HgiDepthStencilState depthState;
423  HgiMultiSampleState multiSampleState;
424  HgiRasterizationState rasterizationState;
425  HgiVertexBufferDescVector vertexBuffers;
426  HgiAttachmentDescVector colorAttachmentDescs;
427  HgiAttachmentDescVector colorResolveAttachmentDescs;
428  HgiAttachmentDesc depthAttachmentDesc;
429  HgiAttachmentDesc depthResolveAttachmentDesc;
430  HgiGraphicsShaderConstantsDesc shaderConstantsDesc;
431  HgiTessellationState tessellationState;
432 };
433 
434 HGI_API
435 bool operator==(
436  const HgiGraphicsPipelineDesc& lhs,
437  const HgiGraphicsPipelineDesc& rhs);
438 
439 HGI_API
440 bool operator!=(
441  const HgiGraphicsPipelineDesc& lhs,
442  const HgiGraphicsPipelineDesc& rhs);
443 
444 
456 {
457 public:
458  HGI_API
459  virtual ~HgiGraphicsPipeline();
460 
462  HGI_API
463  HgiGraphicsPipelineDesc const& GetDescriptor() const;
464 
465 protected:
466  HGI_API
468 
469  HgiGraphicsPipelineDesc _descriptor;
470 
471 private:
472  HgiGraphicsPipeline() = delete;
473  HgiGraphicsPipeline & operator=(const HgiGraphicsPipeline&) = delete;
474  HgiGraphicsPipeline(const HgiGraphicsPipeline&) = delete;
475 };
476 
478 using HgiGraphicsPipelineHandleVector = std::vector<HgiGraphicsPipelineHandle>;
479 
480 
481 PXR_NAMESPACE_CLOSE_SCOPE
482 
483 #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:63
Properties to configure depth and stencil test.
Describes the attributes of a vertex buffer.
Describes the properties needed to create a GPU pipeline.