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;
37 
39  std::shared_ptr<class HdStResourceRegistry>;
40 
41 ///
42 /// HdStRenderDelegate
43 ///
44 /// The Storm Render Delegate provides a rasterizer renderer to draw the scene.
45 /// While it currently has some ties to GL, the goal is to use Hgi to allow
46 /// it to be graphics API agnostic.
47 ///
48 class HdStRenderDelegate final : public HdRenderDelegate {
49 public:
50  HDST_API
52  HDST_API
53  HdStRenderDelegate(HdRenderSettingsMap const& settingsMap);
54 
55  HDST_API
56  virtual ~HdStRenderDelegate();
57 
58  // ---------------------------------------------------------------------- //
59  /// \name HdRenderDelegate virtual API
60  // ---------------------------------------------------------------------- //
61 
62  HDST_API
63  virtual void SetDrivers(HdDriverVector const& drivers) override;
64 
65  HDST_API
66  virtual HdRenderParam *GetRenderParam() const override;
67 
68  HDST_API
69  virtual const TfTokenVector &GetSupportedRprimTypes() const override;
70  HDST_API
71  virtual const TfTokenVector &GetSupportedSprimTypes() const override;
72  HDST_API
73  virtual const TfTokenVector &GetSupportedBprimTypes() const override;
74  HDST_API
75  virtual HdResourceRegistrySharedPtr GetResourceRegistry() const override;
76 
77  HDST_API
79  HdRprimCollection const& collection) override;
80  HDST_API
81  virtual HdRenderPassStateSharedPtr CreateRenderPassState() const override;
82 
83  HDST_API
84  virtual HdInstancer *CreateInstancer(HdSceneDelegate *delegate,
85  SdfPath const& id) override;
86 
87  HDST_API
88  virtual void DestroyInstancer(HdInstancer *instancer) override;
89 
90  HDST_API
91  virtual HdRprim *CreateRprim(TfToken const& typeId,
92  SdfPath const& rprimId) override;
93  HDST_API
94  virtual void DestroyRprim(HdRprim *rPrim) override;
95 
96  HDST_API
97  virtual HdSprim *CreateSprim(TfToken const& typeId,
98  SdfPath const& sprimId) override;
99  HDST_API
100  virtual HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
101  HDST_API
102  virtual void DestroySprim(HdSprim *sPrim) override;
103 
104  HDST_API
105  virtual HdBprim *CreateBprim(TfToken const& typeId,
106  SdfPath const& bprimId) override;
107  HDST_API
108  virtual HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
109  HDST_API
110  virtual void DestroyBprim(HdBprim *bPrim) override;
111 
112  HDST_API
113  virtual void CommitResources(HdChangeTracker *tracker) override;
114 
115  HDST_API
116  virtual TfTokenVector GetMaterialRenderContexts() const override;
117 
118  HDST_API
119  virtual TfTokenVector GetShaderSourceTypes() const override;
120 
121  HDST_API
122  virtual bool IsPrimvarFilteringNeeded() const override;
123 
124  HDST_API
126  GetRenderSettingDescriptors() const override;
127 
128  HDST_API
129  virtual VtDictionary GetRenderStats() const override;
130 
131  HDST_API
132  virtual HdAovDescriptor
133  GetDefaultAovDescriptor(TfToken const& name) const override;
134 
135  // ---------------------------------------------------------------------- //
136  /// \name Misc public API
137  // ---------------------------------------------------------------------- //
138 
139  // Returns whether or not HdStRenderDelegate can run on the current
140  // hardware.
141  HDST_API
142  static bool IsSupported();
143 
144  // Returns Hydra graphics interface
145  HDST_API
146  Hgi* GetHgi();
147 
148 private:
149  void _ApplyTextureSettings();
150  HdSprim *_CreateFallbackMaterialPrim();
151 
152  HdStRenderDelegate(const HdStRenderDelegate &) = delete;
153  HdStRenderDelegate &operator =(const HdStRenderDelegate &) = delete;
154 
155  static const TfTokenVector SUPPORTED_RPRIM_TYPES;
156  static const TfTokenVector SUPPORTED_SPRIM_TYPES;
157 
158  // Resource registry used in this render delegate
159  HdStResourceRegistrySharedPtr _resourceRegistry;
160 
161  HdRenderSettingDescriptorList _settingDescriptors;
162 
163  Hgi* _hgi;
164 
165  std::unique_ptr<HdStRenderParam> _renderParam;
166 };
167 
168 
170 
171 #endif // PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
HDST_API Hgi * GetHgi()
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:42
virtual HDST_API void CommitResources(HdChangeTracker *tracker) override
virtual HDST_API const TfTokenVector & GetSupportedRprimTypes() const override
std::shared_ptr< class HdRenderPass > HdRenderPassSharedPtr
Definition: engine.h:41
std::shared_ptr< class HdResourceRegistry > HdResourceRegistrySharedPtr
std::vector< HdRenderSettingDescriptor > HdRenderSettingDescriptorList
virtual HDST_API ~HdStRenderDelegate()
virtual HDST_API bool IsPrimvarFilteringNeeded() const override
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual HDST_API HdAovDescriptor GetDefaultAovDescriptor(TfToken const &name) const override
virtual HDST_API HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index, HdRprimCollection const &collection) override
virtual HDST_API const TfTokenVector & GetSupportedBprimTypes() const override
virtual HDST_API HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override
virtual HDST_API void DestroySprim(HdSprim *sPrim) override
virtual HDST_API TfTokenVector GetMaterialRenderContexts() const override
virtual HDST_API HdBprim * CreateFallbackBprim(TfToken const &typeId) override
virtual HDST_API HdSprim * CreateFallbackSprim(TfToken const &typeId) override
Definition: token.h:87
std::vector< HdDriver * > HdDriverVector
static HDST_API bool IsSupported()
Definition: rprim.h:68
virtual HDST_API const TfTokenVector & GetSupportedSprimTypes() const override
virtual HDST_API HdRenderParam * GetRenderParam() const override
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
HDST_API HdStRenderDelegate()
Definition: path.h:288
virtual HDST_API void DestroyRprim(HdRprim *rPrim) override
virtual HDST_API void SetDrivers(HdDriverVector const &drivers) override
Definition: sprim.h:52
Definition: hgi.h:106
virtual HDST_API void DestroyBprim(HdBprim *bPrim) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
virtual HDST_API HdRprim * CreateRprim(TfToken const &typeId, SdfPath const &rprimId) override
virtual HDST_API HdSprim * CreateSprim(TfToken const &typeId, SdfPath const &sprimId) override
#define HDST_API
Definition: api.h:40
GLuint index
Definition: glcorearb.h:785
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: bprim.h:56
virtual HDST_API HdResourceRegistrySharedPtr GetResourceRegistry() const override
virtual HDST_API HdRenderPassStateSharedPtr CreateRenderPassState() const override
virtual HDST_API HdBprim * CreateBprim(TfToken const &typeId, SdfPath const &bprimId) override
std::shared_ptr< class HdStResourceRegistry > HdStResourceRegistrySharedPtr
Definition: commandBuffer.h:47
virtual HDST_API void DestroyInstancer(HdInstancer *instancer) override
virtual HDST_API TfTokenVector GetShaderSourceTypes() const override
virtual HDST_API VtDictionary GetRenderStats() const override
virtual HDST_API HdInstancer * CreateInstancer(HdSceneDelegate *delegate, SdfPath const &id) override