HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
engine.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_HD_ENGINE_H
8 #define PXR_IMAGING_HD_ENGINE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hd/api.h"
12 #include "pxr/imaging/hd/version.h"
13 
14 #include "pxr/imaging/hd/task.h"
15 
16 #include <memory>
17 
19 
20 class HdRenderIndex;
21 class HdRenderDelegate;
22 class HdResourceRegistry;
23 
24 using HdRenderPassSharedPtr = std::shared_ptr<class HdRenderPass>;
25 using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
26 
27 /// \class HdEngine
28 ///
29 /// The application-facing entry point top-level entry point for accessing Hydra.
30 /// Typically the application would only create one of these.
31 class HdEngine {
32 public:
33  HD_API
34  HdEngine();
35  HD_API
36  virtual ~HdEngine();
37 
38  /// \name Task Context
39  ///
40  /// External interface to set data/state in the task context passed to
41  /// each task in the render graph
42  ///
43  /// @{
44 
45  /// Adds or updates the value associated with the token.
46  /// Only one is supported for each token.
47  HD_API
48  void SetTaskContextData(const TfToken &id, const VtValue &data);
49 
50  /// If found, will return the value from the task context data associated
51  /// with the token. Returns false if the data could not be found.
52  HD_API
53  bool GetTaskContextData(const TfToken &id, VtValue *data) const;
54 
55  /// Removes the specified token.
56  HD_API
57  void RemoveTaskContextData(const TfToken &id);
58 
59  /// Removes all keys.
60  HD_API
61  void ClearTaskContextData();
62 
63  /// @}
64 
65  /// Execute tasks.
66  HD_API
68  HdTaskSharedPtrVector *tasks);
69 
70 
71  HD_API
72  void Execute(HdRenderIndex * index,
73  const SdfPathVector &taskPaths);
74 
75 private:
76  /// Context containing token-value pairs, that is passed to each
77  /// task in the render graph. The task-context can be pre-populated
78  /// and managed externally, so the state is persistent between runs of the
79  /// render graph.
80  HdTaskContext _taskContext;
81 };
82 
83 
85 
86 #endif //PXR_IMAGING_HD_ENGINE_H
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:25
std::shared_ptr< class HdRenderPass > HdRenderPassSharedPtr
Definition: engine.h:24
#define HD_API
Definition: api.h:23
std::vector< HdTaskSharedPtr > HdTaskSharedPtrVector
Definition: renderIndex.h:58
HD_API bool GetTaskContextData(const TfToken &id, VtValue *data) const
HD_API void RemoveTaskContextData(const TfToken &id)
Removes the specified token.
Definition: token.h:70
std::vector< class SdfPath > SdfPathVector
HD_API void Execute(HdRenderIndex *index, HdTaskSharedPtrVector *tasks)
Execute tasks.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
HD_API void ClearTaskContextData()
Removes all keys.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
GLuint index
Definition: glcorearb.h:786
virtual HD_API ~HdEngine()
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HD_API void SetTaskContextData(const TfToken &id, const VtValue &data)
HD_API HdEngine()
Definition: value.h:146
Definition: format.h:1821