+ /** Returns a pointer to the start of data in client memory. */
+ virtual const void *get_data_pointer() const = 0;
+
+ /** Returns the alignment required for the data, in bytes. The offset is
+ guaranteed to be a multiple of this. */
+ virtual unsigned get_alignment() const { return 1; }
+
+ /** Updates the offsets for the chain so that data from different objects
+ does not overlap. Should be called if either data size or alignment
+ changes. */
+ void update_offset();
+
+ /** Returns the offset where the data should be uploaded. */
+ unsigned get_offset() const { return offset; }
+
+ /** Called when the offset for the data has changed. */
+ virtual void offset_changed() { }
+
+private:
+ bool resize_buffer() const;
+
+protected:
+ /** Resizes the buffer if necessary and calls upload_data(). */
+ void update_buffer() const;
+
+ /** Uploads data to the buffer. Receives pointer to mapped buffer memory as
+ parameter. If null, buffer interface should be used instead. */
+ virtual void upload_data(char *) const;