HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
colorChannelTask.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 HDX_COLORCHANNEL_TASK_H
25 #define HDX_COLORCHANNEL_TASK_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/path.h"
29 #include "pxr/imaging/hdx/api.h"
31 #include "pxr/imaging/hdx/task.h"
32 #include "pxr/imaging/hdx/tokens.h"
33 
34 
36 
37 /// \class HdxColorChannelTask
38 ///
39 /// A task for choosing a color channel for display.
40 ///
42 {
43 public:
44  HDX_API
45  HdxColorChannelTask(HdSceneDelegate* delegate, SdfPath const& id);
46 
47  HDX_API
48  virtual ~HdxColorChannelTask();
49 
50  /// Prepare the tasks resources
51  HDX_API
52  virtual void Prepare(HdTaskContext* ctx,
53  HdRenderIndex* renderIndex) override;
54 
55  /// Execute the color channel task
56  HDX_API
57  virtual void Execute(HdTaskContext* ctx) override;
58 
59 protected:
60  /// Sync the render pass resources
61  HDX_API
62  virtual void _Sync(HdSceneDelegate* delegate,
63  HdTaskContext* ctx,
64  HdDirtyBits* dirtyBits) override;
65 
66 private:
67  HdxColorChannelTask() = delete;
68  HdxColorChannelTask(const HdxColorChannelTask &) = delete;
69  HdxColorChannelTask &operator =(const HdxColorChannelTask &) = delete;
70 
71  // Utility function to create a storage buffer for the shader parameters.
72  void _CreateParameterBuffer();
73 
74  /// Apply the color channel filtering.
75  void _ApplyColorChannel();
76 
77  // This struct must match ParameterBuffer in colorChannel.glslfx.
78  // Be careful to remember the std430 rules.
79  struct _ParameterBuffer
80  {
81  int channel;
82 
83  bool operator==(const _ParameterBuffer& other) const {
84  return channel == other.channel;
85  }
86  };
87 
88  std::unique_ptr<HdxFullscreenShader> _compositor;
89  _ParameterBuffer _parameterData;
90  HgiBufferHandle _parameterBuffer;
91 
92  // The color channel to be rendered (see HdxColorChannelTokens for the
93  // possible values).
94  TfToken _channel;
95 };
96 
97 
98 /// \class HdxColorChannelTaskParams
99 ///
100 /// ColorChannelTask parameters.
101 ///
103 {
105 
106  // Specifies which output color channel should be drawn. Defaults to 'color'
107  // (untouched RGBA).
108  TfToken channel = HdxColorChannelTokens->color;
109 };
110 
111 // VtValue requirements
112 HDX_API
113 std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
114 HDX_API
115 bool operator==(const HdxColorChannelTaskParams& lhs,
116  const HdxColorChannelTaskParams& rhs);
117 HDX_API
118 bool operator!=(const HdxColorChannelTaskParams& lhs,
119  const HdxColorChannelTaskParams& rhs);
120 
121 
123 
124 #endif
virtual HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
uint32_t HdDirtyBits
Definition: types.h:127
#define HDX_API
Definition: api.h:40
Definition: token.h:87
HDX_API std::ostream & operator<<(std::ostream &out, const HdxColorChannelTaskParams &pv)
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:563
virtual HDX_API ~HdxColorChannelTask()
Definition: path.h:288
virtual HDX_API void Execute(HdTaskContext *ctx) override
Execute the color channel task.
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:73
Definition: task.h:44
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
HDX_API bool operator==(const HdxColorChannelTaskParams &lhs, const HdxColorChannelTaskParams &rhs)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:549