HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
drawTargetRenderPassState.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 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_HD_ST_DRAW_TARGET_RENDER_PASS_STATE_H
25 #define PXR_IMAGING_HD_ST_DRAW_TARGET_RENDER_PASS_STATE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/enums.h"
31 #include "pxr/usd/sdf/path.h"
32 
34 
35 
36 class VtValue;
38  std::vector<class HdRenderPassAovBinding>;
39 
40 /// \class HdStDrawTargetRenderPassState
41 ///
42 /// Represents common non-gl context specific render pass state for a draw
43 /// target.
44 ///
45 /// \note This is a temporary API to aid transition to Storm, and is subject
46 /// to major changes. It is likely this functionality will be absorbed into
47 /// the base class.
48 ///
50 public:
51  HDST_API
53  HDST_API
54  ~HdStDrawTargetRenderPassState(); // final no need to be virtual
55 
57  return _aovBindings;
58  }
59 
60  HDST_API
61  void SetAovBindings(const HdRenderPassAovBindingVector &aovBindings);
62 
63  /// Set the number of color buffer's to use.
64  HDST_API
66 
67  /// Set the clear value for a color buffer that is applied at the beginning
68  /// of rendering. The expected type of clearValue is dependent on the
69  /// format of the buffer specified in current draw target at execute time.
70  /// (i.e. there is no order dependency between setting the draw target and
71  /// color values.
72  /// An unexpected formats results in an error and the buffer not being
73  /// cleared.
74  HDST_API
75  void SetColorClearValue(size_t attachmentIdx, const VtValue &clearValue);
76 
77  /// Set the clear value for the depth buffer. It is expected the
78  /// clear value is a normalize float.
79  HDST_API
80  void SetDepthClearValue(float clearValue);
81 
82  /// Sets the priority of values in the depth buffer.
83  /// i.e. should pixels closer or further from the camera win.
84  HDST_API
85  void SetDepthPriority(HdDepthPriority priority);
86 
87  /// Set the path to the camera to use to draw this render path from.
88  HDST_API
89  void SetCamera(const SdfPath &cameraId);
90 
91  HDST_API
92  void SetRprimCollection(HdRprimCollection const& col);
93 
94  /// Returns the number of color buffers attached to the draw target.
95  size_t GetNumColorAttachments() const { return _colorClearValues.size(); }
96 
97  /// Returns the clear color for the specified buffer. The type
98  /// is dependant on the format of the buffer.
99  const VtValue &GetColorClearValue(size_t attachmentIdx) const
100  {
101  TF_DEV_AXIOM(attachmentIdx < _colorClearValues.size());
102 
103  return _colorClearValues[attachmentIdx];
104  }
105 
106  /// Returns the clear value for the z-buffer.
107  float GetDepthClearValue() const { return _depthClearValue; }
108 
109 
110  HdDepthPriority GetDepthPriority() const { return _depthPriority; }
111 
112 
113  /// Returns the path to the camera to render from.
114  const SdfPath &GetCamera() const { return _cameraId; }
115 
116  /// Returns an increasing version number for when the collection object
117  /// is changed.
118  /// Note: This tracks the actual object and not the contents of the
119  /// collection.
120  unsigned int GetRprimCollectionVersion() const
121  {
122  return _rprimCollectionVersion;
123  }
124 
125  /// Returns the collection associated with this draw target.
127  {
128  return _rprimCollection;
129  }
130 
131 private:
132  HdRenderPassAovBindingVector _aovBindings;
133  std::vector<VtValue> _colorClearValues;
134  float _depthClearValue;
135  HdDepthPriority _depthPriority;
136 
137  SdfPath _cameraId;
138 
139  HdRprimCollection _rprimCollection;
140  unsigned int _rprimCollectionVersion;
141 
142  HdStDrawTargetRenderPassState(const HdStDrawTargetRenderPassState &) = delete;
143  HdStDrawTargetRenderPassState &operator =(const HdStDrawTargetRenderPassState &) = delete;
144 };
145 
146 
148 
149 #endif // PXR_IMAGING_HD_ST_DRAW_TARGET_RENDER_PASS_STATE_H
const VtValue & GetColorClearValue(size_t attachmentIdx) const
HdDepthPriority
Definition: enums.h:237
HDST_API void SetCamera(const SdfPath &cameraId)
Set the path to the camera to use to draw this render path from.
GLsizei numAttachments
Definition: glew.h:4075
#define TF_DEV_AXIOM(cond)
HDST_API void SetColorClearValue(size_t attachmentIdx, const VtValue &clearValue)
HDST_API HdStDrawTargetRenderPassState()
size_t GetNumColorAttachments() const
Returns the number of color buffers attached to the draw target.
HdDepthPriority GetDepthPriority() const
HDST_API void SetDepthClearValue(float clearValue)
HDST_API void SetAovBindings(const HdRenderPassAovBindingVector &aovBindings)
Definition: path.h:288
HDST_API void SetNumColorAttachments(size_t numAttachments)
Set the number of color buffer's to use.
unsigned int GetRprimCollectionVersion() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
#define HDST_API
Definition: api.h:40
const HdRenderPassAovBindingVector & GetAovBindings() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
float GetDepthClearValue() const
Returns the clear value for the z-buffer.
HDST_API void SetRprimCollection(HdRprimCollection const &col)
const SdfPath & GetCamera() const
Returns the path to the camera to render from.
const HdRprimCollection & GetRprimCollection() const
Returns the collection associated with this draw target.
HDST_API ~HdStDrawTargetRenderPassState()
std::vector< HdRenderPassAovBinding > HdRenderPassAovBindingVector
Definition: aov.h:147
Definition: value.h:174
HDST_API void SetDepthPriority(HdDepthPriority priority)