Add the new glBufferData stream buffer type to the streambuffer class which is hugely more efficient on Mali drivers.

This commit is contained in:
Ryan Houdek 2013-07-27 00:40:16 +00:00
parent a9ebd7d3e5
commit 319e29e7d0
2 changed files with 16 additions and 5 deletions

View File

@ -23,7 +23,9 @@ StreamBuffer::StreamBuffer(u32 type, size_t size, StreamType uploadType)
if(m_uploadtype & STREAM_DETECT) 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; m_uploadtype = BUFFERSUBDATA;
else if(g_ogl_config.bSupportsGLSync && g_Config.bHackedBufferUpload && (m_uploadtype & MAP_AND_RISK)) else if(g_ogl_config.bSupportsGLSync && g_Config.bHackedBufferUpload && (m_uploadtype & MAP_AND_RISK))
m_uploadtype = MAP_AND_RISK; m_uploadtype = MAP_AND_RISK;
@ -109,6 +111,7 @@ void StreamBuffer::Alloc ( size_t size, u32 stride )
} }
break; break;
case BUFFERSUBDATA: case BUFFERSUBDATA:
case BUFFERDATA:
m_iterator_aligned = 0; m_iterator_aligned = 0;
break; break;
case STREAM_DETECT: case STREAM_DETECT:
@ -139,6 +142,9 @@ size_t StreamBuffer::Upload ( u8* data, size_t size )
case BUFFERSUBDATA: case BUFFERSUBDATA:
glBufferSubData(m_buffertype, m_iterator, size, data); glBufferSubData(m_buffertype, m_iterator, size, data);
break; break;
case BUFFERDATA:
glBufferData(m_buffertype, size, data, GL_STREAM_DRAW);
break;
case STREAM_DETECT: case STREAM_DETECT:
case DETECT_MASK: // Just to shutup warnings case DETECT_MASK: // Just to shutup warnings
break; break;
@ -188,11 +194,14 @@ void StreamBuffer::Init()
case MAP_AND_RISK: case MAP_AND_RISK:
glBindBuffer(m_buffertype, m_buffer); glBindBuffer(m_buffertype, m_buffer);
glBufferData(m_buffertype, m_size, NULL, GL_STREAM_DRAW); 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); glUnmapBuffer(m_buffertype);
if(!pointer) if(!pointer)
ERROR_LOG(VIDEO, "Buffer allocation failed"); ERROR_LOG(VIDEO, "Buffer allocation failed");
break;
case BUFFERDATA:
glBindBuffer(m_buffertype, m_buffer);
break;
case STREAM_DETECT: case STREAM_DETECT:
case DETECT_MASK: // Just to shutup warnings case DETECT_MASK: // Just to shutup warnings
break; break;
@ -211,6 +220,7 @@ void StreamBuffer::Shutdown()
case MAP_AND_RISK: case MAP_AND_RISK:
case MAP_AND_ORPHAN: case MAP_AND_ORPHAN:
case BUFFERSUBDATA: case BUFFERSUBDATA:
case BUFFERDATA:
break; break;
case PINNED_MEMORY: case PINNED_MEMORY:
for(u32 i=0; i<SYNC_POINTS; i++) for(u32 i=0; i<SYNC_POINTS; i++)

View File

@ -18,13 +18,14 @@
namespace OGL namespace OGL
{ {
enum StreamType { enum StreamType {
DETECT_MASK = 0x3F, DETECT_MASK = 0x7F,
STREAM_DETECT = (1 << 0), STREAM_DETECT = (1 << 0),
MAP_AND_ORPHAN = (1 << 1), MAP_AND_ORPHAN = (1 << 1),
MAP_AND_SYNC = (1 << 2), MAP_AND_SYNC = (1 << 2),
MAP_AND_RISK = (1 << 3), MAP_AND_RISK = (1 << 3),
PINNED_MEMORY = (1 << 4), PINNED_MEMORY = (1 << 4),
BUFFERSUBDATA = (1 << 5) BUFFERSUBDATA = (1 << 5),
BUFFERDATA = (1 << 6)
}; };
class StreamBuffer { class StreamBuffer {