HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
oitResolveTask.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_OIT_RESOLVE_TASK_H
25 #define PXR_IMAGING_HDX_OIT_RESOLVE_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
30 #include "pxr/imaging/hd/task.h"
31 
32 #include <memory>
33 
35 
36 
37 class HdSceneDelegate;
38 
39 using HdRenderPassStateSharedPtr = std::shared_ptr<class HdRenderPassState>;
40 using HdStRenderPassStateSharedPtr = std::shared_ptr<class HdStRenderPassState>;
41 
43  std::shared_ptr<class HdSt_ImageShaderRenderPass>;
45  std::shared_ptr<class HdStRenderPassShader>;
46 
47 /// OIT resolve task params.
49 {
51  : useAovMultiSample(true)
52  , resolveAovMultiSample(true)
53  {}
54 
57 };
58 
59 /// \class HdxOitResolveTask
60 ///
61 /// A task for resolving previous passes to pixels.
62 ///
63 /// It is also responsible for allocating the OIT buffers, but it
64 /// leaves the clearing of the OIT buffers to the OIT render tasks.
65 /// OIT render tasks coordinate with the resolve task through
66 /// HdxOitResolveTask::OitBufferAccessor.
67 ///
68 class HdxOitResolveTask : public HdTask
69 {
70 public:
71  HDX_API
72  static bool IsOitEnabled();
73 
74  HDX_API
75  HdxOitResolveTask(HdSceneDelegate* delegate, SdfPath const& id);
76 
77  HDX_API
78  ~HdxOitResolveTask() override;
79 
80  /// Sync the resolve pass resources
81  HDX_API
82  void Sync(HdSceneDelegate* delegate,
83  HdTaskContext* ctx,
84  HdDirtyBits* dirtyBits) override;
85 
86  /// Prepare the tasks resources
87  ///
88  /// Allocates OIT buffers if requested by OIT render task
89  HDX_API
90  void Prepare(HdTaskContext* ctx,
91  HdRenderIndex* renderIndex) override;
92 
93  /// Execute render pass task
94  ///
95  /// Resolves OIT buffers
96  HDX_API
97  void Execute(HdTaskContext* ctx) override;
98 
99 private:
100  HdxOitResolveTask() = delete;
101  HdxOitResolveTask(const HdxOitResolveTask &) = delete;
102  HdxOitResolveTask &operator =(const HdxOitResolveTask &) = delete;
103 
104  void _PrepareOitBuffers(
105  HdTaskContext* ctx,
106  HdRenderIndex* renderIndex,
107  GfVec2i const& screenSize);
108 
109  GfVec2i _ComputeScreenSize(
110  HdTaskContext* ctx,
111  HdRenderIndex* renderIndex) const;
112 
113  const HdRenderPassAovBindingVector& _GetAovBindings(
114  HdTaskContext* ctx) const;
115 
116  void _UpdateCameraFraming(
117  HdTaskContext* ctx);
118 
119  HdRenderPassStateSharedPtr _GetContextRenderPassState(
120  HdTaskContext* ctx) const;
121 
123  HdStRenderPassStateSharedPtr _renderPassState;
124  HdStRenderPassShaderSharedPtr _renderPassShader;
125 
126  GfVec2i _screenSize;
127  HdBufferArrayRangeSharedPtr _counterBar;
129  HdBufferArrayRangeSharedPtr _depthBar;
130  HdBufferArrayRangeSharedPtr _indexBar;
131  HdBufferArrayRangeSharedPtr _uniformBar;
132 };
133 
134 HDX_API
135 bool operator==(const HdxOitResolveTaskParams& lhs,
136  const HdxOitResolveTaskParams& rhs);
137 HDX_API
138 bool operator!=(const HdxOitResolveTaskParams& lhs,
139  const HdxOitResolveTaskParams& rhs);
140 HDX_API
141 std::ostream& operator<<(std::ostream& out, const HdxOitResolveTaskParams& pv);
142 
144 
145 #endif
std::shared_ptr< class HdRenderPassState > HdRenderPassStateSharedPtr
Definition: engine.h:42
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Definition: vec2i.h:60
uint32_t HdDirtyBits
Definition: types.h:158
static HDX_API bool IsOitEnabled()
#define HDX_API
Definition: api.h:40
std::shared_ptr< class HdStRenderPassState > HdStRenderPassStateSharedPtr
Definition: commandBuffer.h:45
HDX_API void Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the resolve pass resources.
std::shared_ptr< class HdSt_ImageShaderRenderPass > HdSt_ImageShaderRenderPassSharedPtr
HDX_API ~HdxOitResolveTask() override
HDX_API void Execute(HdTaskContext *ctx) override
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:556
HDX_API std::ostream & operator<<(std::ostream &out, const HdxOitResolveTaskParams &pv)
Definition: task.h:54
Definition: path.h:290
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:77
std::shared_ptr< class HdStRenderPassShader > HdStRenderPassShaderSharedPtr
OIT resolve task params.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:44
std::vector< HdRenderPassAovBinding > HdRenderPassAovBindingVector
Definition: aov.h:154
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542