diff options
author | Markus Wick <markus@selfnet.de> | 2018-08-09 21:31:46 +0200 |
---|---|---|
committer | Markus Wick <markus@selfnet.de> | 2018-08-12 15:47:35 +0200 |
commit | d7298ec2626f013167ea254276259ac7b39f46be (patch) | |
tree | c011140a61d25b1f93894b9ed7d683e54b1b8e06 /src/video_core/renderer_opengl/gl_stream_buffer.h | |
parent | Merge pull request #1029 from bunnei/fix-out-attrib (diff) | |
download | yuzu-d7298ec2626f013167ea254276259ac7b39f46be.tar yuzu-d7298ec2626f013167ea254276259ac7b39f46be.tar.gz yuzu-d7298ec2626f013167ea254276259ac7b39f46be.tar.bz2 yuzu-d7298ec2626f013167ea254276259ac7b39f46be.tar.lz yuzu-d7298ec2626f013167ea254276259ac7b39f46be.tar.xz yuzu-d7298ec2626f013167ea254276259ac7b39f46be.tar.zst yuzu-d7298ec2626f013167ea254276259ac7b39f46be.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_stream_buffer.h')
-rw-r--r-- | src/video_core/renderer_opengl/gl_stream_buffer.h | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/src/video_core/renderer_opengl/gl_stream_buffer.h b/src/video_core/renderer_opengl/gl_stream_buffer.h index e78dc5784..45592daaf 100644 --- a/src/video_core/renderer_opengl/gl_stream_buffer.h +++ b/src/video_core/renderer_opengl/gl_stream_buffer.h @@ -2,35 +2,41 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once - -#include <memory> +#include <tuple> #include <glad/glad.h> #include "common/common_types.h" #include "video_core/renderer_opengl/gl_resource_manager.h" class OGLStreamBuffer : private NonCopyable { public: - explicit OGLStreamBuffer(GLenum target); - virtual ~OGLStreamBuffer() = default; - -public: - static std::unique_ptr<OGLStreamBuffer> MakeBuffer(bool storage_buffer, GLenum target); - - virtual void Create(size_t size, size_t sync_subdivide) = 0; - virtual void Release() {} + explicit OGLStreamBuffer(GLenum target, GLsizeiptr size, bool prefer_coherent = false); + ~OGLStreamBuffer(); GLuint GetHandle() const; + GLsizeiptr GetSize() const; + + /* + * Allocates a linear chunk of memory in the GPU buffer with at least "size" bytes + * and the optional alignment requirement. + * If the buffer is full, the whole buffer is reallocated which invalidates old chunks. + * The return values are the pointer to the new chunk, the offset within the buffer, + * and the invalidation flag for previous chunks. + * The actual used size must be specified on unmapping the chunk. + */ + std::tuple<u8*, GLintptr, bool> Map(GLsizeiptr size, GLintptr alignment = 0); - virtual std::pair<u8*, GLintptr> Map(size_t size, size_t alignment) = 0; - virtual void Unmap() = 0; + void Unmap(GLsizeiptr size); -protected: +private: OGLBuffer gl_buffer; GLenum gl_target; - size_t buffer_pos = 0; - size_t buffer_size = 0; - size_t buffer_sync_subdivide = 0; - size_t mapped_size = 0; + bool coherent = false; + bool persistent = false; + + GLintptr buffer_pos = 0; + GLsizeiptr buffer_size = 0; + GLintptr mapped_offset = 0; + GLsizeiptr mapped_size = 0; + u8* mapped_ptr = nullptr; }; |