This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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"
17#include "pxr/base/tf/token.h"
18
19#include <memory>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
23class SdfPath;
24class HdRprim;
25class HdSprim;
26class HdBprim;
27class HdSceneDelegate;
28class HdRenderIndex;
29class HdRenderPass;
30class HdInstancer;
31class HdDriver;
32
34
35using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
36using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
37using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
38using HdDriverVector = std::vector<HdDriver*>;
39
46{
47public:
48 HdRenderParam() {}
49 HD_API
50 virtual ~HdRenderParam();
51
57 HD_API
58 virtual bool SetArbitraryValue(const TfToken& key, const VtValue& value);
59
67 HD_API
68 virtual VtValue GetArbitraryValue(const TfToken& key) const;
69
74 HD_API
75 virtual bool HasArbitraryValue(const TfToken& key) const;
76
77private:
78 // Hydra will not attempt to copy the class.
79 HdRenderParam(const HdRenderParam &) = delete;
80 HdRenderParam &operator =(const HdRenderParam &) = delete;
81};
82
83typedef TfHashMap<TfToken, VtValue, TfToken::HashFunctor> HdRenderSettingsMap;
84
90{
91 // A human readable name.
92 std::string name;
93 // The key for HdRenderDelegate::SetRenderSetting/GetRenderSetting.
94 TfToken key;
95 // The default value.
96 VtValue defaultValue;
97};
98
99typedef std::vector<HdRenderSettingDescriptor> HdRenderSettingDescriptorList;
100
103class HdRenderDelegate
104{
105public:
106 HD_API
107 virtual ~HdRenderDelegate();
108
114 HD_API
115 virtual void SetDrivers(HdDriverVector const& drivers);
116
121 virtual const TfTokenVector &GetSupportedRprimTypes() const = 0;
122
127 virtual const TfTokenVector &GetSupportedSprimTypes() const = 0;
128
129
134 virtual const TfTokenVector &GetSupportedBprimTypes() const = 0;
135
148 HD_API
149 virtual HdRenderParam *GetRenderParam() const;
150
155 virtual HdResourceRegistrySharedPtr GetResourceRegistry() const = 0;
156
160 HD_API
161 virtual void SetRenderSetting(TfToken const& key, VtValue const& value);
162
166 HD_API
167 virtual VtValue GetRenderSetting(TfToken const& key) const;
168
173 template<typename T>
174 T GetRenderSetting(TfToken const& key, T const& defValue) const {
175 return GetRenderSetting(key).Cast<T>().GetWithDefault(defValue);
176 }
177
181 HD_API
182 virtual HdRenderSettingDescriptorList GetRenderSettingDescriptors() const;
183
187 HD_API
188 virtual unsigned int GetRenderSettingsVersion() const;
189
193 HD_API
194 virtual VtDictionary GetRenderStats() const;
195
200 HD_API
201 virtual HdContainerDataSourceHandle GetCapabilities() const;
202
208
213 HD_API
214 virtual bool IsPauseSupported() const;
215
220 HD_API
221 virtual bool IsPaused() const;
222
229 HD_API
230 virtual bool Pause();
231
238 HD_API
239 virtual bool Resume();
240
245 HD_API
246 virtual bool IsStopSupported() const;
247
252 HD_API
253 virtual bool IsStopped() const;
254
262 HD_API
263 virtual bool Stop(bool blocking = true);
264
271 HD_API
272 virtual bool Restart();
273
279
286 virtual HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
287 HdRprimCollection const& collection) = 0;
288
297 HD_API
298 virtual HdRenderPassStateSharedPtr CreateRenderPassState() const;
299
305
311 virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
312 SdfPath const& id) = 0;
313
314 virtual void DestroyInstancer(HdInstancer *instancer) = 0;
315
321
322
329 virtual HdRprim *CreateRprim(TfToken const& typeId,
330 SdfPath const& rprimId) = 0;
331
335 virtual void DestroyRprim(HdRprim *rPrim) = 0;
336
343 virtual HdSprim *CreateSprim(TfToken const& typeId,
344 SdfPath const& sprimId) = 0;
345
355 virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) = 0;
356
360 virtual void DestroySprim(HdSprim *sprim) = 0;
361
368 virtual HdBprim *CreateBprim(TfToken const& typeId,
369 SdfPath const& bprimId) = 0;
370
371
381 virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) = 0;
382
386 virtual void DestroyBprim(HdBprim *bprim) = 0;
387
393
405 virtual void CommitResources(HdChangeTracker *tracker) = 0;
406
412
418 HD_API
419 virtual TfToken GetMaterialBindingPurpose() const;
420
421
423 HD_API
424 virtual TfToken GetMaterialNetworkSelector() const;
425
431 HD_API
432 virtual TfTokenVector GetMaterialRenderContexts() const;
433
439 HD_API
440 virtual TfTokenVector GetRenderSettingsNamespaces() const;
441
450 HD_API
451 virtual bool IsPrimvarFilteringNeeded() const;
452
457 HD_API
458 virtual TfTokenVector GetShaderSourceTypes() const;
459
465
470 HD_API
471 virtual HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const;
472
478
482 HD_API
483 virtual HdCommandDescriptors GetCommandDescriptors() const;
484
493 HD_API
494 virtual bool InvokeCommand(
495 const TfToken &command,
496 const HdCommandArgs &args = HdCommandArgs());
497
500 HD_API
501 const std::string &GetRendererDisplayName() {
502 return _displayName;
503 }
504
513
521 HD_API
522 virtual void SetTerminalSceneIndex(
523 const HdSceneIndexBaseRefPtr &terminalSceneIndex);
524
530 HD_API
531 virtual void Update();
532
535 HD_API
536 virtual bool IsParallelSyncEnabled(const TfToken &primType) const;
537
538protected:
540 HD_API
541 HdRenderDelegate();
543 HD_API
544 HdRenderDelegate(HdRenderSettingsMap const& settingsMap);
545
549 HdRenderDelegate(const HdRenderDelegate &) = delete;
550 HdRenderDelegate &operator=(const HdRenderDelegate &) = delete;
551
552 HD_API
553 void _PopulateDefaultSettings(
554 HdRenderSettingDescriptorList const& defaultSettings);
555
557 HdRenderSettingsMap _settingsMap;
558 unsigned int _settingsVersion;
559
560private:
561
562 friend class HdRendererPlugin;
567 void _SetRendererDisplayName(const std::string &displayName) {
568 _displayName = displayName;
569 }
570 std::string _displayName;
571
572};
573
574PXR_NAMESPACE_CLOSE_SCOPE
575
576#endif //PXR_IMAGING_HD_RENDER_DELEGATE_H
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:40
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine.
Definition: changeTracker.h:35
HdDriver represents a device object, commonly a render device, that is owned by the application and p...
Definition: driver.h:23
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:108
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:105
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
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.
virtual HD_API bool SetArbitraryValue(const TfToken &key, const VtValue &value)
Set a custom value in the render param's implementation.
virtual HD_API VtValue GetArbitraryValue(const TfToken &key) const
Retrieve a custom value identified by key from the render param's implementation.
An abstract class representing a single render iteration over a set of prims (the HdRprimCollection),...
Definition: renderPass.h:53
This class defines a renderer plugin interface for Hydra.
A named, semantic collection of objects.
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:38
Adapter class providing data exchange with the client scene graph.
Abstract interface to scene data.
Definition: sceneIndex.h:48
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:35
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A map with string keys and VtValue values.
Definition: dictionary.h:43
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
#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:30
HdRenderSettingDescriptor represents a render setting that a render delegate wants to export (e....
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440