don't delete the shaders before the program
some GPU drivers have issues with deleting shader objects that are attached to programs. while this is allowed by the spec, it seems that some drivers are crashing nonetheless.
This commit is contained in:
@@ -20,8 +20,6 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo
|
||||
|
||||
program = MBGL_CHECK_ERROR(glCreateProgram());
|
||||
|
||||
GLuint vertShader = 0;
|
||||
GLuint fragShader = 0;
|
||||
if (!compileShader(&vertShader, GL_VERTEX_SHADER, vertSource)) {
|
||||
Log::Error(Event::Shader, "Vertex shader %s failed to compile: %s", name, vertSource);
|
||||
MBGL_CHECK_ERROR(glDeleteProgram(program));
|
||||
@@ -67,12 +65,6 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the compiled shaders; they are now part of the program.
|
||||
MBGL_CHECK_ERROR(glDetachShader(program, vertShader));
|
||||
MBGL_CHECK_ERROR(glDeleteShader(vertShader));
|
||||
MBGL_CHECK_ERROR(glDetachShader(program, fragShader));
|
||||
MBGL_CHECK_ERROR(glDeleteShader(fragShader));
|
||||
|
||||
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
|
||||
}
|
||||
|
||||
@@ -115,7 +107,13 @@ bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source) {
|
||||
|
||||
Shader::~Shader() {
|
||||
if (program) {
|
||||
MBGL_CHECK_ERROR(glDetachShader(program, vertShader));
|
||||
MBGL_CHECK_ERROR(glDetachShader(program, fragShader));
|
||||
MBGL_CHECK_ERROR(glDeleteProgram(program));
|
||||
program = 0;
|
||||
MBGL_CHECK_ERROR(glDeleteShader(vertShader));
|
||||
vertShader = 0;
|
||||
MBGL_CHECK_ERROR(glDeleteShader(fragShader));
|
||||
fragShader = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ protected:
|
||||
|
||||
private:
|
||||
bool compileShader(uint32_t *shader, uint32_t type, const char *source);
|
||||
|
||||
uint32_t vertShader = 0;
|
||||
uint32_t fragShader = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user