mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-25 19:20:06 +00:00
Merge pull request #2264 from JayFoxRox/print-shader
Print shaders in case of error
This commit is contained in:
commit
c0d9e4e435
@ -1083,7 +1083,9 @@ void RasterizerOpenGL::SetShader() {
|
|||||||
GLint block_size;
|
GLint block_size;
|
||||||
glGetActiveUniformBlockiv(current_shader->shader.handle, block_index,
|
glGetActiveUniformBlockiv(current_shader->shader.handle, block_index,
|
||||||
GL_UNIFORM_BLOCK_DATA_SIZE, &block_size);
|
GL_UNIFORM_BLOCK_DATA_SIZE, &block_size);
|
||||||
ASSERT_MSG(block_size == sizeof(UniformData), "Uniform block size did not match!");
|
ASSERT_MSG(block_size == sizeof(UniformData),
|
||||||
|
"Uniform block size did not match! Got %d, expected %zu",
|
||||||
|
static_cast<int>(block_size), sizeof(UniformData));
|
||||||
glUniformBlockBinding(current_shader->shader.handle, block_index, 0);
|
glUniformBlockBinding(current_shader->shader.handle, block_index, 0);
|
||||||
|
|
||||||
// Update uniforms
|
// Update uniforms
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_util.h"
|
#include "video_core/renderer_opengl/gl_shader_util.h"
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ GLuint LoadProgram(const char* vertex_shader, const char* fragment_shader) {
|
|||||||
if (info_log_length > 1) {
|
if (info_log_length > 1) {
|
||||||
std::vector<char> vertex_shader_error(info_log_length);
|
std::vector<char> vertex_shader_error(info_log_length);
|
||||||
glGetShaderInfoLog(vertex_shader_id, info_log_length, nullptr, &vertex_shader_error[0]);
|
glGetShaderInfoLog(vertex_shader_id, info_log_length, nullptr, &vertex_shader_error[0]);
|
||||||
if (result) {
|
if (result == GL_TRUE) {
|
||||||
LOG_DEBUG(Render_OpenGL, "%s", &vertex_shader_error[0]);
|
LOG_DEBUG(Render_OpenGL, "%s", &vertex_shader_error[0]);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Render_OpenGL, "Error compiling vertex shader:\n%s", &vertex_shader_error[0]);
|
LOG_ERROR(Render_OpenGL, "Error compiling vertex shader:\n%s", &vertex_shader_error[0]);
|
||||||
@ -51,7 +52,7 @@ GLuint LoadProgram(const char* vertex_shader, const char* fragment_shader) {
|
|||||||
if (info_log_length > 1) {
|
if (info_log_length > 1) {
|
||||||
std::vector<char> fragment_shader_error(info_log_length);
|
std::vector<char> fragment_shader_error(info_log_length);
|
||||||
glGetShaderInfoLog(fragment_shader_id, info_log_length, nullptr, &fragment_shader_error[0]);
|
glGetShaderInfoLog(fragment_shader_id, info_log_length, nullptr, &fragment_shader_error[0]);
|
||||||
if (result) {
|
if (result == GL_TRUE) {
|
||||||
LOG_DEBUG(Render_OpenGL, "%s", &fragment_shader_error[0]);
|
LOG_DEBUG(Render_OpenGL, "%s", &fragment_shader_error[0]);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Render_OpenGL, "Error compiling fragment shader:\n%s",
|
LOG_ERROR(Render_OpenGL, "Error compiling fragment shader:\n%s",
|
||||||
@ -75,13 +76,20 @@ GLuint LoadProgram(const char* vertex_shader, const char* fragment_shader) {
|
|||||||
if (info_log_length > 1) {
|
if (info_log_length > 1) {
|
||||||
std::vector<char> program_error(info_log_length);
|
std::vector<char> program_error(info_log_length);
|
||||||
glGetProgramInfoLog(program_id, info_log_length, nullptr, &program_error[0]);
|
glGetProgramInfoLog(program_id, info_log_length, nullptr, &program_error[0]);
|
||||||
if (result) {
|
if (result == GL_TRUE) {
|
||||||
LOG_DEBUG(Render_OpenGL, "%s", &program_error[0]);
|
LOG_DEBUG(Render_OpenGL, "%s", &program_error[0]);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Render_OpenGL, "Error linking shader:\n%s", &program_error[0]);
|
LOG_ERROR(Render_OpenGL, "Error linking shader:\n%s", &program_error[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the program linking failed at least one of the shaders was probably bad
|
||||||
|
if (result == GL_FALSE) {
|
||||||
|
LOG_ERROR(Render_OpenGL, "Vertex shader:\n%s", vertex_shader);
|
||||||
|
LOG_ERROR(Render_OpenGL, "Fragment shader:\n%s", fragment_shader);
|
||||||
|
}
|
||||||
|
ASSERT_MSG(result == GL_TRUE, "Shader not linked");
|
||||||
|
|
||||||
glDeleteShader(vertex_shader_id);
|
glDeleteShader(vertex_shader_id);
|
||||||
glDeleteShader(fragment_shader_id);
|
glDeleteShader(fragment_shader_id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user