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