gsdx ogl: generic code to cache uniform buffer

It will allow to skip a buffer transfer if the new content is the same
This commit is contained in:
Gregory Hainaut 2016-05-28 18:53:17 +02:00
parent be7af60ab5
commit fa15d7fd26
1 changed files with 14 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class GSUniformBufferOGL {
GLuint buffer; // data object GLuint buffer; // data object
GLuint index; // GLSL slot GLuint index; // GLSL slot
uint32 size; // size of the data uint32 size; // size of the data
uint8* cache; // content of the previous upload
public: public:
GSUniformBufferOGL(GLuint index, uint32 size) : index(index) GSUniformBufferOGL(GLuint index, uint32 size) : index(index)
@ -41,6 +42,8 @@ public:
bind(); bind();
allocate(); allocate();
attach(); attach();
cache = (uint8*)_aligned_malloc(size, 32);
memset(cache, 0, size);
} }
void bind() void bind()
@ -76,8 +79,18 @@ public:
#endif #endif
} }
~GSUniformBufferOGL() { void cache_upload(const void* src)
{
if (memcmp(cache, src, size) != 0) {
memcpy(cache, src, size);
upload(src);
}
}
~GSUniformBufferOGL()
{
glDeleteBuffers(1, &buffer); glDeleteBuffers(1, &buffer);
_aligned_free(cache);
} }
}; };