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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef HDX_COLORCHANNEL_TASK_H
8 #define HDX_COLORCHANNEL_TASK_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/sdf/path.h"
12 #include "pxr/imaging/hdx/api.h"
13 #include "pxr/imaging/hdx/task.h"
14 #include "pxr/imaging/hdx/tokens.h"
16 
18 
20 
21 /// \class HdxColorChannelTask
22 ///
23 /// A task for choosing a color channel for display.
24 ///
26 {
27 public:
29 
30  HDX_API
31  HdxColorChannelTask(HdSceneDelegate* delegate, SdfPath const& id);
32 
33  HDX_API
34  ~HdxColorChannelTask() override;
35 
36  /// Prepare the tasks resources
37  HDX_API
38  void Prepare(HdTaskContext* ctx,
39  HdRenderIndex* renderIndex) override;
40 
41  /// Execute the color channel task
42  HDX_API
43  void Execute(HdTaskContext* ctx) override;
44 
45 protected:
46  /// Sync the render pass resources
47  HDX_API
48  void _Sync(HdSceneDelegate* delegate,
49  HdTaskContext* ctx,
50  HdDirtyBits* dirtyBits) override;
51 
52 private:
53  HdxColorChannelTask() = delete;
54  HdxColorChannelTask(const HdxColorChannelTask &) = delete;
55  HdxColorChannelTask &operator =(const HdxColorChannelTask &) = delete;
56 
57  // Utility function to update the shader uniform parameters.
58  // Returns true if the values were updated. False if unchanged.
59  bool _UpdateParameterBuffer(float screenSizeX, float screenSizeY);
60 
61  /// Apply the color channel filtering.
62  void _ApplyColorChannel();
63 
64  // This struct must match ParameterBuffer in colorChannel.glslfx.
65  // Be careful to remember the std430 rules.
66  struct _ParameterBuffer
67  {
68  float screenSize[2];
69  int channel;
70  bool operator==(const _ParameterBuffer& other) const {
71  return channel == other.channel &&
72  screenSize[0] == other.screenSize[0] &&
73  screenSize[1] == other.screenSize[1];
74  }
75  };
76 
77  std::unique_ptr<class HdxFullscreenShader> _compositor;
78  _ParameterBuffer _parameterData;
79 
80  // The color channel to be rendered (see HdxColorChannelTokens for the
81  // possible values).
82  TfToken _channel;
83 };
84 
85 
86 /// \class HdxColorChannelTaskParams
87 ///
88 /// ColorChannelTask parameters.
89 ///
91 {
93 
94  // Specifies which output color channel should be drawn. Defaults to 'color'
95  // (untouched RGBA).
96  TfToken channel = HdxColorChannelTokens->color;
97 };
98 
99 // VtValue requirements
100 HDX_API
101 std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
102 HDX_API
103 bool operator==(const HdxColorChannelTaskParams& lhs,
104  const HdxColorChannelTaskParams& rhs);
105 HDX_API
106 bool operator!=(const HdxColorChannelTaskParams& lhs,
107  const HdxColorChannelTaskParams& rhs);
108 
109 
111 
112 #endif
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
uint32_t HdDirtyBits
Definition: types.h:143
HDX_API ~HdxColorChannelTask() override
#define HDX_API
Definition: api.h:23
Definition: token.h:70
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:556
Definition: path.h:273
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
Definition: task.h:27
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
HDX_API bool operator==(const HdxColorChannelTaskParams &lhs, const HdxColorChannelTaskParams &rhs)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDX_API void Execute(HdTaskContext *ctx) override
Execute the color channel task.
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.