All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderDelegate.h
1 //
2 // Copyright 2016 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 HD_RENDER_DELEGATE_H
25 #define HD_RENDER_DELEGATE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/aov.h"
30 #include "pxr/imaging/hd/changeTracker.h"
31 #include "pxr/base/vt/dictionary.h"
32 #include "pxr/base/tf/token.h"
33 
34 #include <boost/shared_ptr.hpp>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 
39 class SdfPath;
40 class HdRprim;
41 class HdSprim;
42 class HdBprim;
43 class HdSceneDelegate;
44 class HdRenderIndex;
45 class HdRenderPass;
46 class HdInstancer;
47 
48 typedef boost::shared_ptr<class HdRenderPass> HdRenderPassSharedPtr;
49 typedef boost::shared_ptr<class HdRenderPassState> HdRenderPassStateSharedPtr;
50 typedef boost::shared_ptr<class HdResourceRegistry> HdResourceRegistrySharedPtr;
51 
58 public:
59  HdRenderParam() {}
60  HD_API
61  virtual ~HdRenderParam();
62 
63 private:
64  // Hydra will not attempt to copy the class.
65  HdRenderParam(const HdRenderParam &) = delete;
66  HdRenderParam &operator =(const HdRenderParam &) = delete;
67 };
68 
69 typedef TfHashMap<TfToken, VtValue, TfToken::HashFunctor> HdRenderSettingsMap;
70 
76  // A human readable name.
77  std::string name;
78  // The key for HdRenderDelegate::SetRenderSetting/GetRenderSetting.
79  TfToken key;
80  // The default value.
81  VtValue defaultValue;
82 };
83 
84 typedef std::vector<HdRenderSettingDescriptor> HdRenderSettingDescriptorList;
85 
88 class HdRenderDelegate
89 {
90 public:
91  HD_API
92  virtual ~HdRenderDelegate();
93 
98  virtual const TfTokenVector &GetSupportedRprimTypes() const = 0;
99 
104  virtual const TfTokenVector &GetSupportedSprimTypes() const = 0;
105 
106 
111  virtual const TfTokenVector &GetSupportedBprimTypes() const = 0;
112 
125  virtual HdRenderParam *GetRenderParam() const = 0;
126 
131  virtual HdResourceRegistrySharedPtr GetResourceRegistry() const = 0;
132 
136  HD_API
137  virtual void SetRenderSetting(TfToken const& key, VtValue const& value);
138 
142  HD_API
143  virtual VtValue GetRenderSetting(TfToken const& key) const;
144 
149  template<typename T>
150  T GetRenderSetting(TfToken const& key, T const& defValue) const {
151  return GetRenderSetting(key).Cast<T>().GetWithDefault(defValue);
152  }
153 
157  HD_API
158  virtual HdRenderSettingDescriptorList GetRenderSettingDescriptors() const;
159 
163  HD_API
164  virtual unsigned int GetRenderSettingsVersion() const;
165 
169  HD_API
170  virtual VtDictionary GetRenderStats() const;
171 
177 
182  HD_API
183  virtual bool IsPauseSupported() const;
184 
191  HD_API
192  virtual bool Pause();
193 
200  HD_API
201  virtual bool Resume();
202 
208 
215  virtual HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
216  HdRprimCollection const& collection) = 0;
217 
226  HD_API
227  virtual HdRenderPassStateSharedPtr CreateRenderPassState() const;
228 
234 
242  virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
243  SdfPath const& id,
244  SdfPath const& instancerId) = 0;
245 
246  virtual void DestroyInstancer(HdInstancer *instancer) = 0;
247 
253 
254 
263  virtual HdRprim *CreateRprim(TfToken const& typeId,
264  SdfPath const& rprimId,
265  SdfPath const& instancerId) = 0;
266 
270  virtual void DestroyRprim(HdRprim *rPrim) = 0;
271 
278  virtual HdSprim *CreateSprim(TfToken const& typeId,
279  SdfPath const& sprimId) = 0;
280 
290  virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) = 0;
291 
295  virtual void DestroySprim(HdSprim *sprim) = 0;
296 
303  virtual HdBprim *CreateBprim(TfToken const& typeId,
304  SdfPath const& bprimId) = 0;
305 
306 
316  virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) = 0;
317 
321  virtual void DestroyBprim(HdBprim *bprim) = 0;
322 
328 
340  virtual void CommitResources(HdChangeTracker *tracker) = 0;
341 
347 
353  HD_API
354  virtual TfToken GetMaterialBindingPurpose() const;
355 
360  HD_API
361  virtual TfToken GetMaterialNetworkSelector() const;
362 
371  HD_API
372  virtual bool IsPrimvarFilteringNeeded() const;
373 
378  HD_API
379  virtual TfTokenVector GetShaderSourceTypes() const;
380 
386 
391  HD_API
392  virtual HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const;
393 
394 protected:
396  HD_API
397  HdRenderDelegate();
399  HD_API
400  HdRenderDelegate(HdRenderSettingsMap const& settingsMap);
401 
405  HdRenderDelegate(const HdRenderDelegate &) = delete;
406  HdRenderDelegate &operator=(const HdRenderDelegate &) = delete;
407 
408  HD_API
409  void _PopulateDefaultSettings(
410  HdRenderSettingDescriptorList const& defaultSettings);
411 
413  HdRenderSettingsMap _settingsMap;
414  unsigned int _settingsVersion;
415 };
416 
417 PXR_NAMESPACE_CLOSE_SCOPE
418 
419 #endif //HD_RENDER_DELEGATE_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
HdRenderSettingDescriptor represents a render setting that a render delegate wants to export (e...
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine...
Definition: changeTracker.h:55
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:119
A map with string keys and VtValue values.
Definition: dictionary.h:61
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
An abstract class representing a single render iteration over a set of prims (the HdRprimCollection)...
Definition: renderPass.h:71
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:67
Adapter class providing data exchange with the client scene graph.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e...
Definition: sprim.h:54
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:56
A bundle of state describing an AOV (&quot;Alternate Output Value&quot;) display channel.
Definition: aov.h:46
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182