All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
colorChannelTask.h
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"
30 #include "pxr/imaging/hdx/task.h"
31 #include "pxr/imaging/hdx/tokens.h"
32 #include "pxr/imaging/hgi/graphicsCmds.h"
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
41 {
42 public:
43  HDX_API
44  HdxColorChannelTask(HdSceneDelegate* delegate, SdfPath const& id);
45 
46  HDX_API
47  ~HdxColorChannelTask() override;
48 
50  HDX_API
51  void Prepare(HdTaskContext* ctx,
52  HdRenderIndex* renderIndex) override;
53 
55  HDX_API
56  void Execute(HdTaskContext* ctx) override;
57 
58 protected:
60  HDX_API
61  void _Sync(HdSceneDelegate* delegate,
62  HdTaskContext* ctx,
63  HdDirtyBits* dirtyBits) override;
64 
65 private:
66  HdxColorChannelTask() = delete;
67  HdxColorChannelTask(const HdxColorChannelTask &) = delete;
68  HdxColorChannelTask &operator =(const HdxColorChannelTask &) = delete;
69 
70  // Utility function to update the shader uniform parameters.
71  // Returns true if the values were updated. False if unchanged.
72  bool _UpdateParameterBuffer(float screenSizeX, float screenSizeY);
73 
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  float screenSize[2];
82  int channel;
83  bool operator==(const _ParameterBuffer& other) const {
84  return channel == other.channel &&
85  screenSize[0] == other.screenSize[0] &&
86  screenSize[1] == other.screenSize[1];
87  }
88  };
89 
90  std::unique_ptr<class HdxFullscreenShader> _compositor;
91  _ParameterBuffer _parameterData;
92 
93  // The color channel to be rendered (see HdxColorChannelTokens for the
94  // possible values).
95  TfToken _channel;
96 };
97 
98 
104 {
106 
107  // Specifies which output color channel should be drawn. Defaults to 'color'
108  // (untouched RGBA).
109  TfToken channel = HdxColorChannelTokens->color;
110 };
111 
112 // VtValue requirements
113 HDX_API
114 std::ostream& operator<<(std::ostream& out, const HdxColorChannelTaskParams& pv);
115 HDX_API
116 bool operator==(const HdxColorChannelTaskParams& lhs,
117  const HdxColorChannelTaskParams& rhs);
118 HDX_API
119 bool operator!=(const HdxColorChannelTaskParams& lhs,
120  const HdxColorChannelTaskParams& rhs);
121 
122 
123 PXR_NAMESPACE_CLOSE_SCOPE
124 
125 #endif
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:116
ColorChannelTask parameters.
AR_API bool operator!=(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
AR_API bool operator==(const ArAssetInfo &lhs, const ArAssetInfo &rhs)
HDX_API void _Sync(HdSceneDelegate *delegate, HdTaskContext *ctx, HdDirtyBits *dirtyBits) override
Sync the render pass resources.
HDX_API void Execute(HdTaskContext *ctx) override
Execute the color channel task.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
A task for choosing a color channel for display.
Base class for (some) tasks in Hdx that provides common progressive rendering and Hgi functionality...
Definition: task.h:44
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare the tasks resources.