HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
task.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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_HDX_TASK_H
8 #define PXR_IMAGING_HDX_TASK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdx/api.h"
12 #include "pxr/imaging/hd/task.h"
13 
15 
16 class Hgi;
17 
18 
19 /// \class HdxTask
20 ///
21 /// Base class for (some) tasks in Hdx that provides common progressive
22 /// rendering and Hgi functionality.
23 ///
24 /// Tasks that require neither progressive rendering nor Hgi can continue to
25 /// derive directly from HdTask.
26 ///
27 class HdxTask : public HdTask
28 {
29 public:
30  HDX_API
31  HdxTask(SdfPath const& id);
32 
33  HDX_API
34  ~HdxTask() override;
35 
36  /// This function returns true when a (progressive) task considers its
37  /// execution results converged. Usually this means that a progressive
38  /// render delegate is finished rendering into the HdRenderBuffers used by
39  /// this task.
40  /// Returns true by default which is a good default for rasterizers.
41  ///
42  /// Applications with data-driven task lists can determine their convergence
43  /// state by determining which tasks are HdxTasks and then querying
44  /// specifically those tasks for IsConverged.
45  HDX_API
46  virtual bool IsConverged() const;
47 
48  /// We override HdTask::Sync, but make it 'final' to make sure derived
49  /// classes can't override it and instead override _Sync.
50  /// This 'non-virtual interface'-like pattern allows us to ensure we always
51  /// initialized Hgi during the Sync task so derived classes don't have to.
52  HDX_API
53  void Sync(
54  HdSceneDelegate* delegate,
55  HdTaskContext* ctx,
56  HdDirtyBits* dirtyBits) override final;
57 
58 protected:
59  // This is called during the hydra Sync Phase via HdxTask::Sync.
60  // Please see HdTask::Sync for Sync Phase documentation.
61  virtual void _Sync(
62  HdSceneDelegate* delegate,
63  HdTaskContext* ctx,
64  HdDirtyBits* dirtyBits) = 0;
65 
66  // Swaps the color target and colorIntermediate target.
67  // This is used when a task wishes to read from the color and also write
68  // to it. We use two color targets and ping-pong between them.
69  HDX_API
71 
72  // Swaps the depth target and depthIntermediate target.
73  // This is used when a task wishes to read from the depth and also write
74  // to it. We use two depth targets and ping-pong between them.
75  HDX_API
77 
78  // Helper function to facilitate texture ping-ponging.
79  HDX_API
80  void _SwapTextures(
81  HdTaskContext* ctx,
82  const TfToken& textureToken,
83  const TfToken& textureIntermediateToken);
84 
85  // Return pointer to Hydra Graphics Interface.
86  HDX_API
87  Hgi* _GetHgi() const;
88 
89 private:
90  Hgi* _hgi;
91 };
92 
94 
95 #endif
96 
uint32_t HdDirtyBits
Definition: types.h:143
virtual void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits)=0
#define HDX_API
Definition: api.h:23
HDX_API void _SwapTextures(HdTaskContext *ctx, const TfToken &textureToken, const TfToken &textureIntermediateToken)
Definition: token.h:70
HDX_API HdxTask(SdfPath const &id)
virtual HDX_API bool IsConverged() const
Definition: task.h:43
Definition: path.h:273
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) overridefinal
Definition: task.h:27
Definition: hgi.h:93
HDX_API void _ToggleRenderTarget(HdTaskContext *ctx)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDX_API Hgi * _GetHgi() const
HDX_API void _ToggleDepthTarget(HdTaskContext *ctx)
HDX_API ~HdxTask() override