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 PXR_IMAGING_HD_RENDER_DELEGATE_H
25 #define PXR_IMAGING_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/imaging/hd/command.h"
32 #include "pxr/base/vt/dictionary.h"
33 #include "pxr/base/tf/token.h"
34 
35 #include <memory>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
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 class HdDriver;
48 
49 using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
50 using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
51 using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
52 using HdDriverVector = std::vector<HdDriver*>;
53 
60 {
61 public:
62  HdRenderParam() {}
63  HD_API
64  virtual ~HdRenderParam();
65 
66 private:
67  // Hydra will not attempt to copy the class.
68  HdRenderParam(const HdRenderParam &) = delete;
69  HdRenderParam &operator =(const HdRenderParam &) = delete;
70 };
71 
72 typedef TfHashMap<TfToken, VtValue, TfToken::HashFunctor> HdRenderSettingsMap;
73 
79 {
80  // A human readable name.
81  std::string name;
82  // The key for HdRenderDelegate::SetRenderSetting/GetRenderSetting.
83  TfToken key;
84  // The default value.
85  VtValue defaultValue;
86 };
87 
88 typedef std::vector<HdRenderSettingDescriptor> HdRenderSettingDescriptorList;
89 
92 class HdRenderDelegate
93 {
94 public:
95  HD_API
96  virtual ~HdRenderDelegate();
97 
103  HD_API
104  virtual void SetDrivers(HdDriverVector const& drivers);
105 
110  virtual const TfTokenVector &GetSupportedRprimTypes() const = 0;
111 
116  virtual const TfTokenVector &GetSupportedSprimTypes() const = 0;
117 
118 
123  virtual const TfTokenVector &GetSupportedBprimTypes() const = 0;
124 
137  HD_API
138  virtual HdRenderParam *GetRenderParam() const;
139 
144  virtual HdResourceRegistrySharedPtr GetResourceRegistry() const = 0;
145 
149  HD_API
150  virtual void SetRenderSetting(TfToken const& key, VtValue const& value);
151 
155  HD_API
156  virtual VtValue GetRenderSetting(TfToken const& key) const;
157 
162  template<typename T>
163  T GetRenderSetting(TfToken const& key, T const& defValue) const {
164  return GetRenderSetting(key).Cast<T>().GetWithDefault(defValue);
165  }
166 
170  HD_API
171  virtual HdRenderSettingDescriptorList GetRenderSettingDescriptors() const;
172 
176  HD_API
177  virtual unsigned int GetRenderSettingsVersion() const;
178 
182  HD_API
183  virtual VtDictionary GetRenderStats() const;
184 
190 
195  HD_API
196  virtual bool IsPauseSupported() const;
197 
202  HD_API
203  virtual bool IsPaused() const;
204 
211  HD_API
212  virtual bool Pause();
213 
220  HD_API
221  virtual bool Resume();
222 
227  HD_API
228  virtual bool IsStopSupported() const;
229 
234  HD_API
235  virtual bool IsStopped() const;
236 
244  HD_API
245  virtual bool Stop(bool blocking = true);
246 
253  HD_API
254  virtual bool Restart();
255 
261 
268  virtual HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
269  HdRprimCollection const& collection) = 0;
270 
279  HD_API
280  virtual HdRenderPassStateSharedPtr CreateRenderPassState() const;
281 
287 
293  virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
294  SdfPath const& id) = 0;
295 
296  virtual void DestroyInstancer(HdInstancer *instancer) = 0;
297 
303 
304 
311  virtual HdRprim *CreateRprim(TfToken const& typeId,
312  SdfPath const& rprimId) = 0;
313 
317  virtual void DestroyRprim(HdRprim *rPrim) = 0;
318 
325  virtual HdSprim *CreateSprim(TfToken const& typeId,
326  SdfPath const& sprimId) = 0;
327 
337  virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) = 0;
338 
342  virtual void DestroySprim(HdSprim *sprim) = 0;
343 
350  virtual HdBprim *CreateBprim(TfToken const& typeId,
351  SdfPath const& bprimId) = 0;
352 
353 
363  virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) = 0;
364 
368  virtual void DestroyBprim(HdBprim *bprim) = 0;
369 
375 
387  virtual void CommitResources(HdChangeTracker *tracker) = 0;
388 
394 
400  HD_API
401  virtual TfToken GetMaterialBindingPurpose() const;
402 
403 
405  HD_API
406  virtual TfToken GetMaterialNetworkSelector() const;
407 
413  HD_API
414  virtual TfTokenVector GetMaterialRenderContexts() const;
415 
424  HD_API
425  virtual bool IsPrimvarFilteringNeeded() const;
426 
431  HD_API
432  virtual TfTokenVector GetShaderSourceTypes() const;
433 
439 
444  HD_API
445  virtual HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const;
446 
452 
456  HD_API
457  virtual HdCommandDescriptors GetCommandDescriptors() const;
458 
467  HD_API
468  virtual bool InvokeCommand(
469  const TfToken &command,
470  const HdCommandArgs &args = HdCommandArgs());
471 
474  HD_API
475  const std::string &GetRendererDisplayName() {
476  return _displayName;
477  }
478 
479 protected:
481  HD_API
482  HdRenderDelegate();
484  HD_API
485  HdRenderDelegate(HdRenderSettingsMap const& settingsMap);
486 
490  HdRenderDelegate(const HdRenderDelegate &) = delete;
491  HdRenderDelegate &operator=(const HdRenderDelegate &) = delete;
492 
493  HD_API
494  void _PopulateDefaultSettings(
495  HdRenderSettingDescriptorList const& defaultSettings);
496 
498  HdRenderSettingsMap _settingsMap;
499  unsigned int _settingsVersion;
500 
501 private:
502 
503  friend class HdRendererPluginRegistry;
508  void _SetRendererDisplayName(const std::string &displayName) {
509  _displayName = displayName;
510  }
511  std::string _displayName;
512 
513 };
514 
515 PXR_NAMESPACE_CLOSE_SCOPE
516 
517 #endif //PXR_IMAGING_HD_RENDER_DELEGATE_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:120
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:51
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:124
A map with string keys and VtValue values.
Definition: dictionary.h:63
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:87
An abstract class representing a single render iteration over a set of prims (the HdRprimCollection),...
Definition: renderPass.h:69
HdDriver represents a device object, commonly a render device, that is owned by the application and p...
Definition: driver.h:40
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:54
Adapter class providing data exchange with the client scene graph.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:51
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 ("Arbitrary Output Variable") 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:166
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...