summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_util.h
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2018-05-19 18:19:34 +0200
committerSubv <subv2112@gmail.com>2018-05-19 18:19:34 +0200
commit21959ddfeffe6b4d2ffc49eac6d175c9a534fda4 (patch)
tree1a0618727d1d33846920a441c82d528668bf27ae /src/video_core/renderer_opengl/gl_shader_util.h
parentMerge pull request #436 from bunnei/multi-core (diff)
downloadyuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar
yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar.gz
yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar.bz2
yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar.lz
yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar.xz
yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.tar.zst
yuzu-21959ddfeffe6b4d2ffc49eac6d175c9a534fda4.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_util.h')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_util.h27
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 @@
#pragma once
+#include <string>
#include <vector>
#include <glad/glad.h>
#include "common/assert.h"
@@ -12,6 +13,27 @@
namespace GLShader {
/**
+ * Utility function to log the source code of a list of shaders.
+ * @param shaders The OpenGL shaders whose source we will print.
+ */
+template <typename... T>
+void LogShaderSource(T... shaders) {
+ auto shader_list = {shaders...};
+
+ for (const auto& shader : shader_list) {
+ if (shader == 0)
+ continue;
+
+ GLint source_length;
+ glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &source_length);
+
+ std::string source(source_length, ' ');
+ glGetShaderSource(shader, source_length, nullptr, &source[0]);
+ NGLOG_INFO(Render_OpenGL, "Shader source {}", source);
+ }
+}
+
+/**
* Utility function to create and compile an OpenGL GLSL shader
* @param source String of the GLSL shader program
* @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) {
}
}
+ if (result == GL_FALSE) {
+ // There was a problem linking the shader, print the source for debugging purposes.
+ LogShaderSource(shaders...);
+ }
+
ASSERT_MSG(result == GL_TRUE, "Shader not linked");
((shaders == 0 ? (void)0 : glDetachShader(program_id, shaders)), ...);