HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderSettings.h
Go to the documentation of this file.
1 //
2 // Copyright 2022 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_RENDER_SETTINGS_H
25 #define PXR_IMAGING_HD_RENDER_SETTINGS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/bprim.h"
30 
31 #include "pxr/base/vt/array.h"
32 #include "pxr/base/vt/dictionary.h"
33 #include "pxr/base/gf/vec2i.h"
34 #include "pxr/base/gf/vec2f.h"
35 #include "pxr/base/gf/vec2d.h"
36 #include "pxr/base/gf/range2f.h"
37 
38 #include <vector>
39 
41 
42 ///
43 /// Hydra prim backing render settings scene description.
44 /// While it is a state prim (Sprim) in spirit, it is made to be a Bprim to
45 /// ensure that it is sync'd prior to Sprims and Rprims to allow render setting
46 /// opinions to be discovered and inform the sync process of those prims.
47 ///
48 /// \note Hydra has several "render settings" concepts as of this writing, which
49 /// can be confusing. We have:
50 /// - HdRenderSettingsMap: A dictionary of token-value pairs that is provided
51 /// as an argument for render delegate construction.
52 /// - HdRenderSettingsDescriptorList: A mechanism to discover and update
53 /// render settings on the render delegate.
54 /// - Render task params: This currently captures opinions such as the camera to
55 /// use, the AOV outputs, etc.
56 ///
57 /// We aim to transition away from the API and task based render settings
58 /// opinions above to using render settings scene description to drive
59 /// rendering in Hydra.
60 ///
61 /// \sa HdRenderSettingsPrimTokens (defined in hd/tokens.h) for tokens
62 /// permitted in (legacy) scene delegate queries via Get(...).
63 ///
64 /// \sa HdRenderSettingsSchema for querying locators and building container
65 /// data sources when using scene indices.
66 ///
67 class HdRenderSettings : public HdBprim
68 {
69 public:
70  // Change tracking for HdRenderSettings.
72  Clean = 0,
73  DirtyActive = 1 << 1,
87  };
88 
89  // Parameters that may be queried and invalidated.
90  //
91  // \note This mirrors UsdRender except that the render products and vars
92  // are "flattened out" similar to UsdRenderSpec.
93  struct RenderProduct {
94  struct RenderVar {
100  };
101 
102  /// Identification & output information
103  //
104  // Path to product prim in scene description.
106  // The type of product, ex: "raster".
108  // The name of the product, which uniquely identifies it.
110  // The pixel resolution of the product.
112  // The render vars that the product is comprised of.
113  std::vector<RenderVar> renderVars;
114 
115  /// Camera and framing
116  //
117  // Path to the camera to use for this product.
119  // The pixel aspect ratio as adjusted by aspectRatioConformPolicy.
121  // The policy that was applied to conform aspect ratio
122  // mismatches between the aperture and image.
124  // The camera aperture size as adjusted by aspectRatioConformPolicy.
126  // The data window, in NDC terms relative to the aperture.
127  // (0,0) corresponds to bottom-left and (1,1) corresponds to
128  // top-right. Note that the data window can partially cover
129  // or extend beyond the unit range, for representing overscan
130  // or cropped renders.
132 
133  /// Settings overrides
134  //
138  };
139 
140  using RenderProducts = std::vector<RenderProduct>;
142 
143  HD_API
144  ~HdRenderSettings() override;
145 
146  // ------------------------------------------------------------------------
147  // Public API
148  // ------------------------------------------------------------------------
149  HD_API
150  bool IsActive() const;
151 
152  HD_API
153  bool IsValid() const;
154 
155  HD_API
157 
158  HD_API
159  const RenderProducts& GetRenderProducts() const;
160 
161  HD_API
162  const VtArray<TfToken>& GetIncludedPurposes() const;
163 
164  HD_API
166 
167  HD_API
168  const TfToken& GetRenderingColorSpace() const;
169 
170  // XXX Using VtValue in a std::optional (C++17) sense.
171  HD_API
172  const VtValue& GetShutterInterval() const;
173 
174  // ------------------------------------------------------------------------
175  // Satisfying HdBprim
176  // ------------------------------------------------------------------------
177  HD_API
178  void
179  Sync(HdSceneDelegate *sceneDelegate,
180  HdRenderParam *renderParam,
181  HdDirtyBits *dirtyBits) override final;
182 
183  HD_API
185  GetInitialDirtyBitsMask() const override;
186 
187 protected:
188  HD_API
189  HdRenderSettings(SdfPath const& id);
190 
191  // ------------------------------------------------------------------------
192  // Virtual API
193  // ------------------------------------------------------------------------
194  // This is called during Sync after dirty processing and before clearing the
195  // dirty bits.
196  virtual void
197  _Sync(HdSceneDelegate *sceneDelegate,
198  HdRenderParam *renderParam,
199  const HdDirtyBits *dirtyBits);
200 
201 
202 private:
203  // Class cannot be default constructed or copied.
204  HdRenderSettings() = delete;
205  HdRenderSettings(const HdRenderSettings &) = delete;
206  HdRenderSettings &operator =(const HdRenderSettings &) = delete;
207 
208  bool _active;
209  NamespacedSettings _namespacedSettings;
210  RenderProducts _products;
211  VtArray<TfToken> _includedPurposes;
212  VtArray<TfToken> _materialBindingPurposes;
213  TfToken _renderingColorSpace;
214  VtValue _vShutterInterval;
215 };
216 
217 // VtValue requirements
218 HD_API
220 
221 HD_API
222 std::ostream& operator<<(
223  std::ostream& out, const HdRenderSettings::RenderProduct&);
224 
225 HD_API
228 HD_API
231 HD_API
232 std::ostream& operator<<(
233  std::ostream& out, const HdRenderSettings::RenderProduct::RenderVar&);
234 
235 HD_API
238 HD_API
241 
242 
244 
245 #endif // PXR_IMAGING_HD_RENDER_SETTINGS_H
HD_API bool IsActive() const
HD_API const VtArray< TfToken > & GetIncludedPurposes() const
Definition: vec2i.h:60
HD_API const NamespacedSettings & GetNamespacedSettings() const
std::vector< RenderProduct > RenderProducts
bool disableMotionBlur
Settings overrides.
uint32_t HdDirtyBits
Definition: types.h:158
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
HD_API const RenderProducts & GetRenderProducts() const
#define HD_API
Definition: api.h:40
HD_API const VtArray< TfToken > & GetMaterialBindingPurposes() const
HD_API bool IsValid() const
virtual void _Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, const HdDirtyBits *dirtyBits)
HD_API size_t hash_value(HdRenderSettings::RenderProduct const &rp)
HD_API HdDirtyBits GetInitialDirtyBitsMask() const override
SdfPath productPath
Identification & output information.
Definition: token.h:87
HD_API ~HdRenderSettings() override
HD_API const VtValue & GetShutterInterval() const
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
Definition: path.h:290
HD_API void Sync(HdSceneDelegate *sceneDelegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits) overridefinal
HD_API const TfToken & GetRenderingColorSpace() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
std::vector< RenderVar > renderVars
Definition: vec2f.h:62
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: bprim.h:56
SdfPath cameraPath
Camera and framing.
HD_API std::ostream & operator<<(std::ostream &out, const HdRenderSettings::RenderProduct &)
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