summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-08-21 14:34:06 -0400
committerKonstantin Käfer <mail@kkaefer.com>2015-09-14 15:16:16 +0200
commit5ef7011089e761dda0a26782c04dad9f61e65d34 (patch)
tree9ab5e015d5837506d452b077cea88cb9894cd737 /src
parent6db8e65394838e3269351cf393a8820cea1326a7 (diff)
downloadqtlocation-mapboxgl-5ef7011089e761dda0a26782c04dad9f61e65d34.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/shader/shader.cpp14
-rw-r--r--src/mbgl/shader/shader.hpp3
2 files changed, 9 insertions, 8 deletions
diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/shader/shader.cpp
index ed4cb729b3..c69518c8c8 100644
--- a/src/mbgl/shader/shader.cpp
+++ b/src/mbgl/shader/shader.cpp
@@ -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;
}
}
diff --git a/src/mbgl/shader/shader.hpp b/src/mbgl/shader/shader.hpp
index 9b150c37ed..3290224796 100644
--- a/src/mbgl/shader/shader.hpp
+++ b/src/mbgl/shader/shader.hpp
@@ -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;
};
}