[Misc] (MG_State/Buffer): reserve buffer size rounding up to next power of 2 to make resize complexity logarithmic

This commit is contained in:
2025-07-08 15:44:11 +08:00
parent c43ae7ed2c
commit fbb1fc1fdb
+1
View File
@@ -71,6 +71,7 @@ GLenum BufferState::CommitStorage(GLenum target, GLsizeiptr size, const void* da
obj.usage = usage;
obj.isDynamic = (usage == GL_DYNAMIC_DRAW || usage == GL_DYNAMIC_READ ||
usage == GL_DYNAMIC_COPY || usage == GL_STREAM_DRAW);
obj.data.reserve(std::bit_ceil((size_t)size));
obj.data.resize(size);
if (data) {
memcpy(obj.data.data(), data, size);