renderDelegate.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_RENDER_DELEGATE_H
8 #define PXR_IMAGING_HD_RENDER_DELEGATE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/aov.h"
13 #include "pxr/imaging/hd/changeTracker.h"
14 #include "pxr/imaging/hd/command.h"
15 #include "pxr/imaging/hd/dataSource.h"
16 #include "pxr/imaging/hd/rendererCreateArgs.h"
17 #include "pxr/base/vt/dictionary.h"
18 #include "pxr/base/tf/token.h"
19 
20 #include <memory>
21 
22 PXR_NAMESPACE_OPEN_SCOPE
23 
24 class SdfPath;
25 class HdRprim;
26 class HdSprim;
27 class HdBprim;
28 class HdSceneDelegate;
29 class HdRenderIndex;
30 class HdRenderPass;
31 class HdInstancer;
32 class HdDriver;
33 class Hgi;
34 
36 
37 using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
38 using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
39 using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
40 using HdDriverVector = std::vector<HdDriver*>;
41 
48 {
49 public:
50  HdRenderParam() {}
51  HD_API
52  virtual ~HdRenderParam();
53 
59  HD_API
60  virtual bool SetArbitraryValue(const TfToken& key, const VtValue& value);
61 
69  HD_API
70  virtual VtValue GetArbitraryValue(const TfToken& key) const;
71 
76  HD_API
77  virtual bool HasArbitraryValue(const TfToken& key) const;
78 
79  HD_API
80  virtual bool IsValid() const;
81 
82 private:
83  // Hydra will not attempt to copy the class.
84  HdRenderParam(const HdRenderParam &) = delete;
85  HdRenderParam &operator =(const HdRenderParam &) = delete;
86 };
87 
88 typedef TfHashMap<TfToken, VtValue, TfToken::HashFunctor> HdRenderSettingsMap;
89 
95 {
96  // A human readable name.
97  std::string name;
98  // The key for HdRenderDelegate::SetRenderSetting/GetRenderSetting.
99  TfToken key;
100  // The default value.
101  VtValue defaultValue;
102 };
103 
104 typedef std::vector<HdRenderSettingDescriptor> HdRenderSettingDescriptorList;
105 
108 class HdRenderDelegate
109 {
110 public:
111  HD_API
112  virtual ~HdRenderDelegate();
113 
119  HD_API
120  virtual void SetDrivers(HdDriverVector const& drivers);
121 
126  virtual const TfTokenVector &GetSupportedRprimTypes() const = 0;
127 
132  virtual const TfTokenVector &GetSupportedSprimTypes() const = 0;
133 
134 
139  virtual const TfTokenVector &GetSupportedBprimTypes() const = 0;
140 
153  HD_API
154  virtual HdRenderParam *GetRenderParam() const;
155 
160  virtual HdResourceRegistrySharedPtr GetResourceRegistry() const = 0;
161 
165  HD_API
166  virtual void SetRenderSetting(TfToken const& key, VtValue const& value);
167 
171  HD_API
172  virtual VtValue GetRenderSetting(TfToken const& key) const;
173 
178  template<typename T>
179  T GetRenderSetting(TfToken const& key, T const& defValue) const {
180  return GetRenderSetting(key).Cast<T>().GetWithDefault(defValue);
181  }
182 
186  HD_API
187  virtual HdRenderSettingDescriptorList GetRenderSettingDescriptors() const;
188 
192  HD_API
193  virtual unsigned int GetRenderSettingsVersion() const;
194 
198  HD_API
199  virtual VtDictionary GetRenderStats() const;
200 
205  HD_API
206  virtual HdContainerDataSourceHandle GetCapabilities() const;
207 
213 
218  HD_API
219  virtual bool IsPauseSupported() const;
220 
225  HD_API
226  virtual bool IsPaused() const;
227 
234  HD_API
235  virtual bool Pause();
236 
243  HD_API
244  virtual bool Resume();
245 
250  HD_API
251  virtual bool IsStopSupported() const;
252 
257  HD_API
258  virtual bool IsStopped() const;
259 
267  HD_API
268  virtual bool Stop(bool blocking = true);
269 
276  HD_API
277  virtual bool Restart();
278 
284 
291  virtual HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
292  HdRprimCollection const& collection) = 0;
293 
302  HD_API
303  virtual HdRenderPassStateSharedPtr CreateRenderPassState() const;
304 
310 
316  virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
317  SdfPath const& id) = 0;
318 
319  virtual void DestroyInstancer(HdInstancer *instancer) = 0;
320 
326 
327 
334  virtual HdRprim *CreateRprim(TfToken const& typeId,
335  SdfPath const& rprimId) = 0;
336 
340  virtual void DestroyRprim(HdRprim *rPrim) = 0;
341 
348  virtual HdSprim *CreateSprim(TfToken const& typeId,
349  SdfPath const& sprimId) = 0;
350 
360  virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) = 0;
361 
365  virtual void DestroySprim(HdSprim *sprim) = 0;
366 
373  virtual HdBprim *CreateBprim(TfToken const& typeId,
374  SdfPath const& bprimId) = 0;
375 
376 
386  virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) = 0;
387 
391  virtual void DestroyBprim(HdBprim *bprim) = 0;
392 
398 
410  virtual void CommitResources(HdChangeTracker *tracker) = 0;
411 
417 
423  HD_API
424  virtual TfToken GetMaterialBindingPurpose() const;
425 
426 
428  HD_API
429  virtual TfToken GetMaterialNetworkSelector() const;
430 
436  HD_API
437  virtual TfTokenVector GetMaterialRenderContexts() const;
438 
444  HD_API
445  virtual TfTokenVector GetRenderSettingsNamespaces() const;
446 
455  HD_API
456  virtual bool IsPrimvarFilteringNeeded() const;
457 
458 
463  HD_API
464  virtual TfTokenVector GetShadingSystems() const;
465 
472  HD_API
473  virtual TfTokenVector GetShaderSourceTypes() const;
474 
480 
485  HD_API
486  virtual HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const;
487 
493 
497  HD_API
498  virtual HdCommandDescriptors GetCommandDescriptors() const;
499 
508  HD_API
509  virtual bool InvokeCommand(
510  const TfToken &command,
511  const HdCommandArgs &args = HdCommandArgs());
512 
515  HD_API
516  const std::string &GetRendererDisplayName() {
517  return _displayName;
518  }
519 
528 
536  HD_API
537  virtual void SetTerminalSceneIndex(
538  const HdSceneIndexBaseRefPtr &terminalSceneIndex);
539 
545  HD_API
546  virtual void Update();
547 
550  HD_API
551  virtual bool IsParallelSyncEnabled(const TfToken &primType) const;
552 
557  HD_API
558  virtual bool RequiresStormTasks() const;
559 
560 protected:
562  HD_API
563  HdRenderDelegate();
565  HD_API
566  HdRenderDelegate(HdRenderSettingsMap const& settingsMap);
567 
571  HdRenderDelegate(const HdRenderDelegate &) = delete;
572  HdRenderDelegate &operator=(const HdRenderDelegate &) = delete;
573 
574  HD_API
575  void _PopulateDefaultSettings(
576  HdRenderSettingDescriptorList const& defaultSettings);
577 
579  HdRenderSettingsMap _settingsMap;
580  unsigned int _settingsVersion;
581 
582 private:
583 
584  friend class HdRendererPlugin;
589  void _SetRendererDisplayName(const std::string &displayName) {
590  _displayName = displayName;
591  }
592  std::string _displayName;
593 
594 };
595 
596 PXR_NAMESPACE_CLOSE_SCOPE
597 
598 #endif //PXR_IMAGING_HD_RENDER_DELEGATE_H
The render index is part of the Hydra 1.0 API and is only used for emulation purposes so that HdScene...
Definition: renderIndex.h:110
This class defines a renderer plugin interface for Hydra.
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:34
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:108
A map with string keys and VtValue values.
Definition: dictionary.h:52
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:80
An abstract class representing a single render iteration over a set of prims (the HdRprimCollection),...
Definition: renderPass.h:52
HdDriver represents a device object, commonly a render device, that is owned by the application and p...
Definition: driver.h:23
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:37
virtual HD_API bool HasArbitraryValue(const TfToken &key) const
Check whether a valid custom value exists for the specified key in the render param's implementation.
Adapter class providing data exchange with the client scene graph.
Abstract interface to scene data.
Definition: sceneIndex.h:54
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:489
A named, semantic collection of objects.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:280
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:34
Hydra Graphics Interface.
Definition: hgi.h:94
virtual HD_API VtValue GetArbitraryValue(const TfToken &key) const
Retrieve a custom value identified by key from the render param's implementation.
virtual HD_API bool SetArbitraryValue(const TfToken &key, const VtValue &value)
Set a custom value in the render param's implementation.
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:39
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
A bundle of state describing an AOV ("Arbitrary Output Variable") display channel.
Definition: aov.h:29
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:89
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...