diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-01 03:58:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-01 13:03:52 +0300 |
commit | a6185e4fa547223b976500f967b099eb9b837ee8 (patch) | |
tree | 13d11f84fe5cd522cbd6f422c818aac70b22fe37 /intern/opencolorio | |
parent | 53a806f6dffb2a778e383a82c3d0cdb6e9d9d552 (diff) |
OCIO: Make GLSL implementation use GPUUniformBuf to avoid debug errors
Now that we use internal state info, we require drawing that uses the
GPU api to use it throughout the whole pipeline. This is in order to
track the GL state and do our own error checking.
Diffstat (limited to 'intern/opencolorio')
-rw-r--r-- | intern/opencolorio/ocio_impl_glsl.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc index f766f57732a..ae134cc0725 100644 --- a/intern/opencolorio/ocio_impl_glsl.cc +++ b/intern/opencolorio/ocio_impl_glsl.cc @@ -47,6 +47,7 @@ #include "GPU_immediate.h" #include "GPU_shader.h" +#include "GPU_uniform_buffer.h" using namespace OCIO_NAMESPACE; @@ -119,8 +120,8 @@ struct OCIO_GLSLLut3d { struct OCIO_GLSLCurveMappping { /** Cache IDs */ size_t cacheId; - /** OpenGL Uniform Buffer handle. 0 if not allocated. */ - GLuint buffer; + /** GPU Uniform Buffer handle. 0 if not allocated. */ + GPUUniformBuf *buffer; /** OpenGL Texture handles. 0 if not allocated. */ GLuint texture; /** Error checking. */ @@ -370,10 +371,7 @@ static void ensureGLSLCurveMapping(OCIO_GLSLCurveMappping **curvemap_ptr, allocateCurveMappingTexture(curvemap, curve_mapping_settings); /* Uniform buffer object. */ - glGenBuffers(1, &curvemap->buffer); - glBindBuffer(GL_UNIFORM_BUFFER, curvemap->buffer); - glBufferData(GL_UNIFORM_BUFFER, sizeof(OCIO_GLSLCurveMappingParameters), 0, GL_DYNAMIC_DRAW); - glBindBuffer(GL_UNIFORM_BUFFER, 0); + curvemap->buffer = GPU_uniformbuf_create(sizeof(OCIO_GLSLCurveMappingParameters)); curvemap->valid = (curvemap->texture != 0); curvemap->cacheId = 0; @@ -384,7 +382,7 @@ static void ensureGLSLCurveMapping(OCIO_GLSLCurveMappping **curvemap_ptr, static void freeGLSLCurveMapping(OCIO_GLSLCurveMappping *curvemap) { glDeleteTextures(1, &curvemap->texture); - glDeleteBuffers(1, &curvemap->buffer); + GPU_uniformbuf_free(curvemap->buffer); OBJECT_GUARDED_DELETE(curvemap, OCIO_GLSLCurveMappping); } @@ -438,9 +436,7 @@ static void updateGLSLCurveMapping(OCIO_GLSLCurveMappping *curvemap, data.curve_mapping_lut_size = curve_mapping_settings->lut_size; data.curve_mapping_use_extend_extrapolate = curve_mapping_settings->use_extend_extrapolate; - glBindBuffer(GL_UNIFORM_BUFFER, curvemap->buffer); - glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(OCIO_GLSLCurveMappingParameters), &data); - glBindBuffer(GL_UNIFORM_BUFFER, 0); + GPU_uniformbuf_update(curvemap->buffer, &data); curvemap->cacheId = cacheId; } @@ -597,7 +593,7 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, glActiveTexture(GL_TEXTURE0); /* Bind UBO. */ - glBindBufferBase(GL_UNIFORM_BUFFER, shader->ubo_bind, shader_curvemap->buffer); + GPU_uniformbuf_bind(shader_curvemap->buffer, shader->ubo_bind); /* TODO(fclem) remove remains of IMM. */ immBindShader(shader->shader); |