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 class HdStRenderParam;
37 using HdStDrawItemsCacheUniquePtr =
38  std::unique_ptr<class HdSt_DrawItemsCache>;
39 using HdStDrawItemsCachePtr = HdSt_DrawItemsCache *;
40 
41 using HdStResourceRegistrySharedPtr =
42  std::shared_ptr<class HdStResourceRegistry>;
43 
51 class HdStRenderDelegate final : public HdRenderDelegate
52 {
53 public:
54  HDST_API
56  HDST_API
57  HdStRenderDelegate(HdRenderSettingsMap const& settingsMap);
58 
59  HDST_API
60  ~HdStRenderDelegate() override;
61 
62  // ---------------------------------------------------------------------- //
64  // ---------------------------------------------------------------------- //
65 
66  HDST_API
67  void SetDrivers(HdDriverVector const& drivers) override;
68 
69  HDST_API
70  HdRenderParam *GetRenderParam() const override;
71 
72  HDST_API
73  const TfTokenVector &GetSupportedRprimTypes() const override;
74  HDST_API
75  const TfTokenVector &GetSupportedSprimTypes() const override;
76  HDST_API
77  const TfTokenVector &GetSupportedBprimTypes() const override;
78  HDST_API
79  HdResourceRegistrySharedPtr GetResourceRegistry() const override;
80 
81  HDST_API
82  HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
83  HdRprimCollection const& collection) override;
84  HDST_API
85  HdRenderPassStateSharedPtr CreateRenderPassState() const override;
86 
87  HDST_API
88  HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
89  SdfPath const& id) override;
90 
91  HDST_API
92  void DestroyInstancer(HdInstancer *instancer) override;
93 
94  HDST_API
95  HdRprim *CreateRprim(TfToken const& typeId,
96  SdfPath const& rprimId) override;
97  HDST_API
98  void DestroyRprim(HdRprim *rPrim) override;
99 
100  HDST_API
101  HdSprim *CreateSprim(TfToken const& typeId,
102  SdfPath const& sprimId) override;
103  HDST_API
104  HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
105  HDST_API
106  void DestroySprim(HdSprim *sPrim) override;
107 
108  HDST_API
109  HdBprim *CreateBprim(TfToken const& typeId,
110  SdfPath const& bprimId) override;
111  HDST_API
112  HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
113  HDST_API
114  void DestroyBprim(HdBprim *bPrim) override;
115 
116  HDST_API
117  void CommitResources(HdChangeTracker *tracker) override;
118 
119  HDST_API
120  TfTokenVector GetMaterialRenderContexts() const override;
121 
122  HDST_API
123  TfTokenVector GetShaderSourceTypes() const override;
124 
125  HDST_API
126  bool IsPrimvarFilteringNeeded() const override;
127 
128  HDST_API
129  HdRenderSettingDescriptorList
130  GetRenderSettingDescriptors() const override;
131 
132  HDST_API
133  VtDictionary GetRenderStats() const override;
134 
135  HDST_API
137  GetDefaultAovDescriptor(TfToken const& name) const override;
138 
139  // ---------------------------------------------------------------------- //
141  // ---------------------------------------------------------------------- //
142 
143  // Returns whether or not HdStRenderDelegate can run on the current
144  // hardware.
145  HDST_API
146  static bool IsSupported();
147 
148  // Returns a raw pointer to the draw items cache owned (solely) by the
149  // render delegate.
150  HDST_API
151  HdStDrawItemsCachePtr GetDrawItemsCache() const;
152 
153  // Returns Hydra graphics interface
154  HDST_API
155  Hgi* GetHgi();
156 
157 private:
158  void _ApplyTextureSettings();
159  HdSprim *_CreateFallbackMaterialPrim();
160 
161  HdStRenderDelegate(const HdStRenderDelegate &) = delete;
162  HdStRenderDelegate &operator =(const HdStRenderDelegate &) = delete;
163 
164  static const TfTokenVector SUPPORTED_RPRIM_TYPES;
165  static const TfTokenVector SUPPORTED_SPRIM_TYPES;
166 
167  // Resource registry used in this render delegate
168  HdStResourceRegistrySharedPtr _resourceRegistry;
169 
170  HdRenderSettingDescriptorList _settingDescriptors;
171 
172  Hgi* _hgi;
173 
174  std::unique_ptr<HdStRenderParam> _renderParam;
175 
176  HdStDrawItemsCacheUniquePtr _drawItemsCache;
177 };
178 
179 
180 PXR_NAMESPACE_CLOSE_SCOPE
181 
182 #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:120
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine.
Definition: changeTracker.h:51
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:124
A map with string keys and VtValue values.
Definition: dictionary.h:62
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:54
The render delegate can create an object of type HdRenderParam, to pass to each prim during Sync().
Definition: renderParam.h:43
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:290
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:51
Hydra Graphics Interface.
Definition: hgi.h:110
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 ("Arbitrary Output Variable") display channel.
Definition: aov.h:46