From ff61dc384095680dcd0182b25003de111bcf3373 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 23 Mar 2013 15:37:01 -0500 Subject: [PATCH] Switch to using bitfields in the streambuffer class so we can exclude buggy streambuffer types. This disables pinned memory on ATI for GL_ELEMENT_ARRAY_BUFFER because it seems to be buggy. This fixes ATI for me. --- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 9 --------- .../Plugins/Plugin_VideoOGL/Src/StreamBuffer.cpp | 16 ++++++++++------ .../Plugins/Plugin_VideoOGL/Src/StreamBuffer.h | 15 ++++++++------- .../Plugin_VideoOGL/Src/VertexManager.cpp | 2 +- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 5267118be2..04352dc0cb 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -287,15 +287,6 @@ Renderer::Renderer() ERROR_LOG(VIDEO, "buggy driver detected. Disable UBO"); } -#ifndef _WIN32 - if(g_Config.backend_info.bSupportsGLPinnedMemory) { - // some fglrx versions have a broken pinned memory implementation, so disable it on non-windows plattforms. - // everywhere else it isn't supported at all :-( - g_Config.backend_info.bSupportsGLPinnedMemory = false; - ERROR_LOG(VIDEO, "some fglrx versions have broken pinned memory support, so it's disabled for fglrx"); - } -#endif - UpdateActiveConfig(); OSD::AddMessage(StringFromFormat("Missing Extensions: %s%s%s%s%s%s", g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? "" : "DualSourceBlend ", diff --git a/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.cpp b/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.cpp index 843a126637..2d64f3a591 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.cpp @@ -33,17 +33,17 @@ StreamBuffer::StreamBuffer(u32 type, size_t size, StreamType uploadType) bool nvidia = !strcmp((const char*)glGetString(GL_VENDOR), "NVIDIA Corporation"); - if(m_uploadtype == STREAM_DETECT) + if(m_uploadtype & STREAM_DETECT) { - if(!g_Config.backend_info.bSupportsGLBaseVertex) + if(!g_Config.backend_info.bSupportsGLBaseVertex && (m_uploadtype & BUFFERSUBDATA)) m_uploadtype = BUFFERSUBDATA; - else if(g_Config.backend_info.bSupportsGLSync && g_Config.bHackedBufferUpload) + else if(g_Config.backend_info.bSupportsGLSync && g_Config.bHackedBufferUpload && (m_uploadtype & MAP_AND_RISK)) m_uploadtype = MAP_AND_RISK; - else if(g_Config.backend_info.bSupportsGLSync && g_Config.backend_info.bSupportsGLPinnedMemory) + else if(g_Config.backend_info.bSupportsGLSync && g_Config.backend_info.bSupportsGLPinnedMemory && (m_uploadtype & PINNED_MEMORY)) m_uploadtype = PINNED_MEMORY; - else if(nvidia) + else if(nvidia && (m_uploadtype & BUFFERSUBDATA)) m_uploadtype = BUFFERSUBDATA; - else if(g_Config.backend_info.bSupportsGLSync) + else if(g_Config.backend_info.bSupportsGLSync && (m_uploadtype & MAP_AND_SYNC)) m_uploadtype = MAP_AND_SYNC; else m_uploadtype = MAP_AND_ORPHAN; @@ -124,6 +124,7 @@ void StreamBuffer::Alloc ( size_t size, u32 stride ) m_iterator_aligned = 0; break; case STREAM_DETECT: + case DETECT_MASK: // Just to shutup warnings break; } m_iterator = m_iterator_aligned; @@ -151,6 +152,7 @@ size_t StreamBuffer::Upload ( u8* data, size_t size ) glBufferSubData(m_buffertype, m_iterator, size, data); break; case STREAM_DETECT: + case DETECT_MASK: // Just to shutup warnings break; } size_t ret = m_iterator; @@ -204,6 +206,7 @@ void StreamBuffer::Init() ERROR_LOG(VIDEO, "buffer allocation failed"); case STREAM_DETECT: + case DETECT_MASK: // Just to shutup warnings break; } } @@ -230,6 +233,7 @@ void StreamBuffer::Shutdown() FreeAlignedMemory(pointer); break; case STREAM_DETECT: + case DETECT_MASK: // Just to shutup warnings break; } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.h b/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.h index 8559b58aaa..fa3fd539ea 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/StreamBuffer.h @@ -32,18 +32,19 @@ namespace OGL { enum StreamType { - STREAM_DETECT, - MAP_AND_ORPHAN, - MAP_AND_SYNC, - MAP_AND_RISK, - PINNED_MEMORY, - BUFFERSUBDATA + DETECT_MASK = 0x1F, + 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) }; class StreamBuffer { public: - StreamBuffer(u32 type, size_t size, StreamType uploadType = STREAM_DETECT); + StreamBuffer(u32 type, size_t size, StreamType uploadType = DETECT_MASK); ~StreamBuffer(); void Alloc(size_t size, u32 stride = 0); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index f966c4e069..d289dd1e75 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -72,7 +72,7 @@ void VertexManager::CreateDeviceObjects() { s_vertexBuffer = new StreamBuffer(GL_ARRAY_BUFFER, MAX_VBUFFER_SIZE); m_vertex_buffers = s_vertexBuffer->getBuffer(); - s_indexBuffer = new StreamBuffer(GL_ELEMENT_ARRAY_BUFFER, MAX_IBUFFER_SIZE); + s_indexBuffer = new StreamBuffer(GL_ELEMENT_ARRAY_BUFFER, MAX_IBUFFER_SIZE, (StreamType)(DETECT_MASK & ~PINNED_MEMORY)); m_index_buffers = s_indexBuffer->getBuffer(); m_CurrentVertexFmt = NULL;