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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HDX_PRESENT_TASK_H
8 #define PXR_IMAGING_HDX_PRESENT_TASK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/imaging/hdx/api.h"
12 #include "pxr/imaging/hdx/task.h"
13 #include "pxr/imaging/hgi/tokens.h"
14 #include "pxr/imaging/hgi/types.h"
16 
18 
19 /// \class HdxPresentTaskParams
20 ///
21 /// PresentTask parameters.
22 ///
24 {
26  : dstApi(HgiTokens->OpenGL)
27  , dstRegion(0)
28  , enabled(true)
29  {}
30 
31  // The graphics lib that is used by the application / viewer.
32  // (The 'interopSrc' is determined by checking Hgi->GetAPIName)
34 
35  /// The framebuffer that the AOVs are presented into. This is a
36  /// VtValue that encoding a framebuffer in a dstApi specific
37  /// way.
38  ///
39  /// E.g., a uint32_t (aka GLuint) for framebuffer object for dstApi==OpenGL.
40  /// For backwards compatibility, the currently bound framebuffer is used
41  /// when the VtValue is empty.
43 
44  // Subrectangular region of the framebuffer over which to composite aov
45  // contents. Coordinates are (left, BOTTOM, width, height).
47 
48  // When not enabled, present task does not execute, but still calls
49  // Hgi::EndFrame.
50  bool enabled;
51 };
52 
53 /// \class HdxPresentTask
54 ///
55 /// A task for taking the final result of the aovs and compositing it over the
56 /// currently bound framebuffer.
57 /// This task uses the 'color' and optionally 'depth' aov's in the task
58 /// context. The 'color' aov is expected to use non-integer
59 /// (i.e., float or norm) types to keep the interop step simple.
60 ///
61 class HdxPresentTask : public HdxTask
62 {
63 public:
65 
66  // Returns true if the format is supported for presentation. This is useful
67  // for upstream tasks to prepare the AOV data accordingly, and keeps the
68  // interop step simple.
69  HDX_API
70  static bool IsFormatSupported(HgiFormat aovFormat);
71 
72  HDX_API
73  HdxPresentTask(HdSceneDelegate* delegate, SdfPath const& id);
74 
75  HDX_API
76  ~HdxPresentTask() override;
77 
78  HDX_API
79  void Prepare(HdTaskContext* ctx,
80  HdRenderIndex* renderIndex) override;
81 
82  HDX_API
83  void Execute(HdTaskContext* ctx) override;
84 
85 protected:
86  HDX_API
87  void _Sync(HdSceneDelegate* delegate,
88  HdTaskContext* ctx,
89  HdDirtyBits* dirtyBits) override;
90 
91 private:
92  HdxPresentTaskParams _params;
93  HgiInterop _interop;
94 
95  HdxPresentTask() = delete;
96  HdxPresentTask(const HdxPresentTask &) = delete;
97  HdxPresentTask &operator =(const HdxPresentTask &) = delete;
98 };
99 
100 
101 
102 // VtValue requirements
103 HDX_API
104 std::ostream& operator<<(std::ostream& out, const HdxPresentTaskParams& pv);
105 HDX_API
106 bool operator==(const HdxPresentTaskParams& lhs,
107  const HdxPresentTaskParams& rhs);
108 HDX_API
109 bool operator!=(const HdxPresentTaskParams& lhs,
110  const HdxPresentTaskParams& rhs);
111 
112 
114 
115 #endif
Definition: vec4i.h:43
HDX_API void Execute(HdTaskContext *ctx) override
uint32_t HdDirtyBits
Definition: types.h:143
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:2539
#define HDX_API
Definition: api.h:23
HgiFormat
Definition: types.h:28
HDX_API ~HdxPresentTask() override
Definition: token.h:70
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:273
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
Definition: task.h:27
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDX_API std::ostream & operator<<(std::ostream &out, const HdxPresentTaskParams &pv)
Definition: value.h:146
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542