template< /** Type of the values stored in this uniform buffer. */ typename T, /** The number of values that can be stored in this uniform buffer. */ int64_t len> class StructArrayBuffer { private: T data_[len]; GPUUniformBuf *ubo_; public: StructArrayBuffer() { ubo_ = GPU_uniformbuf_create_ex(sizeof(data_), nullptr, STRINGIFY(T)); } ~StructArrayBuffer() { GPU_uniformbuf_free(ubo_); } void push_update(void) { GPU_uniformbuf_update(ubo_, data_); } const GPUUniformBuf *ubo_get(void) const { return ubo_; } /** * Get the value at the given index. This invokes undefined behavior when the index is out of * bounds. */ const T &operator[](int64_t index) const { BLI_assert(index >= 0); BLI_assert(index < len); return data_[index]; } T &operator[](int64_t index) { BLI_assert(index >= 0); BLI_assert(index < len); return data_[index]; } };