All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderDelegate.h
1 //
2 // Copyright 2017 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 #ifndef PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
24 #define PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
25 
26 #include "pxr/pxr.h"
27 #include "pxr/imaging/hdSt/api.h"
28 #include "pxr/imaging/hd/renderDelegate.h"
29 
30 #include <memory>
31 #include <mutex>
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
35 class Hgi;
36 
37 using HdStResourceRegistrySharedPtr =
38  std::shared_ptr<class HdStResourceRegistry>;
39 
46 class HdStRenderDelegate final : public HdRenderDelegate {
47 public:
48  HDST_API
50  HDST_API
51  HdStRenderDelegate(HdRenderSettingsMap const& settingsMap);
52 
53  HDST_API
54  virtual ~HdStRenderDelegate();
55 
56  HDST_API
57  virtual void SetDrivers(HdDriverVector const& drivers) override;
58 
59  HDST_API
60  virtual HdRenderParam *GetRenderParam() const override;
61 
62  HDST_API
63  virtual const TfTokenVector &GetSupportedRprimTypes() const override;
64  HDST_API
65  virtual const TfTokenVector &GetSupportedSprimTypes() const override;
66  HDST_API
67  virtual const TfTokenVector &GetSupportedBprimTypes() const override;
68  HDST_API
69  virtual HdResourceRegistrySharedPtr GetResourceRegistry() const override;
70 
71  HDST_API
72  virtual HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
73  HdRprimCollection const& collection) override;
74  HDST_API
75  virtual HdRenderPassStateSharedPtr CreateRenderPassState() const override;
76 
77  HDST_API
78  virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
79  SdfPath const& id,
80  SdfPath const& instancerId) override;
81 
82  HDST_API
83  virtual void DestroyInstancer(HdInstancer *instancer) override;
84 
85  HDST_API
86  virtual HdRprim *CreateRprim(TfToken const& typeId,
87  SdfPath const& rprimId,
88  SdfPath const& instancerId) override;
89  HDST_API
90  virtual void DestroyRprim(HdRprim *rPrim) override;
91 
92  HDST_API
93  virtual HdSprim *CreateSprim(TfToken const& typeId,
94  SdfPath const& sprimId) override;
95  HDST_API
96  virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
97  HDST_API
98  virtual void DestroySprim(HdSprim *sPrim) override;
99 
100  HDST_API
101  virtual HdBprim *CreateBprim(TfToken const& typeId,
102  SdfPath const& bprimId) override;
103  HDST_API
104  virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
105  HDST_API
106  virtual void DestroyBprim(HdBprim *bPrim) override;
107 
108  HDST_API
109  virtual void CommitResources(HdChangeTracker *tracker) override;
110 
111  HDST_API
112  virtual TfToken GetMaterialNetworkSelector() const override;
113 
114  HDST_API
115  virtual TfTokenVector GetShaderSourceTypes() const override;
116 
117  HDST_API
118  virtual bool IsPrimvarFilteringNeeded() const override;
119 
120  // Returns whether or not HdStRenderDelegate can run on the current
121  // hardware.
122  HDST_API
123  static bool IsSupported();
124 
125  HDST_API
126  virtual HdRenderSettingDescriptorList
127  GetRenderSettingDescriptors() const override;
128 
129  HDST_API
130  virtual VtDictionary GetRenderStats() const override;
131 
132  HDST_API
133  virtual HdAovDescriptor
134  GetDefaultAovDescriptor(TfToken const& name) const override;
135 
136  // Returns Hydra graphics interface
137  HDST_API
138  Hgi* GetHgi();
139 
140 private:
141  static const TfTokenVector SUPPORTED_RPRIM_TYPES;
142  static const TfTokenVector SUPPORTED_SPRIM_TYPES;
143  static const TfTokenVector SUPPORTED_BPRIM_TYPES;
144 
146  static std::mutex _mutexResourceRegistry;
147  static std::atomic_int _counterResourceRegistry;
148  static HdStResourceRegistrySharedPtr _resourceRegistry;
149 
150  HdRenderSettingDescriptorList _settingDescriptors;
151 
152  Hgi* _hgi;
153 
154  void _Initialize();
155 
156  HdSprim *_CreateFallbackMaterialPrim();
157 
158  HdStRenderDelegate(const HdStRenderDelegate &) = delete;
159  HdStRenderDelegate &operator =(const HdStRenderDelegate &) = delete;
160 };
161 
162 
163 PXR_NAMESPACE_CLOSE_SCOPE
164 
165 #endif // PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:121
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine...
Definition: changeTracker.h:52
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:119
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 ...
HdStRenderDelegate.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
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:431
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
Hydra Graphics Interface.
Definition: hgi.h:68
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;Alternate Output Value&quot;) display channel.
Definition: aov.h:46