Fixes for recent GLSL display space conversions
- Building without OCIO will give correct results again - If GLSL failed to compile, fallback to glaDrawPixelsAuto will happen.
This commit is contained in:
@@ -381,8 +381,9 @@ void FallbackImpl::matrixTransformScale(float * , float * , const float *)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FallbackImpl::setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor)
|
bool FallbackImpl::setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor)
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FallbackImpl::finishGLSLDraw(OCIO_GLSLDrawState *state)
|
void FallbackImpl::finishGLSLDraw(OCIO_GLSLDrawState *state)
|
||||||
|
@@ -283,9 +283,9 @@ void OCIO_matrixTransformScale(float * m44, float * offset4, const float *scale4
|
|||||||
impl->matrixTransformScale(m44, offset4, scale4f);
|
impl->matrixTransformScale(m44, offset4, scale4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor)
|
int OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor)
|
||||||
{
|
{
|
||||||
impl->setupGLSLDraw(state_r, processor);
|
return (int) impl->setupGLSLDraw(state_r, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state)
|
void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state)
|
||||||
|
@@ -121,7 +121,7 @@ void OCIO_matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
|
|||||||
|
|
||||||
void OCIO_matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
void OCIO_matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
||||||
|
|
||||||
void OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor);
|
int OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor);
|
||||||
void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state);
|
void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state);
|
||||||
void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state);
|
void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state);
|
||||||
|
|
||||||
|
@@ -96,7 +96,7 @@ public:
|
|||||||
|
|
||||||
virtual void matrixTransformScale(float * m44, float * offset4, const float * scale4) = 0;
|
virtual void matrixTransformScale(float * m44, float * offset4, const float * scale4) = 0;
|
||||||
|
|
||||||
virtual void setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor) = 0;
|
virtual bool setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor) = 0;
|
||||||
virtual void finishGLSLDraw(struct OCIO_GLSLDrawState *state) = 0;
|
virtual void finishGLSLDraw(struct OCIO_GLSLDrawState *state) = 0;
|
||||||
virtual void freeGLState(struct OCIO_GLSLDrawState *state_r) = 0;
|
virtual void freeGLState(struct OCIO_GLSLDrawState *state_r) = 0;
|
||||||
};
|
};
|
||||||
@@ -169,7 +169,7 @@ public:
|
|||||||
|
|
||||||
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
||||||
|
|
||||||
void setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor);
|
bool setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor);
|
||||||
void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
|
void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
|
||||||
void freeGLState(struct OCIO_GLSLDrawState *state_r);
|
void freeGLState(struct OCIO_GLSLDrawState *state_r);
|
||||||
};
|
};
|
||||||
@@ -243,7 +243,7 @@ public:
|
|||||||
|
|
||||||
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
||||||
|
|
||||||
void setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor);
|
bool setupGLSLDraw(struct OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor);
|
||||||
void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
|
void finishGLSLDraw(struct OCIO_GLSLDrawState *state);
|
||||||
void freeGLState(struct OCIO_GLSLDrawState *state_r);
|
void freeGLState(struct OCIO_GLSLDrawState *state_r);
|
||||||
};
|
};
|
||||||
|
@@ -187,7 +187,7 @@ static void ensureLUT3DAllocated(OCIO_GLSLDrawState *state)
|
|||||||
* When all drawing is finished, finishGLSLDraw shall be called to
|
* When all drawing is finished, finishGLSLDraw shall be called to
|
||||||
* restore OpenGL context to it's pre-GLSL draw state.
|
* restore OpenGL context to it's pre-GLSL draw state.
|
||||||
*/
|
*/
|
||||||
void OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor)
|
bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRcPtr *processor)
|
||||||
{
|
{
|
||||||
ConstProcessorRcPtr ocio_processor = *(ConstProcessorRcPtr *) processor;
|
ConstProcessorRcPtr ocio_processor = *(ConstProcessorRcPtr *) processor;
|
||||||
|
|
||||||
@@ -232,22 +232,35 @@ void OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
|
|||||||
|
|
||||||
if (state->fragShader)
|
if (state->fragShader)
|
||||||
glDeleteShader(state->fragShader);
|
glDeleteShader(state->fragShader);
|
||||||
|
|
||||||
state->fragShader = compileShaderText(GL_FRAGMENT_SHADER, os.str().c_str());
|
state->fragShader = compileShaderText(GL_FRAGMENT_SHADER, os.str().c_str());
|
||||||
|
|
||||||
if (state->program)
|
if (state->fragShader) {
|
||||||
glDeleteProgram(state->program);
|
if (state->program)
|
||||||
|
glDeleteProgram(state->program);
|
||||||
|
|
||||||
state->program = linkShaders(state->fragShader);
|
state->program = linkShaders(state->fragShader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
if (state->program) {
|
||||||
glBindTexture(GL_TEXTURE_3D, state->lut3d_texture);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_3D, state->lut3d_texture);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
glUseProgram(state->program);
|
glUseProgram(state->program);
|
||||||
glUniform1i(glGetUniformLocation(state->program, "tex1"), 0);
|
glUniform1i(glGetUniformLocation(state->program, "tex1"), 0);
|
||||||
glUniform1i(glGetUniformLocation(state->program, "tex2"), 1);
|
glUniform1i(glGetUniformLocation(state->program, "tex2"), 1);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glActiveTexture(state->last_texture_unit);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, state->last_texture);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCIOImpl::finishGLSLDraw(OCIO_GLSLDrawState *state)
|
void OCIOImpl::finishGLSLDraw(OCIO_GLSLDrawState *state)
|
||||||
@@ -267,6 +280,12 @@ void OCIOImpl::freeGLState(struct OCIO_GLSLDrawState *state)
|
|||||||
if (state->lut3d)
|
if (state->lut3d)
|
||||||
MEM_freeN(state->lut3d);
|
MEM_freeN(state->lut3d);
|
||||||
|
|
||||||
|
if (state->program)
|
||||||
|
glDeleteProgram(state->program);
|
||||||
|
|
||||||
|
if (state->fragShader)
|
||||||
|
glDeleteShader(state->fragShader);
|
||||||
|
|
||||||
state->lut3dcacheid.~string();
|
state->lut3dcacheid.~string();
|
||||||
state->shadercacheid.~string();
|
state->shadercacheid.~string();
|
||||||
|
|
||||||
|
@@ -2775,9 +2775,7 @@ int IMB_coloemanagement_setup_glsl_draw(const ColorManagedViewSettings *view_set
|
|||||||
/* Make sure OCIO processor is up-to-date. */
|
/* Make sure OCIO processor is up-to-date. */
|
||||||
update_glsl_display_processor(applied_view_settings, display_settings);
|
update_glsl_display_processor(applied_view_settings, display_settings);
|
||||||
|
|
||||||
OCIO_setupGLSLDraw(&global_glsl_state.ocio_glsl_state, global_glsl_state.processor);
|
return OCIO_setupGLSLDraw(&global_glsl_state.ocio_glsl_state, global_glsl_state.processor);
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int IMB_coloemanagement_setup_glsl_draw_from_ctx(const bContext *C)
|
int IMB_coloemanagement_setup_glsl_draw_from_ctx(const bContext *C)
|
||||||
|
Reference in New Issue
Block a user