diff options
| author | 2018-05-19 11:19:34 -0500 | |
|---|---|---|
| committer | 2018-05-19 11:19:34 -0500 | |
| commit | 21959ddfeffe6b4d2ffc49eac6d175c9a534fda4 (patch) | |
| tree | 1a0618727d1d33846920a441c82d528668bf27ae /src | |
| parent | Merge pull request #436 from bunnei/multi-core (diff) | |
| download | yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar.gz yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar.xz yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.zip | |
GLRenderer: Log the shader source code when program linking fails.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_util.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_util.h b/src/video_core/renderer_opengl/gl_shader_util.h index a1fa9e814..2036a06a9 100644 --- a/src/video_core/renderer_opengl/gl_shader_util.h +++ b/src/video_core/renderer_opengl/gl_shader_util.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <string> | ||
| 7 | #include <vector> | 8 | #include <vector> |
| 8 | #include <glad/glad.h> | 9 | #include <glad/glad.h> |
| 9 | #include "common/assert.h" | 10 | #include "common/assert.h" |
| @@ -12,6 +13,27 @@ | |||
| 12 | namespace GLShader { | 13 | namespace GLShader { |
| 13 | 14 | ||
| 14 | /** | 15 | /** |
| 16 | * Utility function to log the source code of a list of shaders. | ||
| 17 | * @param shaders The OpenGL shaders whose source we will print. | ||
| 18 | */ | ||
| 19 | template <typename... T> | ||
| 20 | void LogShaderSource(T... shaders) { | ||
| 21 | auto shader_list = {shaders...}; | ||
| 22 | |||
| 23 | for (const auto& shader : shader_list) { | ||
| 24 | if (shader == 0) | ||
| 25 | continue; | ||
| 26 | |||
| 27 | GLint source_length; | ||
| 28 | glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &source_length); | ||
| 29 | |||
| 30 | std::string source(source_length, ' '); | ||
| 31 | glGetShaderSource(shader, source_length, nullptr, &source[0]); | ||
| 32 | NGLOG_INFO(Render_OpenGL, "Shader source {}", source); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | /** | ||
| 15 | * Utility function to create and compile an OpenGL GLSL shader | 37 | * Utility function to create and compile an OpenGL GLSL shader |
| 16 | * @param source String of the GLSL shader program | 38 | * @param source String of the GLSL shader program |
| 17 | * @param type Type of the shader (GL_VERTEX_SHADER, GL_GEOMETRY_SHADER or GL_FRAGMENT_SHADER) | 39 | * @param type Type of the shader (GL_VERTEX_SHADER, GL_GEOMETRY_SHADER or GL_FRAGMENT_SHADER) |
| @@ -55,6 +77,11 @@ GLuint LoadProgram(bool separable_program, T... shaders) { | |||
| 55 | } | 77 | } |
| 56 | } | 78 | } |
| 57 | 79 | ||
| 80 | if (result == GL_FALSE) { | ||
| 81 | // There was a problem linking the shader, print the source for debugging purposes. | ||
| 82 | LogShaderSource(shaders...); | ||
| 83 | } | ||
| 84 | |||
| 58 | ASSERT_MSG(result == GL_TRUE, "Shader not linked"); | 85 | ASSERT_MSG(result == GL_TRUE, "Shader not linked"); |
| 59 | 86 | ||
| 60 | ((shaders == 0 ? (void)0 : glDetachShader(program_id, shaders)), ...); | 87 | ((shaders == 0 ? (void)0 : glDetachShader(program_id, shaders)), ...); |