diff --git a/Source/Core/VideoBackends/OGL/StreamBuffer.cpp b/Source/Core/VideoBackends/OGL/StreamBuffer.cpp index 49a8a0e050..5723283b72 100644 --- a/Source/Core/VideoBackends/OGL/StreamBuffer.cpp +++ b/Source/Core/VideoBackends/OGL/StreamBuffer.cpp @@ -22,7 +22,7 @@ static u32 genBuffer() return id; } -StreamBuffer::StreamBuffer(u32 type, size_t size) +StreamBuffer::StreamBuffer(u32 type, u32 size) : m_buffer(genBuffer()), m_buffertype(type), m_size(ROUND_UP_POW2(size)), m_bit_per_slot(Log2(ROUND_UP_POW2(size) / SYNC_POINTS)) { m_iterator = 0; @@ -77,7 +77,7 @@ void StreamBuffer::DeleteFences() glDeleteSync(fences[i]); } } -void StreamBuffer::AllocMemory(size_t size) +void StreamBuffer::AllocMemory(u32 size) { // insert waiting slots for used memory for (int i = SLOT(m_used_iterator); i < SLOT(m_iterator); i++) @@ -126,7 +126,7 @@ void StreamBuffer::AllocMemory(size_t size) class MapAndOrphan : public StreamBuffer { public: - MapAndOrphan(u32 type, size_t size) : StreamBuffer(type, size) { + MapAndOrphan(u32 type, u32 size) : StreamBuffer(type, size) { glBindBuffer(m_buffertype, m_buffer); glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW); } @@ -134,7 +134,7 @@ public: ~MapAndOrphan() { } - std::pair Map(size_t size) override { + std::pair Map(u32 size) override { if (m_iterator + size >= m_size) { glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW); m_iterator = 0; @@ -144,7 +144,7 @@ public: return std::make_pair(pointer, m_iterator); } - void Unmap(size_t used_size) override { + void Unmap(u32 used_size) override { glFlushMappedBufferRange(m_buffertype, 0, used_size); glUnmapBuffer(m_buffertype); m_iterator += used_size; @@ -161,7 +161,7 @@ public: class MapAndSync : public StreamBuffer { public: - MapAndSync(u32 type, size_t size) : StreamBuffer(type, size) { + MapAndSync(u32 type, u32 size) : StreamBuffer(type, size) { CreateFences(); glBindBuffer(m_buffertype, m_buffer); glBufferData(m_buffertype, m_size, nullptr, GL_STREAM_DRAW); @@ -171,14 +171,14 @@ public: DeleteFences(); } - std::pair Map(size_t size) override { + std::pair Map(u32 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); return std::make_pair(pointer, m_iterator); } - void Unmap(size_t used_size) override { + void Unmap(u32 used_size) override { glFlushMappedBufferRange(m_buffertype, 0, used_size); glUnmapBuffer(m_buffertype); m_iterator += used_size; @@ -201,7 +201,7 @@ public: class BufferStorage : public StreamBuffer { public: - BufferStorage(u32 type, size_t size) : StreamBuffer(type, size) { + BufferStorage(u32 type, u32 size) : StreamBuffer(type, size) { CreateFences(); glBindBuffer(m_buffertype, m_buffer); @@ -220,12 +220,12 @@ public: glBindBuffer(m_buffertype, 0); } - std::pair Map(size_t size) override { + std::pair Map(u32 size) override { AllocMemory(size); return std::make_pair(m_pointer + m_iterator, m_iterator); } - void Unmap(size_t used_size) override { + void Unmap(u32 used_size) override { glFlushMappedBufferRange(m_buffertype, m_iterator, used_size); m_iterator += used_size; } @@ -243,7 +243,7 @@ public: class PinnedMemory : public StreamBuffer { public: - PinnedMemory(u32 type, size_t size) : StreamBuffer(type, size) { + PinnedMemory(u32 type, u32 size) : StreamBuffer(type, size) { CreateFences(); m_pointer = (u8*)AllocateAlignedMemory(ROUND_UP(m_size,ALIGN_PINNED_MEMORY), ALIGN_PINNED_MEMORY ); glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_buffer); @@ -260,12 +260,12 @@ public: m_pointer = nullptr; } - std::pair Map(size_t size) override { + std::pair Map(u32 size) override { AllocMemory(size); return std::make_pair(m_pointer + m_iterator, m_iterator); } - void Unmap(size_t used_size) override { + void Unmap(u32 used_size) override { m_iterator += used_size; } @@ -281,7 +281,7 @@ public: class BufferSubData : public StreamBuffer { public: - BufferSubData(u32 type, size_t size) : StreamBuffer(type, size) { + BufferSubData(u32 type, u32 size) : StreamBuffer(type, size) { glBindBuffer(m_buffertype, m_buffer); glBufferData(m_buffertype, size, nullptr, GL_STATIC_DRAW); m_pointer = new u8[m_size]; @@ -291,11 +291,11 @@ public: delete [] m_pointer; } - std::pair Map(size_t size) override { + std::pair Map(u32 size) override { return std::make_pair(m_pointer, 0); } - void Unmap(size_t used_size) override { + void Unmap(u32 used_size) override { glBufferSubData(m_buffertype, 0, used_size, m_pointer); } @@ -310,7 +310,7 @@ public: class BufferData : public StreamBuffer { public: - BufferData(u32 type, size_t size) : StreamBuffer(type, size) { + BufferData(u32 type, u32 size) : StreamBuffer(type, size) { glBindBuffer(m_buffertype, m_buffer); m_pointer = new u8[m_size]; } @@ -319,11 +319,11 @@ public: delete [] m_pointer; } - std::pair Map(size_t size) override { + std::pair Map(u32 size) override { return std::make_pair(m_pointer, 0); } - void Unmap(size_t used_size) override { + void Unmap(u32 used_size) override { glBufferData(m_buffertype, used_size, m_pointer, GL_STREAM_DRAW); } @@ -331,7 +331,7 @@ public: }; // choose best streaming library based on the supported extensions and known issues -StreamBuffer* StreamBuffer::Create(u32 type, size_t size) +StreamBuffer* StreamBuffer::Create(u32 type, u32 size) { // without basevertex support, only streaming methods whith uploads everything to zero works fine: if (!g_ogl_config.bSupportsGLBaseVertex) diff --git a/Source/Core/VideoBackends/OGL/StreamBuffer.h b/Source/Core/VideoBackends/OGL/StreamBuffer.h index d9d12fe8f4..928af0bbaf 100644 --- a/Source/Core/VideoBackends/OGL/StreamBuffer.h +++ b/Source/Core/VideoBackends/OGL/StreamBuffer.h @@ -15,7 +15,7 @@ namespace OGL class StreamBuffer { public: - static StreamBuffer* Create(u32 type, size_t size); + static StreamBuffer* Create(u32 type, u32 size); virtual ~StreamBuffer(); /* This mapping function will return a pair of: @@ -26,10 +26,10 @@ 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) = 0; - virtual void Unmap(size_t used_size) = 0; + virtual std::pair Map(u32 size) = 0; + virtual void Unmap(u32 used_size) = 0; - inline std::pair Map(size_t size, u32 stride) + inline std::pair Map(u32 size, u32 stride) { u32 padding = m_iterator % stride; if (padding) @@ -42,21 +42,21 @@ public: const u32 m_buffer; protected: - StreamBuffer(u32 type, size_t size); + StreamBuffer(u32 type, u32 size); void CreateFences(); void DeleteFences(); - void AllocMemory(size_t size); + void AllocMemory(u32 size); const u32 m_buffertype; - const size_t m_size; + const u32 m_size; - size_t m_iterator; - size_t m_used_iterator; - size_t m_free_iterator; + u32 m_iterator; + u32 m_used_iterator; + u32 m_free_iterator; private: static const int SYNC_POINTS = 16; - inline int SLOT(size_t x) const { return x >> m_bit_per_slot; } + inline int SLOT(u32 x) const { return x >> m_bit_per_slot; } const int m_bit_per_slot; GLsync fences[SYNC_POINTS];