Fix incorrect shader state after shader interface creation
Use store-current-and-restore-previous OpenGL program in the OpenGL Shader Interface. This is a better fix for the initial error, which additionally solves interface artifacts when opening non-default startyp files on macOS with AMD GPU.
This commit is contained in:
@@ -1004,11 +1004,6 @@ bool GLShader::finalize(const shader::ShaderCreateInfo *info)
|
|||||||
else {
|
else {
|
||||||
interface = new GLShaderInterface(shader_program_);
|
interface = new GLShaderInterface(shader_program_);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* WORKAROUND: Creating the shader interface changes the active program.
|
|
||||||
* Make sure to update the context, otherwise we might have a missing bind.
|
|
||||||
*/
|
|
||||||
Context::get()->shader = this;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,6 +200,9 @@ static Type gpu_type_from_gl_type(int gl_type)
|
|||||||
|
|
||||||
GLShaderInterface::GLShaderInterface(GLuint program)
|
GLShaderInterface::GLShaderInterface(GLuint program)
|
||||||
{
|
{
|
||||||
|
GLuint last_program;
|
||||||
|
glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *)&last_program);
|
||||||
|
|
||||||
/* Necessary to make #glUniform works. */
|
/* Necessary to make #glUniform works. */
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
@@ -385,6 +388,8 @@ GLShaderInterface::GLShaderInterface(GLuint program)
|
|||||||
// this->debug_print();
|
// this->debug_print();
|
||||||
|
|
||||||
this->sort_inputs();
|
this->sort_inputs();
|
||||||
|
|
||||||
|
glUseProgram(last_program);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateInfo &info)
|
GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateInfo &info)
|
||||||
@@ -442,6 +447,9 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
|
|||||||
uint32_t name_buffer_offset = 0;
|
uint32_t name_buffer_offset = 0;
|
||||||
|
|
||||||
/* Necessary to make #glUniform works. TODO(fclem) Remove. */
|
/* Necessary to make #glUniform works. TODO(fclem) Remove. */
|
||||||
|
GLuint last_program;
|
||||||
|
glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *)&last_program);
|
||||||
|
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
|
|
||||||
/* Attributes */
|
/* Attributes */
|
||||||
@@ -552,6 +560,8 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
|
|||||||
this->sort_inputs();
|
this->sort_inputs();
|
||||||
|
|
||||||
// this->debug_print();
|
// this->debug_print();
|
||||||
|
|
||||||
|
glUseProgram(last_program);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLShaderInterface::~GLShaderInterface()
|
GLShaderInterface::~GLShaderInterface()
|
||||||
|
|||||||
Reference in New Issue
Block a user