X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbufferable.cpp;fp=source%2Fcore%2Fbufferable.cpp;h=69588dddef301d72f0eda7128209a5fba632cc63;hb=6d2e2a0bb28496a8c25b441009bdd2a1a1e72d81;hp=502c270c8f6bad09861841847e1dc71d70d006c7;hpb=5003bcfeb0832ec2d0f74f4149bc97888a70a900;p=libs%2Fgl.git
diff --git a/source/core/bufferable.cpp b/source/core/bufferable.cpp
index 502c270c..69588ddd 100644
--- a/source/core/bufferable.cpp
+++ b/source/core/bufferable.cpp
@@ -128,14 +128,20 @@ void Bufferable::update_offset()
void Bufferable::mark_dirty()
{
- dirty = true;
+ dirty = 0xFF;
}
-void Bufferable::upload_data(char *target) const
+void Bufferable::upload_data(unsigned frame, char *target) const
{
if(!buffer)
throw invalid_operation("Bufferable::upload_data");
+ unsigned multi_buf = buffer->get_multiplicity();
+ frame %= multi_buf;
+ uint8_t mask = 1<sub_data(offset, data_size, get_data_pointer());
- dirty = false;
+ buffer->sub_data(frame*buffer->get_size()+offset, data_size, get_data_pointer());
+ dirty &= ~mask;
+ if(!(dirty&((1<get_multiplicity()>1)
+ throw invalid_operation("Bufferable::create_async_updater");
+ return new AsyncUpdater(*this);
}
@@ -168,14 +183,14 @@ Bufferable::AsyncUpdater::~AsyncUpdater()
void Bufferable::AsyncUpdater::upload_data()
{
- bufferable.upload_data(mapped_address+bufferable.offset);
+ bufferable.upload_data(0, mapped_address+bufferable.offset);
// Update all bufferables in the same buffer at once
for(const Bufferable *b=bufferable.prev_in_buffer; b; b=b->prev_in_buffer)
if(b->dirty)
- b->upload_data(mapped_address+b->offset);
+ b->upload_data(0, mapped_address+b->offset);
for(const Bufferable *b=bufferable.next_in_buffer; b; b=b->next_in_buffer)
if(b->dirty)
- b->upload_data(mapped_address+b->offset);
+ b->upload_data(0, mapped_address+b->offset);
}
} // namespace GL