11 #ifndef hifi_gpu_Stream_h
12 #define hifi_gpu_Stream_h
40 SKIN_CLUSTER_INDEX = 5,
41 SKIN_CLUSTER_WEIGHT = 6,
61 static const std::array<Element, InputSlot::NUM_INPUT_SLOTS>& getDefaultElements();
75 Attribute(Slot slot, Slot channel, Element element, Offset offset = 0, Frequency frequency = PER_VERTEX) :
83 Slot _slot{ POSITION };
84 Slot _channel{ POSITION };
85 Element _element{ Element::VEC3F_XYZ };
87 uint32 _frequency{ PER_VERTEX };
90 uint32 getSize()
const {
return _element.getSize(); }
93 std::string getKey()
const;
99 typedef std::map< Slot, Attribute > AttributeMap;
103 std::vector< Slot > _slots;
104 std::vector< Offset > _offsets;
107 uint32 _frequency{ PER_VERTEX };
109 ChannelInfo() : _stride(0), _netSize(0) {}
111 typedef std::map< Slot, ChannelInfo > ChannelMap;
113 size_t getNumAttributes()
const {
return _attributes.size(); }
114 const AttributeMap& getAttributes()
const {
return _attributes; }
116 size_t getNumChannels()
const {
return _channels.size(); }
117 const ChannelMap& getChannels()
const {
return _channels; }
118 Offset getChannelStride(Slot channel)
const {
return _channels.at(channel)._stride; }
120 size_t getElementTotalSize()
const {
return _elementTotalSize; }
122 bool setAttribute(Slot slot, Slot channel, Element element, Offset offset = 0, Frequency frequency = PER_VERTEX);
123 bool setAttribute(Slot slot, Frequency frequency = PER_VERTEX);
124 bool setAttribute(Slot slot, Slot channel, Frequency frequency = PER_VERTEX);
126 bool hasAttribute(Slot slot)
const {
return (_attributes.find(slot) != _attributes.end()); }
127 Attribute getAttribute(Slot slot)
const;
129 const std::string& getKey()
const {
return _key; }
131 const GPUObjectPointer gpuObject{};
134 AttributeMap _attributes;
135 ChannelMap _channels;
136 uint32 _elementTotalSize { 0 };
139 friend class Serializer;
140 friend class Deserializer;
141 void evaluateCache();
144 typedef std::shared_ptr<Format> FormatPointer;
147 typedef std::vector< Offset > Offsets;
153 using Strides = Offsets;
155 void clear() { _buffers.clear(); _offsets.clear(); _strides.clear(); }
156 void addBuffer(
const BufferPointer& buffer, Offset offset, Offset stride);
158 const Buffers& getBuffers()
const {
return _buffers; }
159 const Offsets& getOffsets()
const {
return _offsets; }
160 const Strides& getStrides()
const {
return _strides; }
161 size_t getNumBuffers()
const {
return _buffers.size(); }
163 BufferStream makeRangedStream(uint32 offset, uint32 count = -1)
const;
165 BufferStream& operator = (
const BufferStream& src) =
default;
172 typedef std::shared_ptr<BufferStream> BufferStreamPointer;