diff --git a/Source/Core/VideoBackends/OGL/StreamBuffer.cpp b/Source/Core/VideoBackends/OGL/StreamBuffer.cpp index 57a1cc0036..49a8a0e050 100644 --- a/Source/Core/VideoBackends/OGL/StreamBuffer.cpp +++ b/Source/Core/VideoBackends/OGL/StreamBuffer.cpp @@ -116,14 +116,6 @@ void StreamBuffer::AllocMemory(size_t size) } } -void StreamBuffer::Align(u32 stride) -{ - if (m_iterator && stride) { - m_iterator--; - m_iterator = m_iterator - (m_iterator % stride) + stride; - } -} - /* The usual way to stream data to the gpu. * Described here: https://www.opengl.org/wiki/Buffer_Object_Streaming#Unsynchronized_buffer_mapping * Just do unsync appends until the buffer is full. @@ -142,8 +134,7 @@ public: ~MapAndOrphan() { } - std::pair Map(size_t size, u32 stride) override { - Align(stride); + std::pair Map(size_t size) override { if (m_iterator + size >= m_size) { glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW); m_iterator = 0; @@ -180,8 +171,7 @@ public: DeleteFences(); } - std::pair Map(size_t size, u32 stride) override { - Align(stride); + std::pair Map(size_t size) override { AllocMemory(size); u8* pointer = (u8*)glMapBufferRange(m_buffertype, m_iterator, size, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT); @@ -230,8 +220,7 @@ public: glBindBuffer(m_buffertype, 0); } - std::pair Map(size_t size, u32 stride) override { - Align(stride); + std::pair Map(size_t size) override { AllocMemory(size); return std::make_pair(m_pointer + m_iterator, m_iterator); } @@ -271,8 +260,7 @@ public: m_pointer = nullptr; } - std::pair Map(size_t size, u32 stride) override { - Align(stride); + std::pair Map(size_t size) override { AllocMemory(size); return std::make_pair(m_pointer + m_iterator, m_iterator); } @@ -303,7 +291,7 @@ public: delete [] m_pointer; } - std::pair Map(size_t size, u32 stride) override { + std::pair Map(size_t size) override { return std::make_pair(m_pointer, 0); } @@ -331,7 +319,7 @@ public: delete [] m_pointer; } - std::pair Map(size_t size, u32 stride) override { + std::pair Map(size_t size) override { return std::make_pair(m_pointer, 0); } diff --git a/Source/Core/VideoBackends/OGL/StreamBuffer.h b/Source/Core/VideoBackends/OGL/StreamBuffer.h index 66747eafd9..d9d12fe8f4 100644 --- a/Source/Core/VideoBackends/OGL/StreamBuffer.h +++ b/Source/Core/VideoBackends/OGL/StreamBuffer.h @@ -26,9 +26,19 @@ public: * Mapping invalidates the current buffer content, * so it isn't allowed to access the old content any more. */ - virtual std::pair Map(size_t size, u32 stride = 0) = 0; + virtual std::pair Map(size_t size) = 0; virtual void Unmap(size_t used_size) = 0; + inline std::pair Map(size_t size, u32 stride) + { + u32 padding = m_iterator % stride; + if (padding) + { + m_iterator += stride - padding; + } + return Map(size); + } + const u32 m_buffer; protected: @@ -36,7 +46,6 @@ protected: void CreateFences(); void DeleteFences(); void AllocMemory(size_t size); - void Align(u32 stride); const u32 m_buffertype; const size_t m_size;