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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 #ifndef PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
7 #define PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
8 
9 #include "pxr/pxr.h"
10 #include "pxr/imaging/hdSt/api.h"
12 
13 #include <memory>
14 #include <mutex>
15 
17 
18 class Hgi;
19 class HdStRenderParam;
21  std::unique_ptr<class HdSt_DrawItemsCache>;
22 using HdStDrawItemsCachePtr = HdSt_DrawItemsCache *;
23 
25  std::shared_ptr<class HdStResourceRegistry>;
26 
27 ///
28 /// HdStRenderDelegate
29 ///
30 /// The Storm Render Delegate provides a rasterizer renderer to draw the scene.
31 /// While it currently has some ties to GL, the goal is to use Hgi to allow
32 /// it to be graphics API agnostic.
33 ///
35 {
36 public:
37  HDST_API
39  HDST_API
40  HdStRenderDelegate(HdRenderSettingsMap const& settingsMap);
41 
42  HDST_API
43  ~HdStRenderDelegate() override;
44 
45  // ---------------------------------------------------------------------- //
46  /// \name HdRenderDelegate virtual API
47  // ---------------------------------------------------------------------- //
48 
49  HDST_API
50  void SetDrivers(HdDriverVector const& drivers) override;
51 
52  HDST_API
53  HdRenderParam *GetRenderParam() const override;
54 
55  HDST_API
56  const TfTokenVector &GetSupportedRprimTypes() const override;
57  HDST_API
58  const TfTokenVector &GetSupportedSprimTypes() const override;
59  HDST_API
60  const TfTokenVector &GetSupportedBprimTypes() const override;
61  HDST_API
63 
64  HDST_API
66  HdRprimCollection const& collection) override;
67  HDST_API
69 
70  HDST_API
72  SdfPath const& id) override;
73 
74  HDST_API
75  void DestroyInstancer(HdInstancer *instancer) override;
76 
77  HDST_API
78  HdRprim *CreateRprim(TfToken const& typeId,
79  SdfPath const& rprimId) override;
80  HDST_API
81  void DestroyRprim(HdRprim *rPrim) override;
82 
83  HDST_API
84  HdSprim *CreateSprim(TfToken const& typeId,
85  SdfPath const& sprimId) override;
86  HDST_API
87  HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
88  HDST_API
89  void DestroySprim(HdSprim *sPrim) override;
90 
91  HDST_API
92  HdBprim *CreateBprim(TfToken const& typeId,
93  SdfPath const& bprimId) override;
94  HDST_API
95  HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
96  HDST_API
97  void DestroyBprim(HdBprim *bPrim) override;
98 
99  HDST_API
100  void CommitResources(HdChangeTracker *tracker) override;
101 
102  HDST_API
103  TfTokenVector GetMaterialRenderContexts() const override;
104 
105  HDST_API
106  TfTokenVector GetShaderSourceTypes() const override;
107 
108  HDST_API
109  bool IsPrimvarFilteringNeeded() const override;
110 
111  HDST_API
113  GetRenderSettingDescriptors() const override;
114 
115  HDST_API
116  VtDictionary GetRenderStats() const override;
117 
118  HDST_API
120  GetDefaultAovDescriptor(TfToken const& name) const override;
121 
122  // ---------------------------------------------------------------------- //
123  /// \name Misc public API
124  // ---------------------------------------------------------------------- //
125 
126  // Returns whether or not HdStRenderDelegate can run on the current
127  // hardware.
128  HDST_API
129  static bool IsSupported();
130 
131  // Returns a raw pointer to the draw items cache owned (solely) by the
132  // render delegate.
133  HDST_API
135 
136  // Returns Hydra graphics interface
137  HDST_API
138  Hgi* GetHgi();
139 
140 private:
141  void _ApplyTextureSettings();
142  HdSprim *_CreateFallbackMaterialPrim();
143 
144  HdStRenderDelegate(const HdStRenderDelegate &) = delete;
145  HdStRenderDelegate &operator =(const HdStRenderDelegate &) = delete;
146 
147  static const TfTokenVector SUPPORTED_RPRIM_TYPES;
148  static const TfTokenVector SUPPORTED_SPRIM_TYPES;
149 
150  // Resource registry used in this render delegate
151  HdStResourceRegistrySharedPtr _resourceRegistry;
152 
153  HdRenderSettingDescriptorList _settingDescriptors;
154 
155  Hgi* _hgi;
156 
157  std::unique_ptr<HdStRenderParam> _renderParam;
158 
159  HdStDrawItemsCacheUniquePtr _drawItemsCache;
160 };
161 
162 
164 
165 #endif // PXR_IMAGING_HD_ST_RENDER_DELEGATE_H
HDST_API Hgi * GetHgi()
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:25
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:24
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:70
std::vector< HdDriver * > HdDriverVector
HDST_API const TfTokenVector & GetSupportedBprimTypes() const override
static HDST_API bool IsSupported()
Definition: rprim.h:37
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:440
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:273
HDST_API HdInstancer * CreateInstancer(HdSceneDelegate *delegate, SdfPath const &id) override
HDST_API HdAovDescriptor GetDefaultAovDescriptor(TfToken const &name) const override
Definition: sprim.h:34
HDST_API HdRenderPassStateSharedPtr CreateRenderPassState() const override
Definition: hgi.h:93
HDST_API ~HdStRenderDelegate() override
HDST_API HdResourceRegistrySharedPtr GetResourceRegistry() const override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HDST_API void DestroyRprim(HdRprim *rPrim) override
#define HDST_API
Definition: api.h:23
GLuint index
Definition: glcorearb.h:786
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: bprim.h:39
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:30
HDST_API void DestroyInstancer(HdInstancer *instancer) override
HDST_API HdBprim * CreateFallbackBprim(TfToken const &typeId) override
HDST_API bool IsPrimvarFilteringNeeded() const override