11 #ifndef hifi_gpu_Stream_h
12 #define hifi_gpu_Stream_h
40 SKIN_CLUSTER_INDEX = 5,
41 SKIN_CLUSTER_WEIGHT = 6,
54 static const std::array<Element, InputSlot::NUM_INPUT_SLOTS>& getDefaultElements();
68 Attribute(Slot slot, Slot channel, Element element, Offset offset = 0, Frequency frequency = PER_VERTEX) :
76 Slot _slot{ POSITION };
77 Slot _channel{ POSITION };
78 Element _element{ Element::VEC3F_XYZ };
80 uint32 _frequency{ PER_VERTEX };
83 uint32 getSize()
const {
return _element.getSize(); }
86 std::string getKey()
const;
92 typedef std::map< Slot, Attribute > AttributeMap;
96 std::vector< Slot > _slots;
97 std::vector< Offset > _offsets;
101 ChannelInfo() : _stride(0), _netSize(0) {}
103 typedef std::map< Slot, ChannelInfo > ChannelMap;
105 size_t getNumAttributes()
const {
return _attributes.size(); }
106 const AttributeMap& getAttributes()
const {
return _attributes; }
108 size_t getNumChannels()
const {
return _channels.size(); }
109 const ChannelMap& getChannels()
const {
return _channels; }
110 Offset getChannelStride(Slot channel)
const {
return _channels.at(channel)._stride; }
112 size_t getElementTotalSize()
const {
return _elementTotalSize; }
114 bool setAttribute(Slot slot, Slot channel, Element element, Offset offset = 0, Frequency frequency = PER_VERTEX);
115 bool setAttribute(Slot slot, Frequency frequency = PER_VERTEX);
116 bool setAttribute(Slot slot, Slot channel, Frequency frequency = PER_VERTEX);
118 bool hasAttribute(Slot slot)
const {
return (_attributes.find(slot) != _attributes.end()); }
119 Attribute getAttribute(Slot slot)
const;
121 const std::string& getKey()
const {
return _key; }
123 const GPUObjectPointer gpuObject{};
126 AttributeMap _attributes;
127 ChannelMap _channels;
128 uint32 _elementTotalSize { 0 };
131 friend class Serializer;
132 friend class Deserializer;
133 void evaluateCache();
136 typedef std::shared_ptr<Format> FormatPointer;
139 typedef std::vector< Offset > Offsets;
145 using Strides = Offsets;
147 void clear() { _buffers.clear(); _offsets.clear(); _strides.clear(); }
148 void addBuffer(
const BufferPointer& buffer, Offset offset, Offset stride);
150 const Buffers& getBuffers()
const {
return _buffers; }
151 const Offsets& getOffsets()
const {
return _offsets; }
152 const Strides& getStrides()
const {
return _strides; }
153 size_t getNumBuffers()
const {
return _buffers.size(); }
155 BufferStream makeRangedStream(uint32 offset, uint32 count = -1)
const;
157 BufferStream& operator = (
const BufferStream& src) =
default;
164 typedef std::shared_ptr<BufferStream> BufferStreamPointer;