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,
81 BINDLESS_ARRAY_OF_TEXTURE_2D,
82 BINDLESS_TEXTURE_FIELD,
84 BINDLESS_TEXTURE_UDIM_ARRAY,
85 BINDLESS_TEXTURE_UDIM_LAYOUT,
86 BINDLESS_TEXTURE_PTEX_TEXEL,
87 BINDLESS_TEXTURE_PTEX_LAYOUT,
100 HdBinding(Type type,
int location,
int textureUnit=0) {
101 Set(type, location, textureUnit);
103 void Set(Type type,
int location,
int textureUnit) {
104 _typeAndLocation = (textureUnit << 24)|(location << 8)|(int)(type);
106 bool IsValid()
const {
return _typeAndLocation >= 0; }
107 Type GetType()
const {
return (Type)(_typeAndLocation & 0xff); }
108 int GetLocation()
const {
return (_typeAndLocation >> 8) & 0xffff; }
109 int GetTextureUnit()
const {
return (_typeAndLocation >> 24) & 0xff; }
110 int GetValue()
const {
return _typeAndLocation; }
111 bool operator < (
HdBinding const &b)
const {
112 return (_typeAndLocation < b._typeAndLocation);
115 int _typeAndLocation;
136 : _bindingType(bindingType)
137 , _dataType(HdTypeInvalid)
141 , _isInterleaved(false)
144 , _concatenateNames(false)
151 : _bindingType(bindingType)
152 , _dataType(dataType)
156 , _isInterleaved(false)
159 , _concatenateNames(false)
165 HdBufferResourceSharedPtr
const& resource)
166 : _bindingType(bindingType)
167 , _dataType(resource->GetTupleType().type)
169 , _resource(resource)
171 , _isInterleaved(false)
174 , _concatenateNames(false)
183 HdBufferArrayRangeSharedPtr bar,
184 bool interleave,
bool writable =
false,
185 size_t arraySize = 0,
bool concatenateNames =
false)
187 , _dataType(HdTypeInvalid)
191 , _isInterleaved(interleave)
192 , _isWritable(writable)
193 , _arraySize(arraySize)
194 , _concatenateNames(concatenateNames)
204 return bool(_resource);
211 return _bar && !_isInterleaved;
219 return _bar && _isInterleaved;
225 return _bar && _isWritable;
231 return (!_bar) && (!_resource) && (_dataType == HdTypeInvalid);
255 if (_resource)
return _resource->GetOffset();
259 if (_bar)
return _bar->GetByteOffset(
TfToken());
264 HdBufferArrayRangeSharedPtr
const&
GetBar()
const {
281 return _concatenateNames;
306 template <
class HashState>
321 HdBinding::Type _bindingType;
326 HdBufferResourceSharedPtr _resource;
329 HdBufferArrayRangeSharedPtr _bar;
336 bool _concatenateNames;
340 PXR_NAMESPACE_CLOSE_SCOPE
342 #endif // PXR_IMAGING_HD_BINDING_H HdBindingRequest(HdBinding::Type bindingType, TfToken const &name, HdBufferResourceSharedPtr const &resource)
A buffer resource binding.
size_t GetArraySize() const
Array size if request is for an array of structs.
bool IsTypeless() const
This binding is typelss.
Bindings are used for buffers or textures, it simple associates a binding type with a binding locatio...
bool isWritable() const
True when the resource is being bound so that it can be written to.
HdBindingRequest(HdBinding::Type bindingType, TfToken const &name, HdType dataType)
A data binding, not backed by neither BufferArrayRange nor BufferResource.
Token for efficient comparison, assignment, and hashing of known strings.
bool IsResource() const
Resource bingings have a single associated Hydra resource, but no buffer array.
HdBufferArrayRangeSharedPtr const & GetBar() const
Returns the buffer array range associated with this binding request or null when IsBufferArrqay() ret...
HD_API size_t ComputeHash() const
Returns the hash corresponding to this buffer request.
TfToken const & GetName() const
Returns the name of the binding point, if any; buffer arrays and structs need not be named.
HdBindingRequest(HdBinding::Type bindingType, TfToken const &name)
A data binding, not backed by neither BufferArrayRange nor BufferResource.
bool IsBufferArray() const
A buffer array binding has several buffers bundled together and each buffer will be bound individuall...
int GetByteOffset() const
Returns the resource or buffer array range offset, defaults to zero.
bool ConcatenateNames() const
Returns whether the struct binding point and struct member names should be concatenated when codegen'...
bool IsInterleavedBufferArray() const
Like BufferArray binding requests, struct bindings have several buffers, however they must be allocat...
HdBinding::Type GetBindingType() const
Returns the HdBinding type of this request.
BindingRequest allows externally allocated buffers to be bound at render time.
HdBindingRequest(HdBinding::Type type, TfToken const &name, HdBufferArrayRangeSharedPtr bar, bool interleave, bool writable=false, size_t arraySize=0, bool concatenateNames=false)
A named struct binding.
HdBufferResourceSharedPtr const & GetResource() const
Returns the single resource associated with this binding request or null when IsResource() returns fa...
HdType GetDataType() const
Return the data type of this request.