HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
presentTask.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 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_PRESENT_TASK_H
25 #define PXR_IMAGING_HDX_PRESENT_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
29 #include "pxr/imaging/hdx/task.h"
30 #include "pxr/imaging/hgi/tokens.h"
31 #include "pxr/imaging/hgi/types.h"
33 
35 
36 /// \class HdxPresentTaskParams
37 ///
38 /// PresentTask parameters.
39 ///
41 {
43  : dstApi(HgiTokens->OpenGL)
44  , dstRegion(0)
45  , enabled(true)
46  {}
47 
48  // The graphics lib that is used by the application / viewer.
49  // (The 'interopSrc' is determined by checking Hgi->GetAPIName)
51 
52  /// The framebuffer that the AOVs are presented into. This is a
53  /// VtValue that encoding a framebuffer in a dstApi specific
54  /// way.
55  ///
56  /// E.g., a uint32_t (aka GLuint) for framebuffer object for dstApi==OpenGL.
57  /// For backwards compatibility, the currently bound framebuffer is used
58  /// when the VtValue is empty.
60 
61  // Subrectangular region of the framebuffer over which to composite aov
62  // contents. Coordinates are (left, BOTTOM, width, height).
64 
65  // When not enabled, present task does not execute, but still calls
66  // Hgi::EndFrame.
67  bool enabled;
68 };
69 
70 /// \class HdxPresentTask
71 ///
72 /// A task for taking the final result of the aovs and compositing it over the
73 /// currently bound framebuffer.
74 /// This task uses the 'color' and optionally 'depth' aov's in the task
75 /// context. The 'color' aov is expected to use non-integer
76 /// (i.e., float or norm) types to keep the interop step simple.
77 ///
78 class HdxPresentTask : public HdxTask
79 {
80 public:
81  // Returns true if the format is supported for presentation. This is useful
82  // for upstream tasks to prepare the AOV data accordingly, and keeps the
83  // interop step simple.
84  HDX_API
85  static bool IsFormatSupported(HgiFormat aovFormat);
86 
87  HDX_API
88  HdxPresentTask(HdSceneDelegate* delegate, SdfPath const& id);
89 
90  HDX_API
91  ~HdxPresentTask() override;
92 
93  HDX_API
94  void Prepare(HdTaskContext* ctx,
95  HdRenderIndex* renderIndex) override;
96 
97  HDX_API
98  void Execute(HdTaskContext* ctx) override;
99 
100 protected:
101  HDX_API
102  void _Sync(HdSceneDelegate* delegate,
103  HdTaskContext* ctx,
104  HdDirtyBits* dirtyBits) override;
105 
106 private:
107  HdxPresentTaskParams _params;
108  HgiInterop _interop;
109 
110  HdxPresentTask() = delete;
111  HdxPresentTask(const HdxPresentTask &) = delete;
112  HdxPresentTask &operator =(const HdxPresentTask &) = delete;
113 };
114 
115 
116 
117 // VtValue requirements
118 HDX_API
119 std::ostream& operator<<(std::ostream& out, const HdxPresentTaskParams& pv);
120 HDX_API
121 bool operator==(const HdxPresentTaskParams& lhs,
122  const HdxPresentTaskParams& rhs);
123 HDX_API
124 bool operator!=(const HdxPresentTaskParams& lhs,
125  const HdxPresentTaskParams& rhs);
126 
127 
129 
130 #endif
Definition: vec4i.h:60
HDX_API void Execute(HdTaskContext *ctx) override
uint32_t HdDirtyBits
Definition: types.h:158
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
#define HDX_API
Definition: api.h:40
HgiFormat
Definition: types.h:45
HDX_API ~HdxPresentTask() override
Definition: token.h:87
static HDX_API bool IsFormatSupported(HgiFormat aovFormat)
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
Definition: path.h:290
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
Definition: task.h:44
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HDX_API std::ostream & operator<<(std::ostream &out, const HdxPresentTaskParams &pv)
Definition: value.h:164
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542