Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add the new glBufferData stream buffer type to the streambuffer class…
… which is hugely more efficient on Mali drivers.
  • Loading branch information
Sonicadvance1 committed Jul 27, 2013
1 parent a9ebd7d commit 319e29e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
16 changes: 13 additions & 3 deletions Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.cpp
Expand Up @@ -23,7 +23,9 @@ StreamBuffer::StreamBuffer(u32 type, size_t size, StreamType uploadType)

if(m_uploadtype & STREAM_DETECT)
{
if(!g_ogl_config.bSupportsGLBaseVertex && (m_uploadtype & BUFFERSUBDATA))
if(!g_ogl_config.bSupportsGLBaseVertex && (m_uploadtype & BUFFERDATA))
m_uploadtype = BUFFERDATA;
else if(!g_ogl_config.bSupportsGLBaseVertex && (m_uploadtype & BUFFERSUBDATA))
m_uploadtype = BUFFERSUBDATA;
else if(g_ogl_config.bSupportsGLSync && g_Config.bHackedBufferUpload && (m_uploadtype & MAP_AND_RISK))
m_uploadtype = MAP_AND_RISK;
Expand Down Expand Up @@ -109,6 +111,7 @@ void StreamBuffer::Alloc ( size_t size, u32 stride )
}
break;
case BUFFERSUBDATA:
case BUFFERDATA:
m_iterator_aligned = 0;
break;
case STREAM_DETECT:
Expand Down Expand Up @@ -139,6 +142,9 @@ size_t StreamBuffer::Upload ( u8* data, size_t size )
case BUFFERSUBDATA:
glBufferSubData(m_buffertype, m_iterator, size, data);
break;
case BUFFERDATA:
glBufferData(m_buffertype, size, data, GL_STREAM_DRAW);
break;
case STREAM_DETECT:
case DETECT_MASK: // Just to shutup warnings
break;
Expand Down Expand Up @@ -188,11 +194,14 @@ void StreamBuffer::Init()
case MAP_AND_RISK:
glBindBuffer(m_buffertype, m_buffer);
glBufferData(m_buffertype, m_size, NULL, GL_STREAM_DRAW);
pointer = (u8*)glMapBuffer(m_buffertype, GL_WRITE_ONLY);
//pointer = (u8*)glMapBuffer(m_buffertype, GL_WRITE_ONLY);
glUnmapBuffer(m_buffertype);
if(!pointer)
ERROR_LOG(VIDEO, "Buffer allocation failed");

break;
case BUFFERDATA:
glBindBuffer(m_buffertype, m_buffer);
break;
case STREAM_DETECT:
case DETECT_MASK: // Just to shutup warnings
break;
Expand All @@ -211,6 +220,7 @@ void StreamBuffer::Shutdown()
case MAP_AND_RISK:
case MAP_AND_ORPHAN:
case BUFFERSUBDATA:
case BUFFERDATA:
break;
case PINNED_MEMORY:
for(u32 i=0; i<SYNC_POINTS; i++)
Expand Down
5 changes: 3 additions & 2 deletions Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.h
Expand Up @@ -18,13 +18,14 @@
namespace OGL
{
enum StreamType {
DETECT_MASK = 0x3F,
DETECT_MASK = 0x7F,
STREAM_DETECT = (1 << 0),
MAP_AND_ORPHAN = (1 << 1),
MAP_AND_SYNC = (1 << 2),
MAP_AND_RISK = (1 << 3),
PINNED_MEMORY = (1 << 4),
BUFFERSUBDATA = (1 << 5)
BUFFERSUBDATA = (1 << 5),
BUFFERDATA = (1 << 6)
};

class StreamBuffer {
Expand Down

0 comments on commit 319e29e

Please sign in to comment.