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,
63 BINDLESS_ARRAY_OF_TEXTURE_2D,
64 BINDLESS_TEXTURE_FIELD,
66 BINDLESS_TEXTURE_UDIM_ARRAY,
67 BINDLESS_TEXTURE_UDIM_LAYOUT,
68 BINDLESS_TEXTURE_PTEX_TEXEL,
69 BINDLESS_TEXTURE_PTEX_LAYOUT,
82 HdStBinding(Type type,
int location,
int textureUnit=0) {
83 Set(type, location, textureUnit);
85 void Set(Type type,
int location,
int textureUnit) {
86 _typeAndLocation = (textureUnit << 24)|(location << 8)|(int)(type);
88 bool IsValid()
const {
return _typeAndLocation >= 0; }
89 Type GetType()
const {
return (Type)(_typeAndLocation & 0xff); }
90 int GetLocation()
const {
return (_typeAndLocation >> 8) & 0xffff; }
91 int GetTextureUnit()
const {
return (_typeAndLocation >> 24) & 0xff; }
92 int GetValue()
const {
return _typeAndLocation; }
94 return (_typeAndLocation < b._typeAndLocation);
118 : _bindingType(bindingType)
119 , _dataType(HdTypeInvalid)
123 , _isInterleaved(false)
126 , _concatenateNames(false)
133 : _bindingType(bindingType)
134 , _dataType(dataType)
138 , _isInterleaved(false)
141 , _concatenateNames(false)
147 HdStBufferResourceSharedPtr
const& resource)
148 : _bindingType(bindingType)
149 , _dataType(resource->GetTupleType().type)
151 , _resource(resource)
153 , _isInterleaved(false)
156 , _concatenateNames(false)
165 HdBufferArrayRangeSharedPtr bar,
166 bool interleave,
bool writable =
false,
167 size_t arraySize = 0,
bool concatenateNames =
false)
169 , _dataType(HdTypeInvalid)
173 , _isInterleaved(interleave)
174 , _isWritable(writable)
175 , _arraySize(arraySize)
176 , _concatenateNames(concatenateNames)
186 return bool(_resource);
193 return _bar && !_isInterleaved;
201 return _bar && _isInterleaved;
207 return _bar && _isWritable;
213 return (!_bar) && (!_resource) && (_dataType == HdTypeInvalid);
237 if (_resource)
return _resource->GetOffset();
241 if (_bar)
return _bar->GetByteOffset(
TfToken());
246 HdBufferArrayRangeSharedPtr
const&
GetBar()
const {
263 return _concatenateNames;
288 template <
class HashState>
303 HdStBinding::Type _bindingType;
308 HdStBufferResourceSharedPtr _resource;
311 HdBufferArrayRangeSharedPtr _bar;
318 bool _concatenateNames;
322PXR_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.