Common: Persistent-mapped stream buffer implementation

This commit is contained in:
Connor McLaughlin
2019-11-07 00:08:13 +10:00
parent ff8cef4da3
commit 26c22f003f
3 changed files with 270 additions and 33 deletions

View File

@ -6,11 +6,10 @@
#include <vector>
namespace GL {
// TODO: Persistent mapping-based implementation
class StreamBuffer
{
public:
~StreamBuffer();
virtual ~StreamBuffer();
ALWAYS_INLINE GLuint GetGLBufferId() const { return m_buffer_id; }
ALWAYS_INLINE GLenum GetGLTarget() const { return m_target; }
@ -27,18 +26,16 @@ public:
u32 space_aligned; // remaining space / alignment
};
MappingResult Map(u32 alignment, u32 min_size);
void Unmap(u32 used_size);
virtual MappingResult Map(u32 alignment, u32 min_size) = 0;
virtual void Unmap(u32 used_size) = 0;
static std::unique_ptr<StreamBuffer> Create(GLenum target, u32 size);
private:
protected:
StreamBuffer(GLenum target, GLuint buffer_id, u32 size);
GLenum m_target;
GLuint m_buffer_id;
u32 m_size;
std::vector<u8> m_cpu_buffer;
};
} // namespace GL