diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-14 19:13:23 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-18 22:30:10 +0300 |
commit | e43e9caf1b17a029efbead02cabeba9b2cf9dcc7 (patch) | |
tree | 402908339ef0bd10782e1a2d338cb086770d4d3b /source/blender/gpu/opengl/gl_shader.cc | |
parent | 216d78687d2b9468b05fb598d1cef0b8424a40d2 (diff) |
GPUShader: Rewrite error printing
Now error printing only display the line related to the error.
We also put char marker if present.
Example:
```
-- Shader Compilation Errors : MAMaterial --
10414 | node_fresnel(, facingnormal, viewposition, tmp34);
| ^
| error: syntax error, unexpected ',', expecting ')'
----------------------------------
```
Diffstat (limited to 'source/blender/gpu/opengl/gl_shader.cc')
-rw-r--r-- | source/blender/gpu/opengl/gl_shader.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index ac2490e10ee..b336d56efcf 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -21,6 +21,8 @@ * \ingroup gpu */ +#include "BKE_global.h" + #include "BLI_string.h" #include "GPU_extensions.h" @@ -131,10 +133,14 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *> GLint status; glGetShaderiv(shader, GL_COMPILE_STATUS, &status); - if (!status) { - char log[5000]; + if (!status || (G.debug & G_DEBUG_GPU)) { + char log[5000] = ""; glGetShaderInfoLog(shader, sizeof(log), NULL, log); - this->print_errors(sources, log); + if (log[0] != '\0') { + this->print_errors(sources, log); + } + } + if (!status) { glDeleteShader(shader); return 0; } |