Loading...
Searching...
No Matches
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"
18#include "pxr/base/tf/token.h"
19
20#include <memory>
21
22PXR_NAMESPACE_OPEN_SCOPE
23
24class SdfPath;
25class HdRprim;
26class HdSprim;
27class HdBprim;
28class HdSceneDelegate;
29class HdRenderIndex;
30class HdRenderPass;
31class HdInstancer;
32class HdDriver;
33class Hgi;
34
36
37using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
38using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
39using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
40using HdDriverVector = std::vector<HdDriver*>;
41
48{
49public:
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
82private:
83 // Hydra will not attempt to copy the class.
84 HdRenderParam(const HdRenderParam &) = delete;
85 HdRenderParam &operator =(const HdRenderParam &) = delete;
86};
87
88typedef 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
104typedef std::vector<HdRenderSettingDescriptor> HdRenderSettingDescriptorList;
105
108class HdRenderDelegate
109{
110public:
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
462 HD_API
463 virtual TfTokenVector GetShaderSourceTypes() const;
464
470
475 HD_API
476 virtual HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const;
477
483
487 HD_API
488 virtual HdCommandDescriptors GetCommandDescriptors() const;
489
498 HD_API
499 virtual bool InvokeCommand(
500 const TfToken &command,
501 const HdCommandArgs &args = HdCommandArgs());
502
505 HD_API
506 const std::string &GetRendererDisplayName() {
507 return _displayName;
508 }
509
518
526 HD_API
527 virtual void SetTerminalSceneIndex(
528 const HdSceneIndexBaseRefPtr &terminalSceneIndex);
529
535 HD_API
536 virtual void Update();
537
540 HD_API
541 virtual bool IsParallelSyncEnabled(const TfToken &primType) const;
542
543protected:
545 HD_API
546 HdRenderDelegate();
548 HD_API
549 HdRenderDelegate(HdRenderSettingsMap const& settingsMap);
550
554 HdRenderDelegate(const HdRenderDelegate &) = delete;
555 HdRenderDelegate &operator=(const HdRenderDelegate &) = delete;
556
557 HD_API
558 void _PopulateDefaultSettings(
559 HdRenderSettingDescriptorList const& defaultSettings);
560
562 HdRenderSettingsMap _settingsMap;
563 unsigned int _settingsVersion;
564
565private:
566
567 friend class HdRendererPlugin;
572 void _SetRendererDisplayName(const std::string &displayName) {
573 _displayName = displayName;
574 }
575 std::string _displayName;
576
577};
578
579PXR_NAMESPACE_CLOSE_SCOPE
580
581#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:54
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:35
Hydra Graphics Interface.
Definition: hgi.h:95
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:152
#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