}
}
-size_t Bufferable::get_required_buffer_size() const
+size_t Bufferable::get_required_buffer_size(bool align) const
{
const Bufferable *last = this;
for(; last->next_in_buffer; last=last->next_in_buffer) ;
- return last->offset+last->get_data_size();
+ size_t size = last->offset+last->get_data_size();
+ if(align)
+ {
+ const Bufferable *first = this;
+ for(; first->prev_in_buffer; first=first->prev_in_buffer) ;
+ size_t alignment = first->get_alignment();
+ size += alignment-1;
+ size -= size%alignment;
+ }
+ return size;
}
void Bufferable::unlink_from_buffer()
/** Returns the total amount of storage required by this object and others
in the same chain, including any padding required by object alignment. */
- std::size_t get_required_buffer_size() const;
+ std::size_t get_required_buffer_size(bool = false) const;
/** Uploads new data into the buffer if necessary. */
void refresh() const { if(dirty) upload_data(0); }