Loading...
Searching...
No Matches
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/imaging/hd/dataSource.h"
34#include "pxr/base/tf/token.h"
35
36#include <memory>
37
38PXR_NAMESPACE_OPEN_SCOPE
39
40class SdfPath;
41class HdRprim;
42class HdSprim;
43class HdBprim;
44class HdSceneDelegate;
45class HdRenderIndex;
46class HdRenderPass;
47class HdInstancer;
48class HdDriver;
49
51
52using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
53using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
54using HdResourceRegistrySharedPtr = std::shared_ptr<class HdResourceRegistry>;
55using HdDriverVector = std::vector<HdDriver*>;
56
63{
64public:
65 HdRenderParam() {}
66 HD_API
67 virtual ~HdRenderParam();
68
69private:
70 // Hydra will not attempt to copy the class.
71 HdRenderParam(const HdRenderParam &) = delete;
72 HdRenderParam &operator =(const HdRenderParam &) = delete;
73};
74
75typedef TfHashMap<TfToken, VtValue, TfToken::HashFunctor> HdRenderSettingsMap;
76
82{
83 // A human readable name.
84 std::string name;
85 // The key for HdRenderDelegate::SetRenderSetting/GetRenderSetting.
86 TfToken key;
87 // The default value.
88 VtValue defaultValue;
89};
90
91typedef std::vector<HdRenderSettingDescriptor> HdRenderSettingDescriptorList;
92
95class HdRenderDelegate
96{
97public:
98 HD_API
99 virtual ~HdRenderDelegate();
100
106 HD_API
107 virtual void SetDrivers(HdDriverVector const& drivers);
108
113 virtual const TfTokenVector &GetSupportedRprimTypes() const = 0;
114
119 virtual const TfTokenVector &GetSupportedSprimTypes() const = 0;
120
121
126 virtual const TfTokenVector &GetSupportedBprimTypes() const = 0;
127
140 HD_API
141 virtual HdRenderParam *GetRenderParam() const;
142
147 virtual HdResourceRegistrySharedPtr GetResourceRegistry() const = 0;
148
152 HD_API
153 virtual void SetRenderSetting(TfToken const& key, VtValue const& value);
154
158 HD_API
159 virtual VtValue GetRenderSetting(TfToken const& key) const;
160
165 template<typename T>
166 T GetRenderSetting(TfToken const& key, T const& defValue) const {
167 return GetRenderSetting(key).Cast<T>().GetWithDefault(defValue);
168 }
169
173 HD_API
174 virtual HdRenderSettingDescriptorList GetRenderSettingDescriptors() const;
175
179 HD_API
180 virtual unsigned int GetRenderSettingsVersion() const;
181
185 HD_API
186 virtual VtDictionary GetRenderStats() const;
187
192 HD_API
193 virtual HdContainerDataSourceHandle GetCapabilities() const;
194
200
205 HD_API
206 virtual bool IsPauseSupported() const;
207
212 HD_API
213 virtual bool IsPaused() const;
214
221 HD_API
222 virtual bool Pause();
223
230 HD_API
231 virtual bool Resume();
232
237 HD_API
238 virtual bool IsStopSupported() const;
239
244 HD_API
245 virtual bool IsStopped() const;
246
254 HD_API
255 virtual bool Stop(bool blocking = true);
256
263 HD_API
264 virtual bool Restart();
265
271
278 virtual HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
279 HdRprimCollection const& collection) = 0;
280
289 HD_API
290 virtual HdRenderPassStateSharedPtr CreateRenderPassState() const;
291
297
303 virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
304 SdfPath const& id) = 0;
305
306 virtual void DestroyInstancer(HdInstancer *instancer) = 0;
307
313
314
321 virtual HdRprim *CreateRprim(TfToken const& typeId,
322 SdfPath const& rprimId) = 0;
323
327 virtual void DestroyRprim(HdRprim *rPrim) = 0;
328
335 virtual HdSprim *CreateSprim(TfToken const& typeId,
336 SdfPath const& sprimId) = 0;
337
347 virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) = 0;
348
352 virtual void DestroySprim(HdSprim *sprim) = 0;
353
360 virtual HdBprim *CreateBprim(TfToken const& typeId,
361 SdfPath const& bprimId) = 0;
362
363
373 virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) = 0;
374
378 virtual void DestroyBprim(HdBprim *bprim) = 0;
379
385
397 virtual void CommitResources(HdChangeTracker *tracker) = 0;
398
404
410 HD_API
411 virtual TfToken GetMaterialBindingPurpose() const;
412
413
415 HD_API
416 virtual TfToken GetMaterialNetworkSelector() const;
417
423 HD_API
424 virtual TfTokenVector GetMaterialRenderContexts() const;
425
431 HD_API
432 virtual TfTokenVector GetRenderSettingsNamespaces() const;
433
442 HD_API
443 virtual bool IsPrimvarFilteringNeeded() const;
444
449 HD_API
450 virtual TfTokenVector GetShaderSourceTypes() const;
451
457
462 HD_API
463 virtual HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const;
464
470
474 HD_API
475 virtual HdCommandDescriptors GetCommandDescriptors() const;
476
485 HD_API
486 virtual bool InvokeCommand(
487 const TfToken &command,
488 const HdCommandArgs &args = HdCommandArgs());
489
492 HD_API
493 const std::string &GetRendererDisplayName() {
494 return _displayName;
495 }
496
505
513 HD_API
514 virtual void SetTerminalSceneIndex(
515 const HdSceneIndexBaseRefPtr &terminalSceneIndex);
516
522 HD_API
523 virtual void Update();
524
526 bool IsParallelSyncEnabled(TfToken primType) const;
527
528protected:
530 HD_API
531 HdRenderDelegate();
533 HD_API
534 HdRenderDelegate(HdRenderSettingsMap const& settingsMap);
535
539 HdRenderDelegate(const HdRenderDelegate &) = delete;
540 HdRenderDelegate &operator=(const HdRenderDelegate &) = delete;
541
542 HD_API
543 void _PopulateDefaultSettings(
544 HdRenderSettingDescriptorList const& defaultSettings);
545
547 HdRenderSettingsMap _settingsMap;
548 unsigned int _settingsVersion;
549
550private:
551
552 friend class HdRendererPluginRegistry;
557 void _SetRendererDisplayName(const std::string &displayName) {
558 _displayName = displayName;
559 }
560 std::string _displayName;
561
562};
563
564PXR_NAMESPACE_CLOSE_SCOPE
565
566#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:57
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine.
Definition: changeTracker.h:52
HdDriver represents a device object, commonly a render device, that is owned by the application and p...
Definition: driver.h:40
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:125
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:121
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
An abstract class representing a single render iteration over a set of prims (the HdRprimCollection),...
Definition: renderPass.h:70
A named, semantic collection of objects.
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:55
Adapter class providing data exchange with the client scene graph.
Abstract interface to scene data.
Definition: sceneIndex.h:65
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:52
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
A map with string keys and VtValue values.
Definition: dictionary.h:60
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75
A bundle of state describing an AOV ("Arbitrary Output Variable") display channel.
Definition: aov.h:47
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:457