mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 00:05:34 +01:00
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;
|
GLuint ProgramShaderCache::CurrentFShader = 0, ProgramShaderCache::CurrentVShader = 0, ProgramShaderCache::CurrentProgram = 0;
|
||||||
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
||||||
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
GLuint ProgramShaderCache::s_ps_vs_ubo;
|
||||||
float* ProgramShaderCache::s_ps_vs_mapped_data;
|
|
||||||
GLintptr ProgramShaderCache::s_vs_data_offset;
|
GLintptr ProgramShaderCache::s_vs_data_offset;
|
||||||
|
|
||||||
std::pair<u64, u64> ProgramShaderCache::CurrentShaderProgram;
|
std::pair<u64, u64> ProgramShaderCache::CurrentShaderProgram;
|
||||||
@ -141,42 +140,18 @@ namespace OGL
|
|||||||
CurrentProgram = entry.program.glprogid;
|
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)
|
void ProgramShaderCache::SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count)
|
||||||
{
|
{
|
||||||
MapBuffer();
|
glBufferSubData(GL_UNIFORM_BUFFER, offset * sizeof(float) * 4,
|
||||||
|
count * sizeof(float) * 4, f);
|
||||||
std::copy(f, f + count * 4, s_ps_vs_mapped_data + offset * 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramShaderCache::SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count)
|
void ProgramShaderCache::SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count)
|
||||||
{
|
{
|
||||||
MapBuffer();
|
glBufferSubData(GL_UNIFORM_BUFFER, s_vs_data_offset + offset * sizeof(float) * 4,
|
||||||
|
count * sizeof(float) * 4, f);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; }
|
GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; }
|
||||||
|
|
||||||
GLint ProgramShaderCache::GetAttr(int num)
|
GLint ProgramShaderCache::GetAttr(int num)
|
||||||
@ -224,10 +199,8 @@ namespace OGL
|
|||||||
pshaders.clear();
|
pshaders.clear();
|
||||||
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
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);
|
glDeleteBuffers(1, &s_ps_vs_ubo);
|
||||||
s_ps_vs_ubo = 0;
|
s_ps_vs_ubo = 0;
|
||||||
s_ps_vs_mapped_data = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,10 +96,7 @@ class ProgramShaderCache
|
|||||||
static std::pair<u64, u64> CurrentShaderProgram;
|
static std::pair<u64, u64> CurrentShaderProgram;
|
||||||
|
|
||||||
static GLuint s_ps_vs_ubo;
|
static GLuint s_ps_vs_ubo;
|
||||||
static float* s_ps_vs_mapped_data;
|
|
||||||
static GLintptr s_vs_data_offset;
|
static GLintptr s_vs_data_offset;
|
||||||
|
|
||||||
static void MapBuffer();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PROGRAMSHADER GetShaderProgram(void);
|
static PROGRAMSHADER GetShaderProgram(void);
|
||||||
@ -109,8 +106,6 @@ public:
|
|||||||
|
|
||||||
static void SetMultiPSConstant4fv(unsigned int offset, const float *f, unsigned int count);
|
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 SetMultiVSConstant4fv(unsigned int offset, const float *f, unsigned int count);
|
||||||
|
|
||||||
static void FlushConstants();
|
|
||||||
|
|
||||||
static void Init(void);
|
static void Init(void);
|
||||||
static void Shutdown(void);
|
static void Shutdown(void);
|
||||||
|
@ -214,9 +214,6 @@ void VertexManager::vFlush()
|
|||||||
// set global constants
|
// set global constants
|
||||||
VertexShaderManager::SetConstants();
|
VertexShaderManager::SetConstants();
|
||||||
PixelShaderManager::SetConstants();
|
PixelShaderManager::SetConstants();
|
||||||
|
|
||||||
if(g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
|
|
||||||
ProgramShaderCache::FlushConstants();
|
|
||||||
|
|
||||||
// setup the pointers
|
// setup the pointers
|
||||||
if (g_nativeVertexFmt)
|
if (g_nativeVertexFmt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user