diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index bff25a5a65..10c15aae36 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -24,7 +24,6 @@ namespace OGL GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0; ProgramShaderCache::PCache ProgramShaderCache::pshaders; GLuint ProgramShaderCache::s_ps_vs_ubo; - float* ProgramShaderCache::s_ps_vs_mapped_data; GLintptr ProgramShaderCache::s_vs_data_offset; std::pair ProgramShaderCache::CurrentShaderProgram; @@ -141,42 +140,18 @@ namespace OGL CurrentProgram = entry.program.glprogid; } - void ProgramShaderCache::MapBuffer() - { - if (!s_ps_vs_mapped_data) - { - s_ps_vs_mapped_data = reinterpret_cast(glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY)); - - if (!s_ps_vs_mapped_data) - PanicAlert("glMapBuffer"); - } - } - void ProgramShaderCache::SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count) { - MapBuffer(); - - std::copy(f, f + count * 4, s_ps_vs_mapped_data + offset * 4); + glBufferSubData(GL_UNIFORM_BUFFER, offset * sizeof(float) * 4, + count * sizeof(float) * 4, f); } void ProgramShaderCache::SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count) { - MapBuffer(); - - // TODO: division = hax - std::copy(f, f + count * 4, s_ps_vs_mapped_data + (s_vs_data_offset / sizeof(float)) + offset * 4); + glBufferSubData(GL_UNIFORM_BUFFER, s_vs_data_offset + offset * sizeof(float) * 4, + count * sizeof(float) * 4, f); } - - void ProgramShaderCache::FlushConstants() - { - if (s_ps_vs_mapped_data) - { - if (!glUnmapBuffer(GL_UNIFORM_BUFFER)) - PanicAlert("glUnmapBuffer"); - s_ps_vs_mapped_data = NULL; - } - } - + GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; } GLint ProgramShaderCache::GetAttr(int num) @@ -224,10 +199,8 @@ namespace OGL pshaders.clear(); glBindBuffer(GL_UNIFORM_BUFFER, 0); - // "A buffer object's mapped data store is automatically unmapped when the buffer object is deleted" glDeleteBuffers(1, &s_ps_vs_ubo); s_ps_vs_ubo = 0; - s_ps_vs_mapped_data = NULL; } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h index 20a33f184b..26d5735ce6 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h @@ -96,10 +96,7 @@ class ProgramShaderCache static std::pair CurrentShaderProgram; static GLuint s_ps_vs_ubo; - static float* s_ps_vs_mapped_data; static GLintptr s_vs_data_offset; - - static void MapBuffer(); public: static PROGRAMSHADER GetShaderProgram(void); @@ -109,8 +106,6 @@ public: static void SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count); static void SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count); - - static void FlushConstants(); static void Init(void); static void Shutdown(void); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index 7d7bc651a0..fff8263569 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -214,9 +214,6 @@ void VertexManager::vFlush() // set global constants VertexShaderManager::SetConstants(); PixelShaderManager::SetConstants(); - - if(g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) - ProgramShaderCache::FlushConstants(); // setup the pointers if (g_nativeVertexFmt)