From fd06342a97e6bedfdedac390e89c88454983c815 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 28 Jan 2013 13:03:31 +0100 Subject: [PATCH] set hint GL_STREAM_READ it's wrong, but so we are guaranteed to get pinned memory. it's slower for rendering, but faster for mapping. --- .../Plugin_VideoOGL/Src/ProgramShaderCache.cpp | 4 ++-- Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index 73a9d5b105..974d839900 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -197,7 +197,7 @@ void ProgramShaderCache::UploadConstants() { if(s_ubo_dirty) { if(s_ubo_iterator + s_ubo_buffer_size >= UBO_LENGTH) { - glBufferData(GL_UNIFORM_BUFFER, UBO_LENGTH, NULL, GL_STREAM_DRAW); + glBufferData(GL_UNIFORM_BUFFER, UBO_LENGTH, NULL, GL_STREAM_READ); s_ubo_iterator = 0; } void *ubo = glMapBufferRange(GL_UNIFORM_BUFFER, s_ubo_iterator, s_ubo_buffer_size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_RANGE_BIT); @@ -242,7 +242,7 @@ void ProgramShaderCache::Init(void) // Then once more to get bytes glGenBuffers(1, &s_ps_vs_ubo); glBindBuffer(GL_UNIFORM_BUFFER, s_ps_vs_ubo); - glBufferData(GL_UNIFORM_BUFFER, UBO_LENGTH, NULL, GL_STREAM_DRAW); + glBufferData(GL_UNIFORM_BUFFER, UBO_LENGTH, NULL, GL_STREAM_READ); s_ubo_iterator = 0; s_ubo_buffer = new float[s_ubo_buffer_size/sizeof(float)]; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index ce3996aa50..6de135d5bd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -92,11 +92,11 @@ void VertexManager::CreateDeviceObjects() GL_REPORT_ERROR(); glBindBuffer(GL_ARRAY_BUFFER, m_vertex_buffers ); GL_REPORT_ERROR(); - glBufferData(GL_ARRAY_BUFFER, m_vertex_buffer_size, NULL, GL_STREAM_DRAW ); + glBufferData(GL_ARRAY_BUFFER, m_vertex_buffer_size, NULL, GL_STREAM_READ ); GL_REPORT_ERROR(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_index_buffers ); GL_REPORT_ERROR(); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer_size, NULL, GL_STREAM_DRAW ); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer_size, NULL, GL_STREAM_READ ); GL_REPORT_ERROR(); m_index_buffer_cursor = 0; m_vertex_buffer_cursor = 0; @@ -134,11 +134,11 @@ void VertexManager::PrepareDrawBuffers(u32 stride) { m_vertex_buffer_cursor = 0; m_index_buffer_cursor = 0; - glBufferData(GL_ARRAY_BUFFER, m_vertex_buffer_size, NULL, GL_STREAM_DRAW); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer_size, NULL, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, m_vertex_buffer_size, NULL, GL_STREAM_READ); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer_size, NULL, GL_STREAM_READ); } - pVertices = (u8*)glMapBufferRange(GL_ARRAY_BUFFER, m_vertex_buffer_cursor, vertex_data_size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT); + pVertices = (u8*)glMapBufferRange(GL_ARRAY_BUFFER, m_vertex_buffer_cursor, vertex_data_size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_RANGE_BIT); if(pVertices) { memcpy(pVertices, LocalVBuffer, vertex_data_size); @@ -149,7 +149,7 @@ void VertexManager::PrepareDrawBuffers(u32 stride) glBufferSubData(GL_ARRAY_BUFFER, m_vertex_buffer_cursor, vertex_data_size, LocalVBuffer); } - pIndices = (u16*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer_cursor , index_data_size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT); + pIndices = (u16*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, m_index_buffer_cursor , index_data_size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_RANGE_BIT); if(pIndices) { if(triangle_index_size)