Skip to content

Commit

Permalink
OGL: remove masking from streambuffer
Browse files Browse the repository at this point in the history
We used this to disable pinned memory for index buffer, but as the detection
was reworked completely, it's just unused code.
  • Loading branch information
degasus committed Jan 9, 2014
1 parent eb310cb commit 95aa977
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 47 deletions.
70 changes: 26 additions & 44 deletions Source/Core/VideoBackends/OGL/StreamBuffer.cpp
Expand Up @@ -16,46 +16,40 @@ namespace OGL
static const u32 SYNC_POINTS = 16;
static const u32 ALIGN_PINNED_MEMORY = 4096;

StreamBuffer::StreamBuffer(u32 type, size_t size, StreamType uploadType)
: m_uploadtype(uploadType), m_buffertype(type), m_size(size)
StreamBuffer::StreamBuffer(u32 type, size_t size)
: m_buffertype(type), m_size(size)
{
glGenBuffers(1, &m_buffer);

bool nvidia = !strcmp(g_ogl_config.gl_vendor, "NVIDIA Corporation");

if(m_uploadtype & STREAM_DETECT)
// TODO: move this to InitBackendInfo
if(g_ActiveConfig.bHackedBufferUpload && DriverDetails::HasBug(DriverDetails::BUG_BROKENHACKEDBUFFER))
{
// TODO: move this to InitBackendInfo
if(g_ActiveConfig.bHackedBufferUpload && DriverDetails::HasBug(DriverDetails::BUG_BROKENHACKEDBUFFER))
{
OSD::AddMessage("Vertex Streaming Hack isn't supported by your GPU.", 10000);
g_ActiveConfig.bHackedBufferUpload = false;
g_Config.bHackedBufferUpload = false;
}

if (g_ogl_config.bSupportsGLBufferStorage &&
!(DriverDetails::HasBug(DriverDetails::BUG_BROKENBUFFERSTORAGE) && type == GL_ARRAY_BUFFER) &&
(m_uploadtype & BUFFERSTORAGE))
m_uploadtype = BUFFERSTORAGE;
else if(!g_ogl_config.bSupportsGLBaseVertex && (m_uploadtype & BUFFERSUBDATA)
&& !DriverDetails::HasBug(DriverDetails::BUG_BROKENBUFFERSTREAM))
m_uploadtype = BUFFERSUBDATA;
else if(!g_ogl_config.bSupportsGLBaseVertex && (m_uploadtype & BUFFERDATA))
m_uploadtype = BUFFERDATA;
else if(g_ogl_config.bSupportsGLSync && g_ActiveConfig.bHackedBufferUpload && (m_uploadtype & MAP_AND_RISK))
m_uploadtype = MAP_AND_RISK;
else if(g_ogl_config.bSupportsGLSync && g_ogl_config.bSupportsGLPinnedMemory &&
!(DriverDetails::HasBug(DriverDetails::BUG_BROKENPINNEDMEMORY) && type == GL_ELEMENT_ARRAY_BUFFER) &&
(m_uploadtype & PINNED_MEMORY))
m_uploadtype = PINNED_MEMORY;
else if(nvidia && (m_uploadtype & BUFFERSUBDATA))
m_uploadtype = BUFFERSUBDATA;
else if(g_ogl_config.bSupportsGLSync && (m_uploadtype & MAP_AND_SYNC))
m_uploadtype = MAP_AND_SYNC;
else
m_uploadtype = MAP_AND_ORPHAN;
OSD::AddMessage("Vertex Streaming Hack isn't supported by your GPU.", 10000);
g_ActiveConfig.bHackedBufferUpload = false;
g_Config.bHackedBufferUpload = false;
}

if (g_ogl_config.bSupportsGLBufferStorage &&
!(DriverDetails::HasBug(DriverDetails::BUG_BROKENBUFFERSTORAGE) && type == GL_ARRAY_BUFFER))
m_uploadtype = BUFFERSTORAGE;
else if(!g_ogl_config.bSupportsGLBaseVertex && !DriverDetails::HasBug(DriverDetails::BUG_BROKENBUFFERSTREAM))
m_uploadtype = BUFFERSUBDATA;
else if(!g_ogl_config.bSupportsGLBaseVertex)
m_uploadtype = BUFFERDATA;
else if(g_ogl_config.bSupportsGLSync && g_ActiveConfig.bHackedBufferUpload)
m_uploadtype = MAP_AND_RISK;
else if(g_ogl_config.bSupportsGLSync && g_ogl_config.bSupportsGLPinnedMemory &&
!(DriverDetails::HasBug(DriverDetails::BUG_BROKENPINNEDMEMORY) && type == GL_ELEMENT_ARRAY_BUFFER))
m_uploadtype = PINNED_MEMORY;
else if(nvidia)
m_uploadtype = BUFFERSUBDATA;
else if(g_ogl_config.bSupportsGLSync)
m_uploadtype = MAP_AND_SYNC;
else
m_uploadtype = MAP_AND_ORPHAN;

Init();
}

Expand Down Expand Up @@ -133,9 +127,6 @@ void StreamBuffer::Alloc ( size_t size, u32 stride )
case BUFFERDATA:
m_iterator_aligned = 0;
break;
case STREAM_DETECT:
case DETECT_MASK: // To shutup compiler warnings
break;
}
m_iterator = m_iterator_aligned;
}
Expand Down Expand Up @@ -165,9 +156,6 @@ size_t StreamBuffer::Upload ( u8* data, size_t size )
case BUFFERDATA:
glBufferData(m_buffertype, size, data, GL_STREAM_DRAW);
break;
case STREAM_DETECT:
case DETECT_MASK: // To shutup compiler warnings
break;
}
size_t ret = m_iterator;
m_iterator += size;
Expand Down Expand Up @@ -242,9 +230,6 @@ void StreamBuffer::Init()
case BUFFERDATA:
glBindBuffer(m_buffertype, m_buffer);
break;
case STREAM_DETECT:
case DETECT_MASK: // To shutup compiler warnings
break;
}
}

Expand All @@ -271,9 +256,6 @@ void StreamBuffer::Shutdown()
glBindBuffer(m_buffertype, 0);
glFinish(); // ogl pipeline must be flushed, else this buffer can be in use
break;
case STREAM_DETECT:
case DETECT_MASK: // To shutup compiler warnings
break;
}
}

Expand Down
4 changes: 1 addition & 3 deletions Source/Core/VideoBackends/OGL/StreamBuffer.h
Expand Up @@ -18,8 +18,6 @@
namespace OGL
{
enum StreamType {
DETECT_MASK = 0xFF,
STREAM_DETECT = (1 << 0),
MAP_AND_ORPHAN = (1 << 1),
MAP_AND_SYNC = (1 << 2),
MAP_AND_RISK = (1 << 3),
Expand All @@ -32,7 +30,7 @@ enum StreamType {
class StreamBuffer {

public:
StreamBuffer(u32 type, size_t size, StreamType uploadType = DETECT_MASK);
StreamBuffer(u32 type, size_t size);
~StreamBuffer();

void Alloc(size_t size, u32 stride = 0);
Expand Down

0 comments on commit 95aa977

Please sign in to comment.