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  /// Are all tasks at taskPaths in the render index converged?
37  static
38  HDX_API
39  bool AreTasksConverged(HdRenderIndex * const renderIndex,
40  const SdfPathVector &taskPaths);
41 
42  /// We override HdTask::Sync, but make it 'final' to make sure derived
43  /// classes can't override it and instead override _Sync.
44  /// This 'non-virtual interface'-like pattern allows us to ensure we always
45  /// initialized Hgi during the Sync task so derived classes don't have to.
46  HDX_API
47  void Sync(
48  HdSceneDelegate* delegate,
49  HdTaskContext* ctx,
50  HdDirtyBits* dirtyBits) override final;
51 
52 protected:
53  // This is called during the hydra Sync Phase via HdxTask::Sync.
54  // Please see HdTask::Sync for Sync Phase documentation.
55  virtual void _Sync(
56  HdSceneDelegate* delegate,
57  HdTaskContext* ctx,
58  HdDirtyBits* dirtyBits) = 0;
59 
60  // Swaps the color target and colorIntermediate target.
61  // This is used when a task wishes to read from the color and also write
62  // to it. We use two color targets and ping-pong between them.
63  HDX_API
65 
66  // Swaps the depth target and depthIntermediate target.
67  // This is used when a task wishes to read from the depth and also write
68  // to it. We use two depth targets and ping-pong between them.
69  HDX_API
71 
72  // Helper function to facilitate texture ping-ponging.
73  HDX_API
74  void _SwapTextures(
75  HdTaskContext* ctx,
76  const TfToken& textureToken,
77  const TfToken& textureIntermediateToken);
78 
79  // Return pointer to Hydra Graphics Interface.
80  HDX_API
81  Hgi* _GetHgi() const;
82 
83 private:
84  Hgi* _hgi;
85 };
86 
88 
89 #endif
90 
uint32_t HdDirtyBits
Definition: types.h:143
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
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)
static HDX_API bool AreTasksConverged(HdRenderIndex *const renderIndex, const SdfPathVector &taskPaths)
Are all tasks at taskPaths in the render index converged?
Definition: token.h:70
HDX_API HdxTask(SdfPath const &id)
std::vector< class SdfPath > SdfPathVector
Definition: task.h:43
Definition: path.h:280
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:94
HDX_API void _ToggleRenderTarget(HdTaskContext *ctx)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDX_API Hgi * _GetHgi() const
HDX_API void _ToggleDepthTarget(HdTaskContext *ctx)
HDX_API ~HdxTask() override