gl: Memoize the bound range for a buffer

This commit is contained in:
kd-11 2024-04-23 05:02:10 +03:00 committed by kd-11
parent 3ef1eb8529
commit 4cf7b7022e
2 changed files with 6 additions and 0 deletions

View file

@ -146,11 +146,13 @@ namespace gl
void buffer::bind_range(u32 index, u32 offset, u32 size) const
{
m_bound_range = { offset, size };
glBindBufferRange(static_cast<GLenum>(current_target()), index, id(), offset, size);
}
void buffer::bind_range(target target_, u32 index, u32 offset, u32 size) const
{
m_bound_range = { offset, size };
glBindBufferRange(static_cast<GLenum>(target_), index, id(), offset, size);
}

View file

@ -74,6 +74,9 @@ namespace gl
target m_target = target::array;
memory_type m_memory_type = memory_type::undefined;
// Metadata
mutable std::pair<u32, u32> m_bound_range{};
void allocate(GLsizeiptr size, const void* data_, memory_type type, GLenum usage);
public:
@ -109,6 +112,7 @@ namespace gl
uint id() const { return m_id; }
void set_id(uint id) { m_id = id; }
bool created() const { return m_id != GL_NONE; }
std::pair<u32, u32> bound_range() const { return m_bound_range; }
explicit operator bool() const { return created(); }
};