24 #ifndef PXR_IMAGING_HDST_BINDING_H 25 #define PXR_IMAGING_HDST_BINDING_H 28 #include "pxr/imaging/hdSt/api.h" 30 #include "pxr/imaging/hd/bufferArrayRange.h" 31 #include "pxr/imaging/hd/bufferResource.h" 32 #include "pxr/imaging/hd/types.h" 36 PXR_NAMESPACE_OPEN_SCOPE
39 using HdStBindingVector = std::vector<class HdStBinding>;
40 using HdStBindingRequestVector = std::vector<class HdStBindingRequest>;
55 DRAW_INDEX_INSTANCE_ARRAY,
80 BINDLESS_ARRAY_OF_TEXTURE_2D,
81 BINDLESS_TEXTURE_FIELD,
83 BINDLESS_TEXTURE_UDIM_ARRAY,
84 BINDLESS_TEXTURE_UDIM_LAYOUT,
85 BINDLESS_TEXTURE_PTEX_TEXEL,
86 BINDLESS_TEXTURE_PTEX_LAYOUT,
99 HdStBinding(Type type,
int location,
int textureUnit=0) {
100 Set(type, location, textureUnit);
102 void Set(Type type,
int location,
int textureUnit) {
103 _typeAndLocation = (textureUnit << 24)|(location << 8)|(int)(type);
105 bool IsValid()
const {
return _typeAndLocation >= 0; }
106 Type GetType()
const {
return (Type)(_typeAndLocation & 0xff); }
107 int GetLocation()
const {
return (_typeAndLocation >> 8) & 0xffff; }
108 int GetTextureUnit()
const {
return (_typeAndLocation >> 24) & 0xff; }
109 int GetValue()
const {
return _typeAndLocation; }
111 return (_typeAndLocation < b._typeAndLocation);
114 int _typeAndLocation;
135 : _bindingType(bindingType)
136 , _dataType(HdTypeInvalid)
140 , _isInterleaved(false)
143 , _concatenateNames(false)
150 : _bindingType(bindingType)
151 , _dataType(dataType)
155 , _isInterleaved(false)
158 , _concatenateNames(false)
164 HdBufferResourceSharedPtr
const& resource)
165 : _bindingType(bindingType)
166 , _dataType(resource->GetTupleType().type)
168 , _resource(resource)
170 , _isInterleaved(false)
173 , _concatenateNames(false)
182 HdBufferArrayRangeSharedPtr bar,
183 bool interleave,
bool writable =
false,
184 size_t arraySize = 0,
bool concatenateNames =
false)
186 , _dataType(HdTypeInvalid)
190 , _isInterleaved(interleave)
191 , _isWritable(writable)
192 , _arraySize(arraySize)
193 , _concatenateNames(concatenateNames)
203 return bool(_resource);
210 return _bar && !_isInterleaved;
218 return _bar && _isInterleaved;
224 return _bar && _isWritable;
230 return (!_bar) && (!_resource) && (_dataType == HdTypeInvalid);
254 if (_resource)
return _resource->GetOffset();
258 if (_bar)
return _bar->GetByteOffset(
TfToken());
263 HdBufferArrayRangeSharedPtr
const&
GetBar()
const {
280 return _concatenateNames;
305 template <
class HashState>
320 HdStBinding::Type _bindingType;
325 HdBufferResourceSharedPtr _resource;
328 HdBufferArrayRangeSharedPtr _bar;
335 bool _concatenateNames;
339 PXR_NAMESPACE_CLOSE_SCOPE
341 #endif // PXR_IMAGING_HDST_BINDING_H
HdStBindingRequest(HdStBinding::Type bindingType, TfToken const &name)
A data binding, not backed by neither BufferArrayRange nor BufferResource.
HdType GetDataType() const
Return the data type of this request.
HdStBindingRequest(HdStBinding::Type bindingType, TfToken const &name, HdBufferResourceSharedPtr const &resource)
A buffer resource binding.
HdStBinding::Type GetBindingType() const
Returns the HdStBinding type of this request.
HdStBindingRequest(HdStBinding::Type type, TfToken const &name, HdBufferArrayRangeSharedPtr bar, bool interleave, bool writable=false, size_t arraySize=0, bool concatenateNames=false)
A named struct binding.
bool IsBufferArray() const
A buffer array binding has several buffers bundled together and each buffer will be bound individuall...
Token for efficient comparison, assignment, and hashing of known strings.
bool IsInterleavedBufferArray() const
Like BufferArray binding requests, struct bindings have several buffers, however they must be allocat...
Bindings are used for buffers or textures, it simply associates a binding type with a binding locatio...
TfToken const & GetName() const
Returns the name of the binding point, if any; buffer arrays and structs need not be named.
size_t GetArraySize() const
Array size if request is for an array of structs.
HDST_API size_t ComputeHash() const
Returns the hash corresponding to this buffer request.
bool ConcatenateNames() const
Returns whether the struct binding point and struct member names should be concatenated when codegen'...
HdBufferArrayRangeSharedPtr const & GetBar() const
Returns the buffer array range associated with this binding request or null when IsBufferArrqay() ret...
HdBufferResourceSharedPtr const & GetResource() const
Returns the single resource associated with this binding request or null when IsResource() returns fa...
HdStBindingRequest(HdStBinding::Type bindingType, TfToken const &name, HdType dataType)
A data binding, not backed by neither BufferArrayRange nor BufferResource.
int GetByteOffset() const
Returns the resource or buffer array range offset, defaults to zero.
bool IsResource() const
Resource bingings have a single associated Hydra resource, but no buffer array.
bool IsTypeless() const
This binding is typelss.
bool isWritable() const
True when the resource is being bound so that it can be written to.
BindingRequest allows externally allocated buffers to be bound at render time.