7#ifndef PXR_IMAGING_HDST_BINDING_H
8#define PXR_IMAGING_HDST_BINDING_H
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hdSt/bufferResource.h"
14#include "pxr/imaging/hd/bufferArrayRange.h"
15#include "pxr/imaging/hd/types.h"
19PXR_NAMESPACE_OPEN_SCOPE
22using HdStBindingVector = std::vector<class HdStBinding>;
23using HdStBindingRequestVector = std::vector<class HdStBindingRequest>;
38 DRAW_INDEX_INSTANCE_ARRAY,
64 BINDLESS_ARRAY_OF_TEXTURE_2D,
65 BINDLESS_TEXTURE_FIELD,
67 BINDLESS_TEXTURE_UDIM_ARRAY,
68 BINDLESS_TEXTURE_UDIM_LAYOUT,
69 BINDLESS_TEXTURE_PTEX_TEXEL,
70 BINDLESS_TEXTURE_PTEX_LAYOUT,
71 BINDLESS_TEXTURE_CUBEMAP,
84 HdStBinding(Type type,
int location,
int textureUnit=0) {
85 Set(type, location, textureUnit);
87 void Set(Type type,
int location,
int textureUnit) {
88 _typeAndLocation = (textureUnit << 24)|(location << 8)|(int)(type);
90 bool IsValid()
const {
return _typeAndLocation >= 0; }
91 Type GetType()
const {
return (Type)(_typeAndLocation & 0xff); }
92 int GetLocation()
const {
return (_typeAndLocation >> 8) & 0xffff; }
93 int GetTextureUnit()
const {
return (_typeAndLocation >> 24) & 0xff; }
94 int GetValue()
const {
return _typeAndLocation; }
96 return (_typeAndLocation < b._typeAndLocation);
120 : _bindingType(bindingType)
121 , _dataType(HdTypeInvalid)
125 , _isInterleaved(false)
128 , _concatenateNames(false)
135 : _bindingType(bindingType)
136 , _dataType(dataType)
140 , _isInterleaved(false)
143 , _concatenateNames(false)
149 HdStBufferResourceSharedPtr
const& resource)
150 : _bindingType(bindingType)
151 , _dataType(resource->GetTupleType().type)
153 , _resource(resource)
155 , _isInterleaved(false)
158 , _concatenateNames(false)
167 HdBufferArrayRangeSharedPtr bar,
168 bool interleave,
bool writable =
false,
169 size_t arraySize = 0,
bool concatenateNames =
false)
171 , _dataType(HdTypeInvalid)
175 , _isInterleaved(interleave)
176 , _isWritable(writable)
177 , _arraySize(arraySize)
178 , _concatenateNames(concatenateNames)
188 return bool(_resource);
195 return _bar && !_isInterleaved;
203 return _bar && _isInterleaved;
209 return _bar && _isWritable;
215 return (!_bar) && (!_resource) && (_dataType == HdTypeInvalid);
239 if (_resource)
return _resource->GetOffset();
243 if (_bar)
return _bar->GetByteOffset(
TfToken());
248 HdBufferArrayRangeSharedPtr
const&
GetBar()
const {
265 return _concatenateNames;
290 template <
class HashState>
305 HdStBinding::Type _bindingType;
310 HdStBufferResourceSharedPtr _resource;
313 HdBufferArrayRangeSharedPtr _bar;
320 bool _concatenateNames;
324PXR_NAMESPACE_CLOSE_SCOPE
Bindings are used for buffers or textures, it simply associates a binding type with a binding locatio...
BindingRequest allows externally allocated buffers to be bound at render time.
HdStBindingRequest(HdStBinding::Type bindingType, TfToken const &name)
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 IsTypeless() const
This binding is typelss.
bool IsBufferArray() const
A buffer array binding has several buffers bundled together and each buffer will be bound individuall...
HdStBindingRequest(HdStBinding::Type bindingType, TfToken const &name, HdType dataType)
A data binding, not backed by neither BufferArrayRange nor BufferResource.
bool ConcatenateNames() const
Returns whether the struct binding point and struct member names should be concatenated when codegen'...
size_t GetArraySize() const
Array size if request is for an array of structs.
bool isWritable() const
True when the resource is being bound so that it can be written to.
HdStBufferResourceSharedPtr const & GetResource() const
Returns the single resource associated with this binding request or null when IsResource() returns fa...
bool IsInterleavedBufferArray() const
Like BufferArray binding requests, struct bindings have several buffers, however they must be allocat...
HDST_API size_t ComputeHash() const
Returns the hash corresponding to this buffer request.
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.
HdStBindingRequest(HdStBinding::Type bindingType, TfToken const &name, HdStBufferResourceSharedPtr const &resource)
A buffer resource binding.
TfToken const & GetName() const
Returns the name of the binding point, if any; buffer arrays and structs need not be named.
bool IsResource() const
Resource bingings have a single associated Hydra resource, but no buffer array.
HdType GetDataType() const
Return the data type of this request.
HdBufferArrayRangeSharedPtr const & GetBar() const
Returns the buffer array range associated with this binding request or null when IsBufferArrqay() ret...
Token for efficient comparison, assignment, and hashing of known strings.