HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
graphicsPipeline.h
Go to the documentation of this file.
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"
30 #include "pxr/imaging/hgi/enums.h"
31 #include "pxr/imaging/hgi/handle.h"
34 #include "pxr/imaging/hgi/types.h"
35 
36 #include <string>
37 #include <vector>
38 
40 
41 
42 /// \struct HgiVertexAttributeDesc
43 ///
44 /// Describes one attribute of a vertex.
45 ///
46 /// <ul>
47 /// <li>format:
48 /// Format of the vertex attribute.</li>
49 /// <li>offset:
50 /// The byte offset of the attribute in vertex buffer</li>
51 /// <li>shaderBindLocation:
52 /// The location of the attribute in the shader. layout(location = X)</li>
53 /// </ul>
54 ///
56 {
57  HGI_API
59 
61  uint32_t offset;
63 };
64 using HgiVertexAttributeDescVector = std::vector<HgiVertexAttributeDesc>;
65 
66 HGI_API
67 bool operator==(
68  const HgiVertexAttributeDesc& lhs,
69  const HgiVertexAttributeDesc& rhs);
70 
71 HGI_API
72 inline bool operator!=(
73  const HgiVertexAttributeDesc& lhs,
74  const HgiVertexAttributeDesc& rhs);
75 
76 
77 /// \struct HgiVertexBufferDesc
78 ///
79 /// Describes the attributes of a vertex buffer.
80 ///
81 /// <ul>
82 /// <li>bindingIndex:
83 /// Binding location for this vertex buffer.</li>
84 /// <li>vertexAttributes:
85 /// List of vertex attributes (in vertex buffer).</li>
86 /// <li>vertexStride:
87 /// The byte size of a vertex (distance between two vertices).</li>
88 /// </ul>
89 ///
91 {
92  HGI_API
94 
95  uint32_t bindingIndex;
97  uint32_t vertexStride;
98 };
99 using HgiVertexBufferDescVector = std::vector<HgiVertexBufferDesc>;
100 
101 HGI_API
102 bool operator==(
103  const HgiVertexBufferDesc& lhs,
104  const HgiVertexBufferDesc& rhs);
105 
106 HGI_API
107 inline bool operator!=(
108  const HgiVertexBufferDesc& lhs,
109  const HgiVertexBufferDesc& rhs);
110 
111 
112 /// \struct HgiMultiSampleState
113 ///
114 /// Properties to configure multi sampling.
115 ///
116 /// <ul>
117 /// <li>alphaToCoverageEnable:
118 /// Fragment's color.a determines coverage (screen door transparency).</li>
119 /// <li>sampleCount:
120 /// The number of samples for each fragment. Must match attachments</li>
121 /// </ul>
122 ///
124 {
125  HGI_API
127 
130 };
131 
132 HGI_API
133 bool operator==(
134  const HgiMultiSampleState& lhs,
135  const HgiMultiSampleState& rhs);
136 
137 HGI_API
138 bool operator!=(
139  const HgiMultiSampleState& lhs,
140  const HgiMultiSampleState& rhs);
141 
142 
143 /// \struct HgiRasterizationState
144 ///
145 /// Properties to configure multi sampling.
146 ///
147 /// <ul>
148 /// <li>polygonMode:
149 /// Determines the rasterization draw mode of primitve (triangles).</li>
150 /// <li>lineWidth:
151 /// The width of lines when polygonMode is set to line drawing.</li>
152 /// <li>cullMode:
153 /// Determines the culling rules for primitives (triangles).</li>
154 /// <li>winding:
155 /// The rule that determines what makes a front-facing primitive.</li>
156 /// <li>rasterizationEnabled:
157 /// When false all primitives are discarded before rasterization stage.</li>
158 /// </ul>
159 ///
161 {
162  HGI_API
164 
166  float lineWidth;
170 };
171 
172 HGI_API
173 bool operator==(
174  const HgiRasterizationState& lhs,
175  const HgiRasterizationState& rhs);
176 
177 HGI_API
178 bool operator!=(
179  const HgiRasterizationState& lhs,
180  const HgiRasterizationState& rhs);
181 
182 /// \struct HgiDepthStencilState
183 ///
184 /// Properties to configure depth and stencil test.
185 ///
186 /// <ul>
187 /// <li>depthTestEnabled:
188 /// When enabled uses `depthCompareFn` to test if a fragment passes the
189 /// depth test. Note that depth writes are automatically disabled when
190 /// depthTestEnabled is false.</li>
191 /// <li>depthWriteEnabled:
192 /// When enabled uses `depthCompareFn` to test if a fragment passes the
193 /// depth test. Note that depth writes are automatically disabled when
194 /// depthTestEnabled is false.</li>
195 /// <li>stencilTestEnabled:
196 /// Enables the stencil test.</li>
197 /// </ul>
198 ///
200 {
201  HGI_API
203 
208 };
209 
210 HGI_API
211 bool operator==(
212  const HgiDepthStencilState& lhs,
213  const HgiDepthStencilState& rhs);
214 
215 HGI_API
216 bool operator!=(
217  const HgiDepthStencilState& lhs,
218  const HgiDepthStencilState& rhs);
219 
220 /// \struct HgiGraphicsShaderConstantsDesc
221 ///
222 /// A small, but fast buffer of uniform data for shaders.
223 ///
224 /// <ul>
225 /// <li>byteSize:
226 /// Size of the constants in bytes. (max 256 bytes)</li>
227 /// <li>stageUsage:
228 /// What shader stage(s) the constants will be used in.</li>
229 /// </ul>
230 ///
232  HGI_API
234 
235  uint32_t byteSize;
237 };
238 
239 HGI_API
240 bool operator==(
242  const HgiGraphicsShaderConstantsDesc& rhs);
243 
244 HGI_API
245 bool operator!=(
247  const HgiGraphicsShaderConstantsDesc& rhs);
248 
249 /// \struct HgiGraphicsPipelineDesc
250 ///
251 /// Describes the properties needed to create a GPU pipeline.
252 ///
253 /// <ul>
254 /// <li>primitiveType:
255 /// Describes the stream of vertices (primitive topology).</li>
256 /// <li>shaderProgram:
257 /// Shader functions/stages used in this pipeline.</li>
258 /// <li>depthState:
259 /// Describes depth state for a pipeline.</li>
260 /// <li>multiSampleState:
261 /// Various settings to control multi-sampling.</li>
262 /// <li>rasterizationState:
263 /// Various settings to control rasterization.</li>
264 /// <li>vertexBuffers:
265 /// Description of the vertex buffers (per-vertex attributes).
266 /// The actual VBOs are bound via GraphicsCmds.</li>
267 /// <li>colorAttachmentDescs:
268 /// Describes each of the color attachments.</li>
269 /// <li>colorResolveAttachmentDescs:
270 /// Describes each of the color resolve attachments (optional).</li>
271 /// <li>depthAttachmentDesc:
272 /// Describes the depth attachment (optional)
273 /// Use HgiFormatInvalid to indicate no depth attachment.</li>
274 /// <li>depthResolveAttachmentDesc:
275 /// Describes the depth resolve attachment (optional).
276 /// Use HgiFormatInvalid to indicate no depth resolve attachment.</li>
277 /// <li>shaderConstantsDesc:
278 /// Describes the shader uniforms.</li>
279 /// </ul>
280 ///
282 {
283  HGI_API
285 
298 };
299 
300 HGI_API
301 bool operator==(
302  const HgiGraphicsPipelineDesc& lhs,
303  const HgiGraphicsPipelineDesc& rhs);
304 
305 HGI_API
306 bool operator!=(
307  const HgiGraphicsPipelineDesc& lhs,
308  const HgiGraphicsPipelineDesc& rhs);
309 
310 
311 ///
312 /// \class HgiGraphicsPipeline
313 ///
314 /// Represents a graphics platform independent GPU graphics pipeline
315 /// resource.
316 ///
317 /// Base class for Hgi pipelines.
318 /// To the client (HdSt) pipeline resources are referred to via
319 /// opaque, stateless handles (HgiPipelineHandle).
320 ///
322 {
323 public:
324  HGI_API
325  virtual ~HgiGraphicsPipeline();
326 
327  /// The descriptor describes the object.
328  HGI_API
329  HgiGraphicsPipelineDesc const& GetDescriptor() const;
330 
331 protected:
332  HGI_API
334 
336 
337 private:
338  HgiGraphicsPipeline() = delete;
339  HgiGraphicsPipeline & operator=(const HgiGraphicsPipeline&) = delete;
340  HgiGraphicsPipeline(const HgiGraphicsPipeline&) = delete;
341 };
342 
344 using HgiGraphicsPipelineHandleVector = std::vector<HgiGraphicsPipelineHandle>;
345 
346 
348 
349 #endif
HgiVertexBufferDescVector vertexBuffers
HgiPolygonMode
Definition: enums.h:343
HgiVertexAttributeDescVector vertexAttributes
HgiCompareFunction
Definition: enums.h:446
HGI_API HgiMultiSampleState()
HGI_API HgiDepthStencilState()
virtual HGI_API ~HgiGraphicsPipeline()
std::vector< HgiAttachmentDesc > HgiAttachmentDescVector
HgiWinding
Definition: enums.h:388
HgiDepthStencilState depthState
HgiAttachmentDescVector colorAttachmentDescs
HgiGraphicsPipelineDesc _descriptor
HgiFormat
Definition: types.h:45
std::vector< HgiVertexBufferDesc > HgiVertexBufferDescVector
HgiCullMode
Definition: enums.h:367
std::vector< HgiGraphicsPipelineHandle > HgiGraphicsPipelineHandleVector
HgiAttachmentDesc depthResolveAttachmentDesc
HgiSampleCount sampleCount
HgiMultiSampleState multiSampleState
HgiGraphicsShaderConstantsDesc shaderConstantsDesc
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
HgiRasterizationState rasterizationState
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:570
HGI_API HgiVertexAttributeDesc()
HgiPrimitiveType
Definition: enums.h:494
HGI_API HgiVertexBufferDesc()
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
HgiAttachmentDescVector colorResolveAttachmentDescs
HgiShaderProgramHandle shaderProgram
HGI_API HgiRasterizationState()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HGI_API HgiGraphicsPipelineDesc()
HgiAttachmentDesc depthAttachmentDesc
HgiBits HgiShaderStage
Definition: enums.h:292
HgiPolygonMode polygonMode
HgiPrimitiveType primitiveType
HgiSampleCount
Definition: enums.h:177
HGI_API HgiGraphicsPipelineDesc const & GetDescriptor() const
The descriptor describes the object.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:556
HgiCompareFunction depthCompareFn
std::vector< HgiVertexAttributeDesc > HgiVertexAttributeDescVector