All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
renderDelegate.h
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//
7#ifndef PXR_IMAGING_PLUGIN_HD_EMBREE_RENDER_DELEGATE_H
8#define PXR_IMAGING_PLUGIN_HD_EMBREE_RENDER_DELEGATE_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hd/renderDelegate.h"
12#include "pxr/imaging/hd/renderThread.h"
13#include "pxr/imaging/plugin/hdEmbree/renderer.h"
15
16#include <mutex>
17#include <embree3/rtcore.h>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
22
23#define HDEMBREE_RENDER_SETTINGS_TOKENS \
24 (enableAmbientOcclusion) \
25 (enableSceneColors) \
26 (ambientOcclusionSamples) \
27 (randomNumberSeed)
28
29// Also: HdRenderSettingsTokens->convergedSamplesPerPixel
30
31TF_DECLARE_PUBLIC_TOKENS(HdEmbreeRenderSettingsTokens, HDEMBREE_RENDER_SETTINGS_TOKENS);
32
68class HdEmbreeRenderDelegate final : public HdRenderDelegate
69{
70public:
77 HdEmbreeRenderDelegate(HdRenderSettingsMap const& settingsMap);
81
84 HdRenderParam *GetRenderParam() const override;
85
88 const TfTokenVector &GetSupportedRprimTypes() const override;
91 const TfTokenVector &GetSupportedSprimTypes() const override;
94 const TfTokenVector &GetSupportedBprimTypes() const override;
95
97 HdResourceRegistrySharedPtr GetResourceRegistry() const override;
98
103 HdRenderSettingDescriptorList
105
107 bool IsPauseSupported() const override;
108
110 bool Pause() override;
111
113 bool Resume() override;
114
123 HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index,
124 HdRprimCollection const& collection) override;
125
134 SdfPath const& id) override;
135
138 void DestroyInstancer(HdInstancer *instancer) override;
139
149 SdfPath const& rprimId) override;
150
153 void DestroyRprim(HdRprim *rPrim) override;
154
163 SdfPath const& sprimId) override;
164
170 HdSprim *CreateFallbackSprim(TfToken const& typeId) override;
171
174 void DestroySprim(HdSprim *sPrim) override;
175
183 SdfPath const& bprimId) override;
184
190 HdBprim *CreateFallbackBprim(TfToken const& typeId) override;
191
194 void DestroyBprim(HdBprim *bPrim) override;
195
201 void CommitResources(HdChangeTracker *tracker) override;
202
209 return HdTokens->full;
210 }
211
219 GetDefaultAovDescriptor(TfToken const& name) const override;
220
223 VtDictionary GetRenderStats() const override;
224
225private:
226 static const TfTokenVector SUPPORTED_RPRIM_TYPES;
227 static const TfTokenVector SUPPORTED_SPRIM_TYPES;
228 static const TfTokenVector SUPPORTED_BPRIM_TYPES;
229
231 static std::mutex _mutexResourceRegistry;
232 static std::atomic_int _counterResourceRegistry;
233 static HdResourceRegistrySharedPtr _resourceRegistry;
234
235 // This class does not support copying.
237 HdEmbreeRenderDelegate &operator =(const HdEmbreeRenderDelegate &) = delete;
238
239 // Embree initialization routine.
240 void _Initialize();
241
242 // Handle for an embree "device", or library state.
243 RTCDevice _rtcDevice;
244
245 // Handle for the top-level embree scene, mirroring the Hydra scene.
246 RTCScene _rtcScene;
247
248 // A version counter for edits to _scene.
249 std::atomic<int> _sceneVersion;
250
251 // A shared HdEmbreeRenderParam object that stores top-level embree state;
252 // passed to prims during Sync().
253 std::shared_ptr<HdEmbreeRenderParam> _renderParam;
254
255 // A background render thread for running the actual renders in. The
256 // render thread object manages synchronization between the scene data
257 // and the background-threaded renderer.
258 HdRenderThread _renderThread;
259
260 // An embree renderer object, to perform the actual raytracing.
261 HdEmbreeRenderer _renderer;
262
263 // A list of render setting exports.
264 HdRenderSettingDescriptorList _settingDescriptors;
265
266 // A callback that interprets embree error codes and injects them into
267 // the hydra logging system.
268 static void HandleRtcError(void* userPtr, RTCError code, const char *msg);
269};
270
271
272PXR_NAMESPACE_CLOSE_SCOPE
273
274#endif // PXR_IMAGING_PLUGIN_HD_EMBREE_RENDER_DELEGATE_H
Bprim (buffer prim) is a base class of managing a blob of data that is used to communicate between th...
Definition: bprim.h:40
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine.
Definition: changeTracker.h:35
Render delegates provide renderer-specific functionality to the render index, the main hydra state ma...
bool Resume() override
Resume background rendering threads.
void DestroyRprim(HdRprim *rPrim) override
Destroy an Rprim created with CreateRprim.
bool Pause() override
Pause background rendering threads.
~HdEmbreeRenderDelegate() override
Render delegate destructor.
const TfTokenVector & GetSupportedSprimTypes() const override
Return a list of which Sprim types can be created by this class's CreateSprim.
void DestroySprim(HdSprim *sPrim) override
Destroy an Sprim created with CreateSprim or CreateFallbackSprim.
void CommitResources(HdChangeTracker *tracker) override
This function is called after new scene data is pulled during prim Sync(), but before any tasks (such...
HdBprim * CreateFallbackBprim(TfToken const &typeId) override
Create a hydra Bprim using default values, and with no scene graph binding.
HdRenderPassSharedPtr CreateRenderPass(HdRenderIndex *index, HdRprimCollection const &collection) override
Create a renderpass.
HdSprim * CreateSprim(TfToken const &typeId, SdfPath const &sprimId) override
Create a hydra Sprim, representing scene or viewport state like cameras or lights.
HdSprim * CreateFallbackSprim(TfToken const &typeId) override
Create a hydra Sprim using default values, and with no scene graph binding.
HdRprim * CreateRprim(TfToken const &typeId, SdfPath const &rprimId) override
Create a hydra Rprim, representing scene geometry.
const TfTokenVector & GetSupportedRprimTypes() const override
Return a list of which Rprim types can be created by this class's CreateRprim.
HdBprim * CreateBprim(TfToken const &typeId, SdfPath const &bprimId) override
Create a hydra Bprim, representing data buffers such as textures.
bool IsPauseSupported() const override
Return true to indicate that pausing and resuming are supported.
HdInstancer * CreateInstancer(HdSceneDelegate *delegate, SdfPath const &id) override
Create an instancer.
HdResourceRegistrySharedPtr GetResourceRegistry() const override
Returns the HdResourceRegistry instance used by this render delegate.
HdRenderParam * GetRenderParam() const override
Return this delegate's render param.
HdEmbreeRenderDelegate()
Render delegate constructor.
void DestroyInstancer(HdInstancer *instancer) override
Destroy an instancer created with CreateInstancer.
const TfTokenVector & GetSupportedBprimTypes() const override
Return a list of which Bprim types can be created by this class's CreateBprim.
HdEmbreeRenderDelegate(HdRenderSettingsMap const &settingsMap)
Render delegate constructor.
void DestroyBprim(HdBprim *bPrim) override
Destroy a Bprim created with CreateBprim or CreateFallbackBprim.
TfToken GetMaterialBindingPurpose() const override
This function tells the scene which material variant to reference.
VtDictionary GetRenderStats() const override
This function allows the renderer to report back some useful statistics that the application can disp...
HdRenderSettingDescriptorList GetRenderSettingDescriptors() const override
Returns a list of user-configurable render settings.
HdAovDescriptor GetDefaultAovDescriptor(TfToken const &name) const override
This function returns the default AOV descriptor for a given named AOV.
The render delegate can create an object of type HdRenderParam, to pass to each prim during Sync().
Definition: renderParam.h:26
HdEmbreeRenderer implements a renderer on top of Embree's raycasting abilities.
Definition: renderer.h:38
This class exists to facilitate point cloud style instancing.
Definition: instancer.h:108
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:104
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
HdRenderThread is a utility that specific render delegates can choose to use depending on their needs...
Definition: renderThread.h:129
A named, semantic collection of objects.
The render engine state for a given rprim from the scene graph.
Definition: rprim.h:38
Adapter class providing data exchange with the client scene graph.
Sprim (state prim) is a base class of managing state for non-drawable scene entity (e....
Definition: sprim.h:35
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
A map with string keys and VtValue values.
Definition: dictionary.h:43
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:81
A bundle of state describing an AOV ("Arbitrary Output Variable") display channel.
Definition: aov.h:30
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440