glMapBuffer was slow, go back to glBufferSubData, single combined ps/vs ubo now
This commit is contained in:
parent
a613012d08
commit
c908e1173d
|
@ -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<u64, u64> ProgramShaderCache::CurrentShaderProgram;
|
||||
|
@ -141,40 +140,16 @@ namespace OGL
|
|||
CurrentProgram = entry.program.glprogid;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::MapBuffer()
|
||||
{
|
||||
if (!s_ps_vs_mapped_data)
|
||||
{
|
||||
s_ps_vs_mapped_data = reinterpret_cast<float*>(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);
|
||||
}
|
||||
|
||||
void ProgramShaderCache::FlushConstants()
|
||||
{
|
||||
if (s_ps_vs_mapped_data)
|
||||
{
|
||||
if (!glUnmapBuffer(GL_UNIFORM_BUFFER))
|
||||
PanicAlert("glUnmapBuffer");
|
||||
s_ps_vs_mapped_data = NULL;
|
||||
}
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, s_vs_data_offset + offset * sizeof(float) * 4,
|
||||
count * sizeof(float) * 4, f);
|
||||
}
|
||||
|
||||
GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; }
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,11 +96,8 @@ class ProgramShaderCache
|
|||
static std::pair<u64, u64> 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);
|
||||
static GLint GetAttr(int num);
|
||||
|
@ -110,8 +107,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);
|
||||
|
||||
|
|
|
@ -215,9 +215,6 @@ void VertexManager::vFlush()
|
|||
VertexShaderManager::SetConstants();
|
||||
PixelShaderManager::SetConstants();
|
||||
|
||||
if(g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
||||
ProgramShaderCache::FlushConstants();
|
||||
|
||||
// setup the pointers
|
||||
if (g_nativeVertexFmt)
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
|
|
Loading…
Reference in New Issue