HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
aov.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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_HD_AOV_H
8 #define PXR_IMAGING_HD_AOV_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/imaging/hd/api.h"
13 #include "pxr/imaging/hd/types.h"
14 #include "pxr/usd/sdf/path.h"
15 #include "pxr/base/gf/vec3i.h"
16 #include "pxr/base/tf/hashmap.h"
17 #include "pxr/base/vt/value.h"
18 
20 
22 
23 /// \class HdAovDescriptor
24 ///
25 /// A bundle of state describing an AOV ("Arbitrary Output Variable") display
26 /// channel. Note that in hydra API, this data is split between
27 /// HdRenderPassAovBinding and HdRenderBufferDescriptor. This class is
28 /// provided for use in higher level application-facing API.
30 {
33  , clearValue(), aovSettings() {}
34  HdAovDescriptor(HdFormat f, bool ms, VtValue const& c)
35  : format(f), multiSampled(ms), clearValue(c), aovSettings() {}
36 
37  // ----------------------------------------------------------------
38  // Render buffer parameters
39  // ----------------------------------------------------------------
40 
41  /// The AOV output format. See also HdRenderBufferDescriptor#format.
43 
44  /// Whether the render buffer should be multisampled.
45  /// See also HdRenderBufferDescriptor#multiSampled.
47 
48  // ----------------------------------------------------------------
49  // Renderpass binding parameters.
50  // ----------------------------------------------------------------
51 
52  /// The clear value to apply to the render buffer before rendering.
53  /// The type of "clearValue" should match the provided format.
54  /// If clearValue is empty, no clear will be performed.
55  /// See also HdRenderPassAovBinding#clearValue.
57 
58  /// Extra settings for AOV rendering, such as pixel filtering options.
59  /// See also HdRenderPassAovBinding#aovSettings.
61 };
62 typedef std::vector<HdAovDescriptor> HdAovDescriptorList;
63 
64 /// \struct HdRenderBufferDescriptor
65 ///
66 /// Describes the allocation structure of a render buffer bprim.
68 
71  HdRenderBufferDescriptor(GfVec3i const& _d, HdFormat _f, bool _ms)
72  : dimensions(_d), format(_f), multiSampled(_ms) {}
73 
74  /// The width, height, and depth of the allocated render buffer.
76 
77  /// The data format of the render buffer. See also HdAovDescriptor#format.
79 
80  /// Whether the render buffer should be multisampled. See also
81  /// HdAovDescriptor#multiSampled.
83 
84  bool operator==(HdRenderBufferDescriptor const& rhs) const {
85  return dimensions == rhs.dimensions &&
86  format == rhs.format && multiSampled == rhs.multiSampled;
87  }
88  bool operator!=(HdRenderBufferDescriptor const& rhs) const {
89  return !(*this == rhs);
90  }
91 };
92 
93 /// \class HdRenderPassAovBinding
94 ///
95 /// A renderpass AOV represents a binding of some output of the
96 /// rendering process to an output buffer.
97 
98 class HdRenderBuffer;
99 
101 
103  : renderBuffer(nullptr) {}
104 
105  /// The identifier of the renderer output to be consumed. This should take
106  /// a value from HdAovTokens.
107  /// Bindings for depth and depthStencil are identified by the "depth"
108  /// or "depthStencil" suffix, respectively.
109  /// See HdAovHasDepthSemantic() and HdAovHadDepthStencilSemantic().
111 
112  /// The render buffer to be bound to the above terminal output.
113  ///
114  /// From the app or scene, this can be specified as either a pointer or
115  /// a path to a renderbuffer in the render index. If both are specified,
116  /// the pointer is used preferentially.
117  ///
118  /// Note: hydra never takes ownership of the renderBuffer, but assumes it
119  /// will be alive until the end of the renderpass, or whenever the buffer
120  /// is marked converged, whichever is later.
122 
123  /// The render buffer to be bound to the above terminal output.
125 
126  /// The clear value to apply to the bound render buffer, before rendering.
127  /// The type of "clearValue" should match the type of the bound buffer.
128  /// If clearValue is empty, it indicates no clear should be performed.
129  /// See also HdAovDescriptor#clearValue.
131 
132  /// Extra settings for AOV rendering, such as pixel filtering options.
133  /// See also HdAovDescriptor#aovSettings.
135 };
136 
137 typedef std::vector<HdRenderPassAovBinding> HdRenderPassAovBindingVector;
138 
139 // VtValue requirements for HdRenderPassAovBinding
140 HD_API
141 std::ostream& operator<<(std::ostream& out,
142  const HdRenderPassAovBinding& desc);
143 HD_API
144 bool operator==(const HdRenderPassAovBinding& lhs,
145  const HdRenderPassAovBinding& rhs);
146 HD_API
147 bool operator!=(const HdRenderPassAovBinding& lhs,
148  const HdRenderPassAovBinding& rhs);
149 
150 HD_API
151 size_t hash_value(const HdRenderPassAovBinding &b);
152 
153 /// Returns true if the AOV is used as a depth binding based on its name.
154 HD_API
155 bool HdAovHasDepthSemantic(TfToken const& aovName);
156 
157 /// Returns true if the AOV is used as a depthStencil binding based on its name.
158 HD_API
159 bool HdAovHasDepthStencilSemantic(TfToken const& aovName);
160 
161 /// \class HdParsedAovToken
162 ///
163 /// Represents an AOV token which has been parsed to extract the prefix
164 /// (in the case of "primvars:"/"lpe:"/etc.).
166  HD_API
168  HD_API
169  HdParsedAovToken(TfToken const& aovName);
170 
172  bool isPrimvar : 1;
173  bool isLpe : 1;
174  bool isShader : 1;
175 };
176 typedef std::vector<HdParsedAovToken> HdParsedAovTokenVector;
177 
179 
180 #endif // PXR_IMAGING_HD_AOV_H
VtValue clearValue
Definition: aov.h:56
bool multiSampled
Definition: aov.h:46
HdRenderBufferDescriptor(GfVec3i const &_d, HdFormat _f, bool _ms)
Definition: aov.h:71
HdFormat
Definition: types.h:408
std::vector< HdParsedAovToken > HdParsedAovTokenVector
Definition: aov.h:176
HD_API bool HdAovHasDepthSemantic(TfToken const &aovName)
Returns true if the AOV is used as a depth binding based on its name.
HD_API std::ostream & operator<<(std::ostream &out, const HdRenderPassAovBinding &desc)
#define HD_API
Definition: api.h:23
HdAovSettingsMap aovSettings
Definition: aov.h:134
HdAovSettingsMap aovSettings
Definition: aov.h:60
bool isShader
Definition: aov.h:174
bool operator!=(HdRenderBufferDescriptor const &rhs) const
Definition: aov.h:88
bool isPrimvar
Definition: aov.h:172
HdFormat format
The AOV output format. See also HdRenderBufferDescriptor::format.
Definition: aov.h:42
HD_API size_t hash_value(const HdRenderPassAovBinding &b)
GLfloat f
Definition: glcorearb.h:1926
Definition: token.h:70
bool operator==(HdRenderBufferDescriptor const &rhs) const
Definition: aov.h:84
PXR_NAMESPACE_OPEN_SCOPE typedef TfHashMap< TfToken, VtValue, TfToken::HashFunctor > HdAovSettingsMap
Definition: aov.h:21
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
std::vector< HdAovDescriptor > HdAovDescriptorList
Definition: aov.h:62
Definition: vec3i.h:43
HD_API bool HdAovHasDepthStencilSemantic(TfToken const &aovName)
Returns true if the AOV is used as a depthStencil binding based on its name.
Definition: path.h:273
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
SdfPath renderBufferId
The render buffer to be bound to the above terminal output.
Definition: aov.h:124
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HdFormat format
The data format of the render buffer. See also HdAovDescriptor::format.
Definition: aov.h:78
VtValue clearValue
Definition: aov.h:130
HdAovDescriptor(HdFormat f, bool ms, VtValue const &c)
Definition: aov.h:34
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool isLpe
Definition: aov.h:173
GfVec3i dimensions
The width, height, and depth of the allocated render buffer.
Definition: aov.h:75
HdAovDescriptor()
Definition: aov.h:31
TfToken name
Definition: aov.h:171
std::vector< HdRenderPassAovBinding > HdRenderPassAovBindingVector
Definition: aov.h:137
HD_API HdParsedAovToken()
Definition: value.h:146
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HdRenderBuffer * renderBuffer
Definition: aov.h:121
TfToken aovName
Definition: aov.h:110