Loading...
Searching...
No Matches
presentTask.h
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/base/gf/vec4f.h"
14#include "pxr/imaging/hgi/tokens.h"
15#include "pxr/imaging/hgi/types.h"
16#include "pxr/imaging/hgiInterop/hgiInterop.h"
17
18PXR_NAMESPACE_OPEN_SCOPE
19
25{
27 : dstApi(HgiTokens->OpenGL)
28 , dstRegion(0)
29 , normalizedSrcRegion(0.0F, 0.0F, 1.0F, 1.0F)
30 , enabled(true)
31 {}
32
33 // The graphics lib that is used by the application / viewer.
34 // (The 'interopSrc' is determined by checking Hgi->GetAPIName)
35 TfToken dstApi;
36
45
46 // Subrectangular region of the framebuffer over which to composite aov
47 // contents. Coordinates are (left, BOTTOM, width, height), which is the
48 // same convention as OpenGL viewport coordinates. Note that this
49 // is specified in *pixel* coordinates.
50 GfVec4i dstRegion;
51
52 // Normalized [0,1] sub-rectangle of the source AOV textures to sample.
53 // Coordinates are (left, bottom, width, height). Identity is (0,0,1,1)
54 // which samples the entire texture. Note this is specified in *normalized*
55 // coordinates.
56 GfVec4f normalizedSrcRegion;
57
58 // When not enabled, present task does not execute, but still calls
59 // Hgi::EndFrame.
60 bool enabled;
61};
62
71class HdxPresentTask : public HdxTask
72{
73public:
75
76 // Returns true if the format is supported for presentation. This is useful
77 // for upstream tasks to prepare the AOV data accordingly, and keeps the
78 // interop step simple.
79 HDX_API
80 static bool IsFormatSupported(HgiFormat aovFormat);
81
82 HDX_API
83 HdxPresentTask(HdSceneDelegate* delegate, SdfPath const& id);
84
85 HDX_API
86 ~HdxPresentTask() override;
87
88 HDX_API
89 void Prepare(HdTaskContext* ctx,
90 HdRenderIndex* renderIndex) override;
91
92 HDX_API
93 void Execute(HdTaskContext* ctx) override;
94
95protected:
96 HDX_API
97 void _Sync(HdSceneDelegate* delegate,
98 HdTaskContext* ctx,
99 HdDirtyBits* dirtyBits) override;
100
101private:
102 HdxPresentTaskParams _params;
103 HgiInterop _interop;
104
105 HdxPresentTask() = delete;
106 HdxPresentTask(const HdxPresentTask &) = delete;
107 HdxPresentTask &operator =(const HdxPresentTask &) = delete;
108};
109
110
111
112// VtValue requirements
113HDX_API
114std::ostream& operator<<(std::ostream& out, const HdxPresentTaskParams& pv);
115HDX_API
116bool operator==(const HdxPresentTaskParams& lhs,
117 const HdxPresentTaskParams& rhs);
118HDX_API
119bool operator!=(const HdxPresentTaskParams& lhs,
120 const HdxPresentTaskParams& rhs);
121
122
123PXR_NAMESPACE_CLOSE_SCOPE
124
125#endif
Basic type for a vector of 4 float components.
Definition vec4f.h:48
Basic type for a vector of 4 int components.
Definition vec4i.h:46
The render index is part of the Hydra 1.0 API and is only used for emulation purposes so that HdScene...
Adapter class providing data exchange with the client scene graph.
A task for taking the final result of the aovs and compositing it over the currently bound framebuffe...
Definition presentTask.h:72
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare Phase: Resolve bindings and manage resources.
HDX_API void Execute(HdTaskContext *ctx) override
Execute Phase: Runs the task.
Base class for (some) tasks in Hdx that provides common progressive rendering and Hgi functionality.
Definition task.h:28
Hydra Graphics Interface Interop.
Definition hgiInterop.h:34
A path value used to locate objects in layers or scenegraphs.
Definition path.h:281
Token for efficient comparison, assignment, and hashing of known strings.
Definition token.h:81
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition value.h:90
PresentTask parameters.
Definition presentTask.h:25
VtValue dstFramebuffer
The framebuffer that the AOVs are presented into.
Definition presentTask.h:44