All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
204  HD_API
205  virtual bool Pause();
206 
213  HD_API
214  virtual bool Resume();
215 
220  HD_API
221  virtual bool IsStopSupported() const;
222 
229  HD_API
230  virtual bool Stop();
231 
238  HD_API
239  virtual bool Restart();
240 
246 
253  virtual HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
254  HdRprimCollection const& collection) = 0;
255 
264  HD_API
265  virtual HdRenderPassStateSharedPtr CreateRenderPassState() const;
266 
272 
278  virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
279  SdfPath const& id) = 0;
280 
281  virtual void DestroyInstancer(HdInstancer *instancer) = 0;
282 
288 
289 
296  virtual HdRprim *CreateRprim(TfToken const& typeId,
297  SdfPath const& rprimId) = 0;
298 
302  virtual void DestroyRprim(HdRprim *rPrim) = 0;
303 
310  virtual HdSprim *CreateSprim(TfToken const& typeId,
311  SdfPath const& sprimId) = 0;
312 
322  virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) = 0;
323 
327  virtual void DestroySprim(HdSprim *sprim) = 0;
328 
335  virtual HdBprim *CreateBprim(TfToken const& typeId,
336  SdfPath const& bprimId) = 0;
337 
338 
348  virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) = 0;
349 
353  virtual void DestroyBprim(HdBprim *bprim) = 0;
354 
360 
372  virtual void CommitResources(HdChangeTracker *tracker) = 0;
373 
379 
385  HD_API
386  virtual TfToken GetMaterialBindingPurpose() const;
387 
388 
390  HD_API
391  virtual TfToken GetMaterialNetworkSelector() const;
392 
398  HD_API
399  virtual TfTokenVector GetMaterialRenderContexts() const;
400 
409  HD_API
410  virtual bool IsPrimvarFilteringNeeded() const;
411 
416  HD_API
417  virtual TfTokenVector GetShaderSourceTypes() const;
418 
424 
429  HD_API
430  virtual HdAovDescriptor GetDefaultAovDescriptor(TfToken const& name) const;
431 
437 
441  HD_API
442  virtual HdCommandDescriptors GetCommandDescriptors() const;
443 
452  HD_API
453  virtual bool InvokeCommand(
454  const TfToken &command,
455  const HdCommandArgs &args = HdCommandArgs());
456 
457 
458 protected:
460  HD_API
461  HdRenderDelegate();
463  HD_API
464  HdRenderDelegate(HdRenderSettingsMap const& settingsMap);
465 
469  HdRenderDelegate(const HdRenderDelegate &) = delete;
470  HdRenderDelegate &operator=(const HdRenderDelegate &) = delete;
471 
472  HD_API
473  void _PopulateDefaultSettings(
474  HdRenderSettingDescriptorList const& defaultSettings);
475 
477  HdRenderSettingsMap _settingsMap;
478  unsigned int _settingsVersion;
479 };
480 
481 PXR_NAMESPACE_CLOSE_SCOPE
482 
483 #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:116
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:50
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:71
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:68
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:288
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e...
Definition: sprim.h:52
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 (&quot;Arbitrary Output Variable&quot;) 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:168
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...