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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HDX_TASK_H
25 #define PXR_IMAGING_HDX_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
29 #include "pxr/imaging/hd/task.h"
30 
32 
33 class Hgi;
34 
35 
36 /// \class HdxTask
37 ///
38 /// Base class for (some) tasks in Hdx that provides common progressive
39 /// rendering and Hgi functionality.
40 ///
41 /// Tasks that require neither progressive rendering nor Hgi can continue to
42 /// derive directly from HdTask.
43 ///
44 class HdxTask : public HdTask {
45 public:
46  HDX_API
47  HdxTask(SdfPath const& id);
48 
49  HDX_API
50  ~HdxTask() override;
51 
52  /// This function returns true when a (progressive) task considers its
53  /// execution results converged. Usually this means that a progressive
54  /// render delegate is finished rendering into the HdRenderBuffers used by
55  /// this task.
56  /// Returns true by default which is a good default for rasterizers.
57  ///
58  /// Applications with data-driven task lists can determine their convergence
59  /// state by determining which tasks are HdxTasks and then querying
60  /// specifically those tasks for IsConverged.
61  HDX_API
62  virtual bool IsConverged() const;
63 
64  /// We override HdTask::Sync, but make it 'final' to make sure derived
65  /// classes can't override it and instead override _Sync.
66  /// This 'non-virtual interface'-like pattern allows us to ensure we always
67  /// initialized Hgi during the Sync task so derived classes don't have to.
68  void Sync(
69  HdSceneDelegate* delegate,
70  HdTaskContext* ctx,
71  HdDirtyBits* dirtyBits) final;
72 
73 protected:
74  // This is called during the hydra Sync Phase via HdxTask::Sync.
75  // Please see HdTask::Sync for Sync Phase documentation.
76  virtual void _Sync(
77  HdSceneDelegate* delegate,
78  HdTaskContext* ctx,
79  HdDirtyBits* dirtyBits) = 0;
80 
81  // Swaps the color target and colorIntermediate target.
82  // This is used when a task wishes to read from the color and also write
83  // to it. We use two color targets and ping-pong between them.
85 
86  // Return pointer to Hydra Graphics Interface.
87  HDX_API
88  Hgi* _GetHgi() const;
89 
91 };
92 
94 
95 #endif
96 
void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) final
Hgi * _hgi
Definition: task.h:90
uint32_t HdDirtyBits
Definition: types.h:127
virtual void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits)=0
#define HDX_API
Definition: api.h:40
HDX_API HdxTask(SdfPath const &id)
virtual HDX_API bool IsConverged() const
Definition: task.h:54
Definition: path.h:288
void _ToggleRenderTarget(HdTaskContext *ctx)
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:73
Definition: task.h:44
Definition: hgi.h:106
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDX_API Hgi * _GetHgi() const
HDX_API ~HdxTask() override