Loading...
Searching...
No Matches
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
41PXR_NAMESPACE_OPEN_SCOPE
42
43
58{
59 HGI_API
61
62 HgiFormat format;
63 uint32_t offset;
64 uint32_t shaderBindLocation;
65};
66using HgiVertexAttributeDescVector = std::vector<HgiVertexAttributeDesc>;
67
68HGI_API
69bool operator==(
70 const HgiVertexAttributeDesc& lhs,
71 const HgiVertexAttributeDesc& rhs);
72
73HGI_API
74inline 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};
104using HgiVertexBufferDescVector = std::vector<HgiVertexBufferDesc>;
105
106HGI_API
107bool operator==(
108 const HgiVertexBufferDesc& lhs,
109 const HgiVertexBufferDesc& rhs);
110
111HGI_API
112inline 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
146HGI_API
147bool operator==(
148 const HgiMultiSampleState& lhs,
149 const HgiMultiSampleState& rhs);
150
151HGI_API
152bool 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
200HGI_API
201bool operator==(
202 const HgiRasterizationState& lhs,
203 const HgiRasterizationState& rhs);
204
205HGI_API
206bool 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
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
247HGI_API
248bool operator==(
249 const HgiStencilState& lhs,
250 const HgiStencilState& rhs);
251
252HGI_API
253bool 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
304HGI_API
305bool operator==(
306 const HgiDepthStencilState& lhs,
307 const HgiDepthStencilState& rhs);
308
309HGI_API
310bool operator!=(
311 const HgiDepthStencilState& lhs,
312 const HgiDepthStencilState& rhs);
313
326 HGI_API
328
329 uint32_t byteSize;
330 HgiShaderStage stageUsage;
331};
332
333HGI_API
334bool operator==(
337
338HGI_API
339bool operator!=(
342
343struct 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 Isoline
371 };
372
373 enum TessFactorMode {
374 Constant,
375 TessControl,
376 TessVertex
377 };
378
379 HGI_API
381
382 PatchType patchType;
383 int primitiveIndexSize;
384 TessFactorMode tessFactorMode = TessFactorMode::Constant;
385 HgiTessellationLevel tessellationLevel;
386};
387
420{
421 HGI_API
423
424 std::string debugName;
425 HgiPrimitiveType primitiveType;
426 HgiShaderProgramHandle shaderProgram;
427 HgiDepthStencilState depthState;
428 HgiMultiSampleState multiSampleState;
429 HgiRasterizationState rasterizationState;
430 HgiVertexBufferDescVector vertexBuffers;
431 HgiAttachmentDescVector colorAttachmentDescs;
432 HgiAttachmentDesc depthAttachmentDesc;
433 bool resolveAttachments;
434 HgiGraphicsShaderConstantsDesc shaderConstantsDesc;
435 HgiTessellationState tessellationState;
436};
437
438HGI_API
439bool operator==(
440 const HgiGraphicsPipelineDesc& lhs,
441 const HgiGraphicsPipelineDesc& rhs);
442
443HGI_API
444bool operator!=(
445 const HgiGraphicsPipelineDesc& lhs,
446 const HgiGraphicsPipelineDesc& rhs);
447
448
460{
461public:
462 HGI_API
463 virtual ~HgiGraphicsPipeline();
464
466 HGI_API
468
469protected:
470 HGI_API
472
473 HgiGraphicsPipelineDesc _descriptor;
474
475private:
476 HgiGraphicsPipeline() = delete;
477 HgiGraphicsPipeline & operator=(const HgiGraphicsPipeline&) = delete;
479};
480
482using HgiGraphicsPipelineHandleVector = std::vector<HgiGraphicsPipelineHandle>;
483
484
485PXR_NAMESPACE_CLOSE_SCOPE
486
487#endif
Basic type for a vector of 2 float components.
Definition: vec2f.h:63
Represents a graphics platform independent GPU graphics pipeline resource.
HGI_API HgiGraphicsPipelineDesc const & GetDescriptor() const
The descriptor describes the object.
Describes the properties of a framebuffer attachment.
Properties to configure depth and stencil test.
Describes the properties needed to create a GPU pipeline.
A small, but fast buffer of uniform data for shaders.
Properties to configure multi sampling.
Properties to configure the rasterization state.
stencilFailOp: The operation executed when the stencil test fails.
Properties to configure tessellation.
Describes one attribute of a vertex.
Describes the attributes of a vertex buffer.