HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resourceBindings.h
Go to the documentation of this file.
1 //
2 // Copyright 2020 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_HGI_RESOURCEBINDINGS_H
25 #define PXR_IMAGING_HGI_RESOURCEBINDINGS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hgi/api.h"
29 #include "pxr/imaging/hgi/buffer.h"
30 #include "pxr/imaging/hgi/enums.h"
31 #include "pxr/imaging/hgi/handle.h"
34 #include "pxr/imaging/hgi/types.h"
35 
36 #include <string>
37 #include <vector>
38 
39 
41 
42 
43 
44 
45 
46 /// \struct HgiBufferBindDesc
47 ///
48 /// Describes the binding information of a buffer (or array of buffers).
49 ///
50 /// <ul>
51 /// <li>buffers:
52 /// The buffer(s) to be bound.
53 /// If there are more than one buffer, the buffers will be put in an
54 /// array-of-buffers. Please note that different platforms have varying
55 /// limits to max buffers in an array.</li>
56 /// <li>offsets:
57 /// Offset (in bytes) where data begins from the start of the buffer.
58 /// This if an offset for each buffer in 'buffers'.</li>
59 /// <li>resourceType:
60 /// The type of buffer(s) that is to be bound.
61 /// All buffers in the array must have the same type.
62 /// Note that vertex and index buffers are not bound to a resourceSet.
63 /// They are instead passed to the draw command.</li>
64 /// <li>bindingIndex:
65 /// Binding location for the buffer(s).</li>
66 /// <li>stageUsage:
67 /// What shader stage(s) the buffer will be used in.</li>
68 /// </ul>
69 ///
71 {
72  HGI_API
74 
76  std::vector<uint32_t> offsets;
78  uint32_t bindingIndex;
80 };
81 using HgiBufferBindDescVector = std::vector<HgiBufferBindDesc>;
82 
83 HGI_API
84 bool operator==(
85  const HgiBufferBindDesc& lhs,
86  const HgiBufferBindDesc& rhs);
87 
88 HGI_API
89 inline bool operator!=(
90  const HgiBufferBindDesc& lhs,
91  const HgiBufferBindDesc& rhs);
92 
93 /// \struct HgiTextureBindDesc
94 ///
95 /// Describes the binding information of a texture (or array of textures).
96 ///
97 /// <ul>
98 /// <li>textures:
99 /// The texture(s) to be bound.
100 /// If there are more than one texture, the textures will be put in an
101 /// array-of-textures (not texture-array). Please note that different
102 /// platforms have varying limits to max textures in an array.</li>
103 /// <li>samplers:
104 /// (optional) The sampler(s) to be bound for each texture in `textures`.
105 /// If empty a default sampler (clamp_to_edge, linear) should be used. </li>
106 /// <li>resourceType:
107 /// The type of the texture(s) that is to be bound.
108 /// All textures in the array must have the same type.</li>
109 /// <li>bindingIndex:
110 /// Binding location for the texture</li>
111 /// <li>stageUsage:
112 /// What shader stage(s) the texture will be used in.</li>
113 /// </ul>
114 ///
116 {
117  HGI_API
119 
123  uint32_t bindingIndex;
125 };
126 using HgiTextureBindDescVector = std::vector<HgiTextureBindDesc>;
127 
128 HGI_API
129 bool operator==(
130  const HgiTextureBindDesc& lhs,
131  const HgiTextureBindDesc& rhs);
132 
133 HGI_API
134 bool operator!=(
135  const HgiTextureBindDesc& lhs,
136  const HgiTextureBindDesc& rhs);
137 
138 /// \struct HgiResourceBindingsDesc
139 ///
140 /// Describes a set of resources that are bound to the GPU during encoding.
141 ///
142 /// <ul>
143 /// <li>pipelineType:
144 /// Bind point for pipeline.</li>
145 /// <li>buffers:
146 /// The buffers to be bound (E.g. uniform or shader storage).</li>
147 /// <li>textures:
148 /// The textures to be bound.</li>
149 /// </ul>
150 ///
152 {
153  HGI_API
155 
160 };
161 
162 HGI_API
163 bool operator==(
164  const HgiResourceBindingsDesc& lhs,
165  const HgiResourceBindingsDesc& rhs);
166 
167 HGI_API
168 bool operator!=(
169  const HgiResourceBindingsDesc& lhs,
170  const HgiResourceBindingsDesc& rhs);
171 
172 
173 ///
174 /// \class HgiResourceBindings
175 ///
176 /// Represents a collection of buffers, texture and vertex attributes that will
177 /// be used by an cmds object (and pipeline).
178 ///
180 {
181 public:
182  HGI_API
183  virtual ~HgiResourceBindings();
184 
185  /// The descriptor describes the object.
186  HGI_API
187  HgiResourceBindingsDesc const& GetDescriptor() const;
188 
189 protected:
190  HGI_API
192 
194 
195 private:
196  HgiResourceBindings() = delete;
197  HgiResourceBindings & operator=(const HgiResourceBindings&) = delete;
198  HgiResourceBindings(const HgiResourceBindings&) = delete;
199 };
200 
201 /// Explicitly instantiate and define ResourceBindings handle
204 using HgiResourceBindingsHandleVector = std::vector<HgiResourceBindingsHandle>;
205 
206 
208 
209 #endif
HgiBindResourceType resourceType
HgiPipelineType pipelineType
HgiTextureHandleVector textures
std::vector< HgiTextureBindDesc > HgiTextureBindDescVector
virtual HGI_API ~HgiResourceBindings()
std::vector< HgiBufferBindDesc > HgiBufferBindDescVector
std::vector< HgiTextureHandle > HgiTextureHandleVector
Definition: texture.h:163
HgiBufferBindDescVector buffers
HGI_API HgiTextureBindDesc()
std::vector< uint32_t > offsets
std::vector< HgiBufferHandle > HgiBufferHandleVector
Definition: buffer.h:142
HgiBindResourceType
Definition: enums.h:322
bool operator!=(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Inequality operator, does exact floating point comparisons.
Definition: Mat3.h:563
std::vector< HgiResourceBindingsHandle > HgiResourceBindingsHandleVector
HGI_API HgiResourceBindingsDesc()
HgiPipelineType
Definition: enums.h:291
HgiTextureBindDescVector textures
HgiResourceBindingsDesc _descriptor
HgiShaderStage stageUsage
HGI_API HgiResourceBindingsDesc const & GetDescriptor() const
The descriptor describes the object.
GLsizei const GLchar *const * string
Definition: glew.h:1844
#define HGI_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
HgiShaderStage stageUsage
HgiBufferHandleVector buffers
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HgiBits HgiShaderStage
Definition: enums.h:278
std::vector< HgiSamplerHandle > HgiSamplerHandleVector
Definition: sampler.h:135
HgiBindResourceType resourceType
HgiSamplerHandleVector samplers
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:549
HGI_API HgiBufferBindDesc()