From fa15d7fd2602a31df7a75aa8e6bf3736b276f1f5 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 28 May 2016 18:53:17 +0200 Subject: [PATCH] gsdx ogl: generic code to cache uniform buffer It will allow to skip a buffer transfer if the new content is the same --- plugins/GSdx/GSUniformBufferOGL.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/GSUniformBufferOGL.h b/plugins/GSdx/GSUniformBufferOGL.h index 7237f96d5e..ce9ef2cccf 100644 --- a/plugins/GSdx/GSUniformBufferOGL.h +++ b/plugins/GSdx/GSUniformBufferOGL.h @@ -32,6 +32,7 @@ class GSUniformBufferOGL { GLuint buffer; // data object GLuint index; // GLSL slot uint32 size; // size of the data + uint8* cache; // content of the previous upload public: GSUniformBufferOGL(GLuint index, uint32 size) : index(index) @@ -41,6 +42,8 @@ public: bind(); allocate(); attach(); + cache = (uint8*)_aligned_malloc(size, 32); + memset(cache, 0, size); } void bind() @@ -76,8 +79,18 @@ public: #endif } - ~GSUniformBufferOGL() { + void cache_upload(const void* src) + { + if (memcmp(cache, src, size) != 0) { + memcpy(cache, src, size); + upload(src); + } + } + + ~GSUniformBufferOGL() + { glDeleteBuffers(1, &buffer); + _aligned_free(cache); } };