renderSettings.h
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/dictionary.h"
32 #include "pxr/base/gf/vec2i.h"
33 #include "pxr/base/gf/vec2f.h"
34 #include "pxr/base/gf/range2f.h"
35 
36 #include <vector>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
65 class HdRenderSettings : public HdBprim
66 {
67 public:
68  // Change tracking for HdRenderSettings.
69  enum DirtyBits : HdDirtyBits {
70  Clean = 0,
71  DirtyActive = 1 << 1,
72  DirtySettings = 1 << 2,
73  DirtyRenderProducts = 1 << 3,
74  AllDirty = DirtyActive
75  | DirtySettings
76  | DirtyRenderProducts
77  };
78 
79  // Parameters that may be queried and invalidated.
80  //
81  // \note This mirrors UsdRender except that the render products and vars
82  // are "flattened out" similar to UsdRenderSpec.
83  struct RenderProduct {
84  struct RenderVar {
85  SdfPath varPath;
86  TfToken dataType;
87  std::string sourceName;
88  TfToken sourceType;
89  VtDictionary extraSettings;
90  };
91 
93  //
94  // Path to product prim in scene description.
95  SdfPath productPath;
96  // The type of product, ex: "raster".
97  TfToken type;
98  // The name of the product, which uniquely identifies it.
99  TfToken name;
100  // The pixel resolution of the product.
101  GfVec2i resolution;
102  // The render vars that the product is comprised of.
103  std::vector<RenderVar> renderVars;
104 
106  //
107  // Path to the camera to use for this product.
108  SdfPath cameraPath;
109  // The pixel aspect ratio as adjusted by aspectRatioConformPolicy.
110  float pixelAspectRatio;
111  // The policy that was applied to conform aspect ratio
112  // mismatches between the aperture and image.
113  TfToken aspectRatioConformPolicy;
114  // The camera aperture size as adjusted by aspectRatioConformPolicy.
115  GfVec2f apertureSize;
116  // The data window, in NDC terms relative to the aperture.
117  // (0,0) corresponds to bottom-left and (1,1) corresponds to
118  // top-right. Note that the data window can partially cover
119  // or extend beyond the unit range, for representing overscan
120  // or cropped renders.
121  GfRange2f dataWindowNDC;
122 
124  //
125  bool disableMotionBlur;
126  VtDictionary extraSettings;
127  };
128 
129  using RenderProducts = std::vector<RenderProduct>;
131 
132  HD_API
133  ~HdRenderSettings() override;
134 
135  // ------------------------------------------------------------------------
136  // Public API
137  // ------------------------------------------------------------------------
138  HD_API
139  bool IsActive() const;
140 
141  HD_API
142  const NamespacedSettings& GetSettings() const;
143 
144  HD_API
145  const RenderProducts& GetRenderProducts() const;
146 
147  // XXX Add API to query AOV bindings.
148 
149  // ------------------------------------------------------------------------
150  // Satisfying HdBprim
151  // ------------------------------------------------------------------------
152  HD_API
153  void
154  Sync(HdSceneDelegate *sceneDelegate,
155  HdRenderParam *renderParam,
156  HdDirtyBits *dirtyBits) override final;
157 
158  HD_API
159  HdDirtyBits
160  GetInitialDirtyBitsMask() const override;
161 
162 protected:
163  HD_API
164  HdRenderSettings(SdfPath const& id);
165 
166  // ------------------------------------------------------------------------
167  // Virtual API
168  // ------------------------------------------------------------------------
169  // This is called during Sync after dirty processing and before clearing the
170  // dirty bits.
171  virtual void
172  _Sync(HdSceneDelegate *sceneDelegate,
173  HdRenderParam *renderParam,
174  const HdDirtyBits *dirtyBits);
175 
176 
177 private:
178  // Class cannot be default constructed or copied.
179  HdRenderSettings() = delete;
180  HdRenderSettings(const HdRenderSettings &) = delete;
181  HdRenderSettings &operator =(const HdRenderSettings &) = delete;
182 
183  bool _active;
184  NamespacedSettings _settings;
185  RenderProducts _products;
186 };
187 
188 // VtValue requirements
189 HD_API
190 size_t hash_value(HdRenderSettings::RenderProduct const &rp);
191 
192 HD_API
193 std::ostream& operator<<(
194  std::ostream& out, const HdRenderSettings::RenderProduct&);
195 
196 HD_API
197 bool operator==(const HdRenderSettings::RenderProduct& lhs,
198  const HdRenderSettings::RenderProduct& rhs);
199 HD_API
200 bool operator!=(const HdRenderSettings::RenderProduct& lhs,
201  const HdRenderSettings::RenderProduct& rhs);
202 HD_API
203 std::ostream& operator<<(
204  std::ostream& out, const HdRenderSettings::RenderProduct::RenderVar&);
205 
206 HD_API
207 bool operator==(const HdRenderSettings::RenderProduct::RenderVar& lhs,
208  const HdRenderSettings::RenderProduct::RenderVar& rhs);
209 HD_API
210 bool operator!=(const HdRenderSettings::RenderProduct::RenderVar& lhs,
211  const HdRenderSettings::RenderProduct::RenderVar& rhs);
212 
213 
214 PXR_NAMESPACE_CLOSE_SCOPE
215 
216 #endif // PXR_IMAGING_HD_RENDER_SETTINGS_H
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.
Basic type for a vector of 2 int components.
Definition: vec2i.h:60
A map with string keys and VtValue values.
Definition: dictionary.h:63
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Abstract hydra prim backing render settings scene description.
Basic type for a vector of 2 float components.
Definition: vec2f.h:62
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:56
Basic type: 2-dimensional floating point range.
Definition: range2f.h:63