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  // This struct must match ParameterBuffer in colorChannel.glslfx.
62  // Be careful to remember the std430 rules.
63  struct _ParameterBuffer
64  {
65  float screenSize[2];
66  int channel;
67  bool operator==(const _ParameterBuffer& other) const {
68  return channel == other.channel &&
69  screenSize[0] == other.screenSize[0] &&
70  screenSize[1] == other.screenSize[1];
71  }
72  };
73 
74  std::unique_ptr<class HdxFullscreenShader> _compositor;
75  _ParameterBuffer _parameterData;
76 
77  // The color channel to be rendered (see HdxColorChannelTokens for the
78  // possible values).
79  TfToken _channel;
80 };
81 
82 
83 /// \class HdxColorChannelTaskParams
84 ///
85 /// ColorChannelTask parameters.
86 ///
88 {
90 
91  // Specifies which output color channel should be drawn. Defaults to 'color'
92  // (untouched RGBA).
93  TfToken channel = HdxColorChannelTokens->color;
94 };
95 
96 // VtValue requirements
97 HDX_API
98 std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
99 HDX_API
100 bool operator==(const HdxColorChannelTaskParams& lhs,
101  const HdxColorChannelTaskParams& rhs);
102 HDX_API
103 bool operator!=(const HdxColorChannelTaskParams& lhs,
104  const HdxColorChannelTaskParams& rhs);
105 
106 
108 
109 #endif
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.
uint32_t HdDirtyBits
Definition: types.h:143
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
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:280
std::unordered_map< TfToken, VtValue, TfToken::HashFunctor > HdTaskContext
Definition: renderIndex.h:61
Definition: task.h:27
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.