#include namespace plot::render { namespace detail { bool InstanceStore::create(Status* st) noexcept { // plot::gl::Buffer::create() already reports Unsupported while the entry // points are unresolved and GLFailure when the driver hands out no name, so // the wrapper only has to propagate its answer. if (!buffer_.create(st)) { return false; } capacity_ = 0; return true; } void InstanceStore::upload(const void* data, u32 count, usize instance_bytes) noexcept { if (buffer_.id() == 0 || count == 0 || instance_bytes == 0) { return; } if (count > capacity_) { // Only a workload larger than anything staged so far pays for an // allocation; a frame that repeats the previous one writes into the store // that is already there. buffer_.upload(nullptr, static_cast(count) * instance_bytes, gl::GL_STREAM_DRAW); capacity_ = count; } buffer_.upload_sub(data, static_cast(count) * instance_bytes, 0); } } // namespace detail } // namespace plot::render