X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fbufferable.cpp;h=6b770a8f68f2c447bb18fe608930cba4bf9e6ab7;hb=bb8b03770053cbddda88577e261ec4ee482e6c5c;hp=569ffb2f08a252cb1d153e591df420a1108dcf5a;hpb=6c525eff3eaaa617648a869449ed3bddf9c1936d;p=libs%2Fgl.git diff --git a/source/bufferable.cpp b/source/bufferable.cpp index 569ffb2f..6b770a8f 100644 --- a/source/bufferable.cpp +++ b/source/bufferable.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include "bindable.h" #include "buffer.h" #include "bufferable.h" @@ -40,6 +42,7 @@ void Bufferable::use_buffer(Buffer *buf, Bufferable *prev) } } + dirty = true; update_offset(); } @@ -106,7 +109,8 @@ bool Bufferable::resize_buffer() const void Bufferable::update_buffer() const { - BindRestore bind(buffer, buffer->get_type()); + Conditional _bind(!ARB_direct_state_access, buffer, buffer->get_type()); + if(resize_buffer()) { /* Resizing the buffer invalidates its contents. Non-dirty data may @@ -120,7 +124,6 @@ void Bufferable::update_buffer() const } upload_data(0); - dirty = false; } void Bufferable::upload_data(char *target) const @@ -132,6 +135,7 @@ void Bufferable::upload_data(char *target) const } else buffer->sub_data(offset, get_data_size(), get_data_pointer()); + dirty = false; } @@ -153,16 +157,10 @@ void Bufferable::AsyncUpdater::upload_data() // 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 || buffer_resized) - { b->upload_data(mapped_address+b->offset); - b->dirty = false; - } for(const Bufferable *b=bufferable.next_in_buffer; b; b=b->next_in_buffer) if(b->dirty || buffer_resized) - { b->upload_data(mapped_address+b->offset); - b->dirty = false; - } } } // namespace GL