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 ///
121 {
122  HGI_API
124 
126 };
127 
128 HGI_API
129 bool operator==(
130  const HgiMultiSampleState& lhs,
131  const HgiMultiSampleState& rhs);
132 
133 HGI_API
134 bool operator!=(
135  const HgiMultiSampleState& lhs,
136  const HgiMultiSampleState& rhs);
137 
138 
139 /// \struct HgiRasterizationState
140 ///
141 /// Properties to configure multi sampling.
142 ///
143 /// <ul>
144 /// <li>polygonMode:
145 /// Determines the rasterization draw mode of primitve (triangles).</li>
146 /// <li>lineWidth:
147 /// The width of lines when polygonMode is set to line drawing.</li>
148 /// <li>cullMode:
149 /// Determines the culling rules for primitives (triangles).</li>
150 /// <li>winding:
151 /// The rule that determines what makes a front-facing primitive.</li>
152 /// <li>rasterizationEnabled:
153 /// When false all primitives are discarded before rasterization stage.</li>
154 /// </ul>
155 ///
157 {
158  HGI_API
160 
162  float lineWidth;
166 };
167 
168 HGI_API
169 bool operator==(
170  const HgiRasterizationState& lhs,
171  const HgiRasterizationState& rhs);
172 
173 HGI_API
174 bool operator!=(
175  const HgiRasterizationState& lhs,
176  const HgiRasterizationState& rhs);
177 
178 /// \struct HgiDepthStencilState
179 ///
180 /// Properties to configure depth and stencil test.
181 ///
182 /// <ul>
183 /// <li>depthTestEnabled:
184 /// When enabled uses `depthCompareFn` to test if a fragment passes the
185 /// depth test. Note that depth writes are automatically disabled when
186 /// depthTestEnabled is false.</li>
187 /// <li>depthWriteEnabled:
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>stencilTestEnabled:
192 /// Enables the stencil test.</li>
193 /// </ul>
194 ///
196 {
197  HGI_API
199 
203 
205 };
206 
207 HGI_API
208 bool operator==(
209  const HgiDepthStencilState& lhs,
210  const HgiDepthStencilState& rhs);
211 
212 HGI_API
213 bool operator!=(
214  const HgiDepthStencilState& lhs,
215  const HgiDepthStencilState& rhs);
216 
217 /// \struct HgiPipelineDesc
218 ///
219 /// Describes the properties needed to create a GPU pipeline.
220 ///
221 /// <ul>
222 /// <li>resourceBindings:
223 /// The resource bindings that will be bound when the pipeline is used.
224 /// Primarily used to query the vertex attributes.</li>
225 /// <li>shaderProgram:
226 /// Shader functions/stages used in this pipeline.</li>
227 /// <li>depthState:
228 /// (Graphics pipeline only)
229 /// Describes depth state for a pipeline.</li>
230 /// <li>multiSampleState:
231 /// (Graphics pipeline only)
232 /// Various settings to control multi-sampling.</li>
233 /// <li>rasterizationState:
234 /// (Graphics pipeline only)
235 /// Various settings to control rasterization.</li>
236 /// <li>vertexBuffers:
237 /// Description of the vertex buffers (per-vertex attributes).
238 /// The actual VBOs are bound via GraphicsCmds.</li>
239 /// <li>colorAttachmentDescs:
240 /// Describes each of the color attachments.</li>
241 /// <li>depthAttachmentDesc:
242 /// Describes the depth attachment (optional)</li>
243 /// </ul>
244 ///
246 {
247  HGI_API
249 
259 };
260 
261 HGI_API
262 bool operator==(
263  const HgiGraphicsPipelineDesc& lhs,
264  const HgiGraphicsPipelineDesc& rhs);
265 
266 HGI_API
267 bool operator!=(
268  const HgiGraphicsPipelineDesc& lhs,
269  const HgiGraphicsPipelineDesc& rhs);
270 
271 
272 ///
273 /// \class HgiGraphicsPipeline
274 ///
275 /// Represents a graphics platform independent GPU graphics pipeline
276 /// resource.
277 ///
278 /// Base class for Hgi pipelines.
279 /// To the client (HdSt) pipeline resources are referred to via
280 /// opaque, stateless handles (HgiPipelineHandle).
281 ///
283 {
284 public:
285  HGI_API
286  virtual ~HgiGraphicsPipeline();
287 
288  /// The descriptor describes the object.
289  HGI_API
290  HgiGraphicsPipelineDesc const& GetDescriptor() const;
291 
292 protected:
293  HGI_API
295 
297 
298 private:
299  HgiGraphicsPipeline() = delete;
300  HgiGraphicsPipeline & operator=(const HgiGraphicsPipeline&) = delete;
301  HgiGraphicsPipeline(const HgiGraphicsPipeline&) = delete;
302 };
303 
304 /// Explicitly instantiate and define pipeline handle
307 using HgiGraphicsPipelineHandleVector = std::vector<HgiGraphicsPipelineHandle>;
308 
309 
311 
312 #endif
HgiVertexBufferDescVector vertexBuffers
HgiPolygonMode
Definition: enums.h:347
HgiVertexAttributeDescVector vertexAttributes
HgiCompareFunction
Definition: enums.h:450
HGI_API HgiMultiSampleState()
HGI_API HgiDepthStencilState()
virtual HGI_API ~HgiGraphicsPipeline()
std::vector< HgiAttachmentDesc > HgiAttachmentDescVector
HgiWinding
Definition: enums.h:392
HgiDepthStencilState depthState
HgiAttachmentDescVector colorAttachmentDescs
HgiGraphicsPipelineDesc _descriptor
std::vector< HgiVertexBufferDesc > HgiVertexBufferDescVector
HgiCullMode
Definition: enums.h:371
std::vector< HgiGraphicsPipelineHandle > HgiGraphicsPipelineHandleVector
HgiMultiSampleState multiSampleState
HgiResourceBindingsHandle resourceBindings
HgiRasterizationState rasterizationState
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:563
HGI_API HgiVertexAttributeDesc()
HGI_API HgiVertexBufferDesc()
GLsizei const GLchar *const * string
Definition: glew.h:1844
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
HgiShaderProgramHandle shaderProgram
HGI_API HgiRasterizationState()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HgiFormat
Definition: types.h:42
HGI_API HgiGraphicsPipelineDesc()
HgiAttachmentDesc depthAttachmentDesc
HgiPolygonMode polygonMode
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:549
HgiCompareFunction depthCompareFn
std::vector< HgiVertexAttributeDesc > HgiVertexAttributeDescVector