2019-11-02 12:21:56 +00:00
|
|
|
#pragma once
|
2019-11-03 05:22:37 +00:00
|
|
|
#include "../types.h"
|
2022-07-08 11:57:06 +00:00
|
|
|
#include "loader.h"
|
2019-11-02 12:21:56 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <tuple>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace GL {
|
|
|
|
class StreamBuffer
|
|
|
|
{
|
|
|
|
public:
|
2019-11-06 14:08:13 +00:00
|
|
|
virtual ~StreamBuffer();
|
2019-11-02 12:21:56 +00:00
|
|
|
|
|
|
|
ALWAYS_INLINE GLuint GetGLBufferId() const { return m_buffer_id; }
|
|
|
|
ALWAYS_INLINE GLenum GetGLTarget() const { return m_target; }
|
|
|
|
ALWAYS_INLINE u32 GetSize() const { return m_size; }
|
|
|
|
|
|
|
|
void Bind();
|
2019-11-02 13:42:44 +00:00
|
|
|
void Unbind();
|
2019-11-02 12:21:56 +00:00
|
|
|
|
|
|
|
struct MappingResult
|
|
|
|
{
|
|
|
|
void* pointer;
|
2019-11-03 03:15:17 +00:00
|
|
|
u32 buffer_offset;
|
2019-11-02 12:21:56 +00:00
|
|
|
u32 index_aligned; // offset / alignment, suitable for base vertex
|
|
|
|
u32 space_aligned; // remaining space / alignment
|
|
|
|
};
|
|
|
|
|
2019-11-06 14:08:13 +00:00
|
|
|
virtual MappingResult Map(u32 alignment, u32 min_size) = 0;
|
|
|
|
virtual void Unmap(u32 used_size) = 0;
|
2019-11-02 12:21:56 +00:00
|
|
|
|
|
|
|
static std::unique_ptr<StreamBuffer> Create(GLenum target, u32 size);
|
|
|
|
|
2019-11-06 14:08:13 +00:00
|
|
|
protected:
|
2019-11-02 12:21:56 +00:00
|
|
|
StreamBuffer(GLenum target, GLuint buffer_id, u32 size);
|
|
|
|
|
|
|
|
GLenum m_target;
|
|
|
|
GLuint m_buffer_id;
|
|
|
|
u32 m_size;
|
|
|
|
};
|
|
|
|
} // namespace GL
|