Showing the changes to interface/src/gpu/Stream.cpp (1 of 3 files). Show all
Unified · Split
| @@ -0,0 +1,50 @@ | |||
| 1 | // | ||
| 2 | // Stream.cpp | ||
| 3 | // interface/src/gpu | ||
| 4 | // | ||
| 5 | // Created by Sam Gateau on 10/29/2014. | ||
| 6 | // Copyright 2014 High Fidelity, Inc. | ||
| 7 | // | ||
| 8 | // Distributed under the Apache License, Version 2.0. | ||
| 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
| 10 | // | ||
| 11 | |||
| 12 | #include "Stream.h" | ||
| 13 | |||
| 14 | using namespace gpu; | ||
| 15 | |||
| 16 | void StreamFormat::evaluateCache() { | ||
| 17 | _channels.clear(); | ||
| 18 | _elementTotalSize = 0; | ||
| 19 | for(AttributeMap::iterator it = _attributes.begin(); it != _attributes.end(); it++) { | ||
| 20 | Attribute& attrib = (*it).second; | ||
| 21 | Channel& channel = _channels[attrib._channel]; | ||
| 22 | channel._slots.push_back(attrib._slot); | ||
| 23 | channel._stride = std::max(channel._stride, attrib.getSize() + attrib._offset); | ||
| 24 | channel._netSize += attrib.getSize(); | ||
| 25 | _elementTotalSize += attrib.getSize(); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | bool StreamFormat::setAttribute(Slot slot, uint8 channel, Element element, uint32 offset, Frequency frequency) { | ||
| 30 | _attributes[slot] = Attribute(slot, channel, element, offset, frequency); | ||
| 31 | evaluateCache(); | ||
| 32 | return true; | ||
| 33 | } | ||
| 34 | |||
| 35 | Stream::Stream() : | ||
| 36 | _buffers(), | ||
| 37 | _offsets() | ||
| 38 | {} | ||
| 39 | |||
| 40 | Stream::~Stream() | ||
| 41 | { | ||
| 42 | _buffers.clear(); | ||
| 43 | _offsets.clear(); | ||
| 44 | } | ||
| 45 | |||
| 46 | void Stream::addBuffer(BufferPtr& buffer, uint32 offset, uint32 stride) { | ||
| 47 | _buffers.push_back(buffer); | ||
| 48 | _offsets.push_back(offset); | ||
| 49 | _strides.push_back(stride); | ||
| 50 | } | ||