All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
renderSettings.h
1//
2// Copyright 2022 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_RENDER_SETTINGS_H
8#define PXR_IMAGING_HD_RENDER_SETTINGS_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/api.h"
12#include "pxr/imaging/hd/bprim.h"
13
14#include "pxr/base/vt/array.h"
16#include "pxr/base/gf/vec2i.h"
17#include "pxr/base/gf/vec2f.h"
18#include "pxr/base/gf/vec2d.h"
19#include "pxr/base/gf/range2f.h"
20
21#include <vector>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
51{
52public:
53 // Change tracking for HdRenderSettings.
54 enum DirtyBits : HdDirtyBits {
55 Clean = 0,
56 DirtyActive = 1 << 1,
57 DirtyNamespacedSettings = 1 << 2,
58 DirtyRenderProducts = 1 << 3,
59 DirtyIncludedPurposes = 1 << 4,
60 DirtyMaterialBindingPurposes = 1 << 5,
61 DirtyRenderingColorSpace = 1 << 6,
62 DirtyShutterInterval = 1 << 7,
63 DirtyFrameNumber = 1 << 8,
64 AllDirty = DirtyActive
65 | DirtyNamespacedSettings
66 | DirtyRenderProducts
67 | DirtyIncludedPurposes
68 | DirtyMaterialBindingPurposes
69 | DirtyRenderingColorSpace
70 | DirtyShutterInterval
71 | DirtyFrameNumber
72 };
73
74 // Parameters that may be queried and invalidated.
75 //
76 // \note This mirrors UsdRender except that the render products and vars
77 // are "flattened out" similar to UsdRenderSpec.
78 struct RenderProduct {
79 struct RenderVar {
80 SdfPath varPath;
81 TfToken dataType;
82 std::string sourceName;
83 TfToken sourceType;
84 VtDictionary namespacedSettings;
85 };
86
88 //
89 // Path to product prim in scene description.
90 SdfPath productPath;
91 // The type of product, ex: "raster".
92 TfToken type;
93 // The name of the product, which uniquely identifies it.
94 TfToken name;
95 // The pixel resolution of the product.
96 GfVec2i resolution = GfVec2i(0);
97 // The render vars that the product is comprised of.
98 std::vector<RenderVar> renderVars;
99
101 //
102 // Path to the camera to use for this product.
103 SdfPath cameraPath;
104 // The pixel aspect ratio as adjusted by aspectRatioConformPolicy.
105 float pixelAspectRatio;
106 // The policy that was applied to conform aspect ratio
107 // mismatches between the aperture and image.
108 TfToken aspectRatioConformPolicy;
109 // The camera aperture size as adjusted by aspectRatioConformPolicy.
110 GfVec2f apertureSize = GfVec2f(0);
111 // The data window, in NDC terms relative to the aperture.
112 // (0,0) corresponds to bottom-left and (1,1) corresponds to
113 // top-right. Note that the data window can partially cover
114 // or extend beyond the unit range, for representing overscan
115 // or cropped renders.
116 GfRange2f dataWindowNDC;
117
119 //
120 bool disableMotionBlur;
121 bool disableDepthOfField;
122 VtDictionary namespacedSettings;
123 };
124
125 using RenderProducts = std::vector<RenderProduct>;
127
128 HD_API
129 ~HdRenderSettings() override;
130
131 // ------------------------------------------------------------------------
132 // Public API
133 // ------------------------------------------------------------------------
134 HD_API
135 bool IsActive() const;
136
137 HD_API
138 bool IsValid() const;
139
140 HD_API
141 const NamespacedSettings& GetNamespacedSettings() const;
142
143 HD_API
144 const RenderProducts& GetRenderProducts() const;
145
146 HD_API
147 const VtArray<TfToken>& GetIncludedPurposes() const;
148
149 HD_API
150 const VtArray<TfToken>& GetMaterialBindingPurposes() const;
151
152 HD_API
153 const TfToken& GetRenderingColorSpace() const;
154
155 // XXX Using VtValue in a std::optional (C++17) sense.
156 HD_API
157 const VtValue& GetShutterInterval() const;
158
166 HD_API
168
169 // ------------------------------------------------------------------------
170 // Satisfying HdBprim
171 // ------------------------------------------------------------------------
172 HD_API
173 void
174 Sync(HdSceneDelegate *sceneDelegate,
175 HdRenderParam *renderParam,
176 HdDirtyBits *dirtyBits) override final;
177
178 HD_API
179 HdDirtyBits
180 GetInitialDirtyBitsMask() const override;
181
182protected:
183 HD_API
184 HdRenderSettings(SdfPath const& id);
185
186 // ------------------------------------------------------------------------
187 // Virtual API
188 // ------------------------------------------------------------------------
189 // This is called during Sync after dirty processing and before clearing the
190 // dirty bits.
191 virtual void
192 _Sync(HdSceneDelegate *sceneDelegate,
193 HdRenderParam *renderParam,
194 const HdDirtyBits *dirtyBits);
195
196
197private:
198 // Class cannot be default constructed or copied.
199 HdRenderSettings() = delete;
200 HdRenderSettings(const HdRenderSettings &) = delete;
201 HdRenderSettings &operator =(const HdRenderSettings &) = delete;
202
203 bool _active;
204 bool _dirtyProducts;
205 NamespacedSettings _namespacedSettings;
206 RenderProducts _products;
207 VtArray<TfToken> _includedPurposes;
208 VtArray<TfToken> _materialBindingPurposes;
209 TfToken _renderingColorSpace;
210 VtValue _vShutterInterval;
211};
212
213// VtValue requirements
214HD_API
215size_t hash_value(HdRenderSettings::RenderProduct const &rp);
216
217HD_API
218std::ostream& operator<<(
219 std::ostream& out, const HdRenderSettings::RenderProduct&);
220
221HD_API
222bool operator==(const HdRenderSettings::RenderProduct& lhs,
223 const HdRenderSettings::RenderProduct& rhs);
224HD_API
225bool operator!=(const HdRenderSettings::RenderProduct& lhs,
226 const HdRenderSettings::RenderProduct& rhs);
227HD_API
228std::ostream& operator<<(
229 std::ostream& out, const HdRenderSettings::RenderProduct::RenderVar&);
230
231HD_API
232bool operator==(const HdRenderSettings::RenderProduct::RenderVar& lhs,
233 const HdRenderSettings::RenderProduct::RenderVar& rhs);
234HD_API
235bool operator!=(const HdRenderSettings::RenderProduct::RenderVar& lhs,
236 const HdRenderSettings::RenderProduct::RenderVar& rhs);
237
238
239PXR_NAMESPACE_CLOSE_SCOPE
240
241#endif // PXR_IMAGING_HD_RENDER_SETTINGS_H
Basic type: 2-dimensional floating point range.
Definition: range2f.h:47
Basic type for a vector of 2 float components.
Definition: vec2f.h:46
Basic type for a vector of 2 int components.
Definition: vec2i.h:44
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:40
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Hydra prim backing render settings scene description.
HD_API bool GetAndResetHasDirtyProducts()
Returns whether the render products were invalidated since the last time this function was called.
HD_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the minimal set of dirty bits to place in the change tracker for use in the first sync of thi...
HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) override final
Synchronizes state from the delegate to this object.
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:211
A map with string keys and VtValue values.
Definition: dictionary.h:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].