HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
renderDelegate.h
Go to the documentation of this file.
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"
29 
30 #include <memory>
31 #include <mutex>
32 
34 
35 class Hgi;
36 class HdStRenderParam;
38  std::unique_ptr<class HdSt_DrawItemsCache>;
39 using HdStDrawItemsCachePtr = HdSt_DrawItemsCache *;
40 
42  std::shared_ptr<class HdStResourceRegistry>;
43 
44 ///
45 /// HdStRenderDelegate
46 ///
47 /// The Storm Render Delegate provides a rasterizer renderer to draw the scene.
48 /// While it currently has some ties to GL, the goal is to use Hgi to allow
49 /// it to be graphics API agnostic.
50 ///
52 {
53 public:
54  HDST_API
56  HDST_API
57  HdStRenderDelegate(HdRenderSettingsMap const& settingsMap);
58 
59  HDST_API
60  ~HdStRenderDelegate() override;
61 
62  // ---------------------------------------------------------------------- //
63  /// \name HdRenderDelegate virtual API
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
80 
81  HDST_API
83  HdRprimCollection const& collection) override;
84  HDST_API
86 
87  HDST_API
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
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  // ---------------------------------------------------------------------- //
140  /// \name Misc public API
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
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 
181 
182 #endif // PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
HDST_API Hgi * GetHgi()
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:42
HDST_API void CommitResources(HdChangeTracker *tracker) override
HDST_API VtDictionary GetRenderStats() const override
HDST_API TfTokenVector GetShaderSourceTypes() const override
std::shared_ptr< class HdRenderPass > HdRenderPassSharedPtr
Definition: engine.h:41
std::shared_ptr< class HdResourceRegistry > HdResourceRegistrySharedPtr
std::vector< HdRenderSettingDescriptor > HdRenderSettingDescriptorList
HDST_API const TfTokenVector & GetSupportedRprimTypes() const override
HDST_API HdRprim * CreateRprim(TfToken const &typeId, SdfPath const &rprimId) override
HDST_API HdSprim * CreateSprim(TfToken const &typeId, SdfPath const &sprimId) override
Definition: token.h:87
std::vector< HdDriver * > HdDriverVector
HDST_API const TfTokenVector & GetSupportedBprimTypes() const override
static HDST_API bool IsSupported()
Definition: rprim.h:54
HDST_API HdStDrawItemsCachePtr GetDrawItemsCache() const
HDST_API const TfTokenVector & GetSupportedSprimTypes() const override
HDST_API HdRenderParam * GetRenderParam() const override
HDST_API void SetDrivers(HdDriverVector const &drivers) override
HDST_API HdSprim * CreateFallbackSprim(TfToken const &typeId) override
HDST_API void DestroyBprim(HdBprim *bPrim) override
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
GLuint const GLchar * name
Definition: glcorearb.h:786
std::unique_ptr< class HdSt_DrawItemsCache > HdStDrawItemsCacheUniquePtr
HDST_API HdStRenderDelegate()
HDST_API HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override
Definition: path.h:291
HDST_API HdInstancer * CreateInstancer(HdSceneDelegate *delegate, SdfPath const &id) override
HDST_API HdAovDescriptor GetDefaultAovDescriptor(TfToken const &name) const override
Definition: sprim.h:51
HDST_API HdRenderPassStateSharedPtr CreateRenderPassState() const override
Definition: hgi.h:110
HDST_API ~HdStRenderDelegate() override
HDST_API HdResourceRegistrySharedPtr GetResourceRegistry() const override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
HDST_API void DestroyRprim(HdRprim *rPrim) override
#define HDST_API
Definition: api.h:40
GLuint index
Definition: glcorearb.h:786
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: bprim.h:56
HDST_API void DestroySprim(HdSprim *sPrim) override
HDST_API HdBprim * CreateBprim(TfToken const &typeId, SdfPath const &bprimId) override
HdSt_DrawItemsCache * HdStDrawItemsCachePtr
HDST_API TfTokenVector GetMaterialRenderContexts() const override
HDST_API HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index, HdRprimCollection const &collection) override
std::shared_ptr< class HdStResourceRegistry > HdStResourceRegistrySharedPtr
Definition: commandBuffer.h:47
HDST_API void DestroyInstancer(HdInstancer *instancer) override
HDST_API HdBprim * CreateFallbackBprim(TfToken const &typeId) override
HDST_API bool IsPrimvarFilteringNeeded() const override