24 #ifndef PXR_IMAGING_HD_BINDING_H
25 #define PXR_IMAGING_HD_BINDING_H
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/types.h"
32 #include "pxr/imaging/hd/bufferResource.h"
33 #include "pxr/imaging/hd/bufferArrayRange.h"
37 PXR_NAMESPACE_OPEN_SCOPE
40 typedef std::vector<class HdBinding> HdBindingVector;
41 typedef std::vector<class HdBindingRequest> HdBindingRequestVector;
56 DRAW_INDEX_INSTANCE_ARRAY,
78 BINDLESS_TEXTURE_FIELD,
80 BINDLESS_TEXTURE_UDIM_ARRAY,
81 BINDLESS_TEXTURE_UDIM_LAYOUT,
82 BINDLESS_TEXTURE_PTEX_TEXEL,
83 BINDLESS_TEXTURE_PTEX_LAYOUT,
96 HdBinding(Type type,
int location,
int textureUnit=0) {
97 Set(type, location, textureUnit);
99 void Set(Type type,
int location,
int textureUnit) {
100 _typeAndLocation = (textureUnit << 24)|(location << 8)|(int)(type);
102 bool IsValid()
const {
return _typeAndLocation >= 0; }
103 Type GetType()
const {
return (Type)(_typeAndLocation & 0xff); }
104 int GetLocation()
const {
return (_typeAndLocation >> 8) & 0xffff; }
105 int GetTextureUnit()
const {
return (_typeAndLocation >> 24) & 0xff; }
106 int GetValue()
const {
return _typeAndLocation; }
107 bool operator < (
HdBinding const &b)
const {
108 return (_typeAndLocation < b._typeAndLocation);
111 int _typeAndLocation;
132 : _bindingType(bindingType)
133 , _dataType(HdTypeInvalid)
137 , _isInterleaved(false)
144 : _bindingType(bindingType)
145 , _dataType(dataType)
149 , _isInterleaved(false)
155 HdBufferResourceSharedPtr
const& resource)
156 : _bindingType(bindingType)
157 , _dataType(resource->GetTupleType().type)
159 , _resource(resource)
161 , _isInterleaved(false)
170 HdBufferArrayRangeSharedPtr bar,
173 , _dataType(HdTypeInvalid)
177 , _isInterleaved(interleave)
187 return bool(_resource);
194 return _bar && !_isInterleaved;
202 return _bar && _isInterleaved;
208 return (!_bar) && (!_resource) && (_dataType == HdTypeInvalid);
232 if (_resource)
return _resource->GetOffset();
236 if (_bar)
return _bar->GetByteOffset(
TfToken());
241 HdBufferArrayRangeSharedPtr
const&
GetBar()
const {
272 template <
class HashState>
287 HdBinding::Type _bindingType;
292 HdBufferResourceSharedPtr _resource;
295 HdBufferArrayRangeSharedPtr _bar;
301 PXR_NAMESPACE_CLOSE_SCOPE
303 #endif // PXR_IMAGING_HD_BINDING_H
HdBinding::Type GetBindingType() const
Returns the HdBinding type of this request.
HdBindingRequest(HdBinding::Type bindingType, TfToken const &name, HdBufferResourceSharedPtr const &resource)
A buffer resource binding.
bool IsBufferArray() const
A buffer array binding has several buffers bundled together and each buffer will be bound individuall...
HdBindingRequest(HdBinding::Type type, TfToken const &name, HdBufferArrayRangeSharedPtr bar, bool interleave)
A named struct binding.
Bindings are used for buffers or textures, it simple associates a binding type with a binding locatio...
HdBindingRequest(HdBinding::Type bindingType, TfToken const &name, HdType dataType)
A data binding, not backed by neither BufferArrayRange nor BufferResource.
TfToken const & GetName() const
Returns the name of the binding point, if any; buffer arrays and structs need not be named...
HdType GetDataType() const
Return the data type of this request.
HdBufferResourceSharedPtr const & GetResource() const
Returns the single resource associated with this binding request or null when IsResource() returns fa...
Token for efficient comparison, assignment, and hashing of known strings.
HdBindingRequest(HdBinding::Type bindingType, TfToken const &name)
A data binding, not backed by neither BufferArrayRange nor BufferResource.
bool IsTypeless() const
This binding is typelss.
HD_API size_t ComputeHash() const
Returns the hash corresponding to this buffer request.
bool IsResource() const
Resource bingings have a single associated Hydra resource, but no buffer array.
int GetByteOffset() const
Returns the resource or buffer array range offset, defaults to zero.
BindingRequest allows externally allocated buffers to be bound at render time.
HdBufferArrayRangeSharedPtr const & GetBar() const
Returns the buffer array range associated with this binding request or null when IsBufferArrqay() ret...
bool IsInterleavedBufferArray() const
Like BufferArray binding requests, struct bindings have several buffers, however they must be allocat...