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/range2f.h"
36 
37 #include <vector>
38 
40 
41 ///
42 /// Hydra prim backing render settings scene description.
43 /// While it is a state prim (Sprim) in spirit, it is made to be a Bprim to
44 /// ensure that it is sync'd prior to Sprims and Rprims to allow render setting
45 /// opinions to be discovered and inform the sync process of those prims.
46 ///
47 /// \note Hydra has several "render settings" concepts as of this writing, which
48 /// can be confusing. We have:
49 /// - HdRenderSettingsMap: A dictionary of token-value pairs that is provided
50 /// as an argument for render delegate construction.
51 /// - HdRenderSettingsDescriptorList: A mechanism to discover and update
52 /// render settings on the render delegate.
53 /// - Render task params: This currently captures opinions such as the camera to
54 /// use, the AOV outputs, etc.
55 ///
56 /// We aim to transition away from the API and task based render settings
57 /// opinions above to using render settings scene description to drive
58 /// rendering in Hydra.
59 ///
60 /// \sa HdRenderSettingsPrimTokens (defined in hd/tokens.h) for tokens
61 /// permitted in (legacy) scene delegate queries via Get(...).
62 ///
63 /// \sa HdRenderSettingsSchema for querying locators and building container
64 /// data sources when using scene indices.
65 ///
66 class HdRenderSettings : public HdBprim
67 {
68 public:
69  // Change tracking for HdRenderSettings.
71  Clean = 0,
72  DirtyActive = 1 << 1,
84  };
85 
86  // Parameters that may be queried and invalidated.
87  //
88  // \note This mirrors UsdRender except that the render products and vars
89  // are "flattened out" similar to UsdRenderSpec.
90  struct RenderProduct {
91  struct RenderVar {
97  };
98 
99  /// Identification & output information
100  //
101  // Path to product prim in scene description.
103  // The type of product, ex: "raster".
105  // The name of the product, which uniquely identifies it.
107  // The pixel resolution of the product.
109  // The render vars that the product is comprised of.
110  std::vector<RenderVar> renderVars;
111 
112  /// Camera and framing
113  //
114  // Path to the camera to use for this product.
116  // The pixel aspect ratio as adjusted by aspectRatioConformPolicy.
118  // The policy that was applied to conform aspect ratio
119  // mismatches between the aperture and image.
121  // The camera aperture size as adjusted by aspectRatioConformPolicy.
123  // The data window, in NDC terms relative to the aperture.
124  // (0,0) corresponds to bottom-left and (1,1) corresponds to
125  // top-right. Note that the data window can partially cover
126  // or extend beyond the unit range, for representing overscan
127  // or cropped renders.
129 
130  /// Settings overrides
131  //
134  };
135 
136  using RenderProducts = std::vector<RenderProduct>;
138 
139  HD_API
140  ~HdRenderSettings() override;
141 
142  // ------------------------------------------------------------------------
143  // Public API
144  // ------------------------------------------------------------------------
145  HD_API
146  bool IsActive() const;
147 
148  HD_API
150 
151  HD_API
152  unsigned int GetSettingsVersion() const;
153 
154  HD_API
155  const RenderProducts& GetRenderProducts() const;
156 
157  HD_API
158  const VtArray<TfToken>& GetIncludedPurposes() const;
159 
160  HD_API
162 
163  HD_API
164  const TfToken& GetRenderingColorSpace() const;
165 
166  // XXX Add API to query AOV bindings.
167 
168  // ------------------------------------------------------------------------
169  // Satisfying HdBprim
170  // ------------------------------------------------------------------------
171  HD_API
172  void
173  Sync(HdSceneDelegate *sceneDelegate,
174  HdRenderParam *renderParam,
175  HdDirtyBits *dirtyBits) override final;
176 
177  HD_API
179  GetInitialDirtyBitsMask() const override;
180 
181 protected:
182  HD_API
183  HdRenderSettings(SdfPath const& id);
184 
185  // ------------------------------------------------------------------------
186  // Virtual API
187  // ------------------------------------------------------------------------
188  // This is called during Sync after dirty processing and before clearing the
189  // dirty bits.
190  virtual void
191  _Sync(HdSceneDelegate *sceneDelegate,
192  HdRenderParam *renderParam,
193  const HdDirtyBits *dirtyBits);
194 
195 
196 private:
197  // Class cannot be default constructed or copied.
198  HdRenderSettings() = delete;
199  HdRenderSettings(const HdRenderSettings &) = delete;
200  HdRenderSettings &operator =(const HdRenderSettings &) = delete;
201 
202  bool _active;
203  NamespacedSettings _namespacedSettings;
204  unsigned int _settingsVersion;
205  RenderProducts _products;
206  VtArray<TfToken> _includedPurposes;
207  VtArray<TfToken> _materialBindingPurposes;
208  TfToken _renderingColorSpace;
209 };
210 
211 // VtValue requirements
212 HD_API
214 
215 HD_API
216 std::ostream& operator<<(
217  std::ostream& out, const HdRenderSettings::RenderProduct&);
218 
219 HD_API
222 HD_API
225 HD_API
226 std::ostream& operator<<(
227  std::ostream& out, const HdRenderSettings::RenderProduct::RenderVar&);
228 
229 HD_API
232 HD_API
235 
236 
238 
239 #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.
HD_API unsigned int GetSettingsVersion() const
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
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
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
Definition: path.h:291
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:1441
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 &)
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542