]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/bufferable.h
InstanceArray doesn't need to refresh the vertex arrays
[libs/gl.git] / source / core / bufferable.h
index f11d51fa0671b716f7897fdd1f2ed947892f8da9..25d29fd8f393021c6d6af4f86e624d77ec79705b 100644 (file)
@@ -41,7 +41,7 @@ private:
        Bufferable *next_in_buffer = 0;
        Bufferable *prev_in_buffer = 0;
        mutable bool location_dirty = false;
-       mutable bool dirty = false;
+       mutable uint8_t dirty = 0;
 
 protected:
        Bufferable() = default;
@@ -63,11 +63,11 @@ public:
        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); }
+       void refresh(unsigned f) const { if(dirty&(1<<f)) upload_data(f, 0); }
 
        /** Returns an object which can be used to upload data to the buffer using
        mapped memory.  If data is not dirty, returns null. */
-       AsyncUpdater *refresh_async() const { return dirty ? new AsyncUpdater(*this) : 0; }
+       AsyncUpdater *refresh_async() const { return dirty ? create_async_updater() : 0; }
 
 private:
        void unlink_from_buffer();
@@ -103,7 +103,9 @@ public:
 private:
        /** Uploads data to the buffer.  Receives pointer to mapped buffer memory as
        parameter, or null to use the buffer upload interface. */
-       void upload_data(char *) const;
+       void upload_data(unsigned, char *) const;
+
+       AsyncUpdater *create_async_updater() const;
 };
 
 } // namespace GL