Skip to content

Commit

Permalink
Fixed wrong assumption of GL log length > 0 meaning an error.
Browse files Browse the repository at this point in the history
Regression caused by 6f0251d. GPUs are allowed to return logs even
if no error occurred. I believe (but cannot confirm until the fix is
tried) that this caused an error in a system where the GPU was printing
empty logs.
  • Loading branch information
onpon4 committed Jan 1, 2023
1 parent 983a59f commit e67d81a
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/opengl_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,25 @@ static GLuint gl_shader_compile( GLuint type, const char *buf,
glShaderSource(shader, 1, (const char**)&buf, &length);
glCompileShader(shader);

/* Check for compile error */
glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_status);
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
//if (GL_COMPILE_STATUS == GL_FALSE) {

/* Check for logs */
if (log_length > 0) {
log = malloc(log_length + 1);
glGetShaderInfoLog(shader, log_length, &log_length, log);
print_with_line_numbers( buf );
WARN("%s\n%s\n", filename, log);
print_with_line_numbers(buf);
if (compile_status == GL_FALSE)
WARN("%s\n%s\n", filename, log);
else
DEBUG("%s\n%s", filename, log);
free(log);
shader = 0;
}

/* Check for compile error */
if (compile_status == GL_FALSE)
shader = 0;

gl_checkErr();
return shader;
}
Expand All @@ -206,19 +213,24 @@ static int gl_program_link( GLuint program )

glLinkProgram(program);

/* Check for linking error */
glGetProgramiv(program, GL_LINK_STATUS, &link_status);
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
//if (link_status == GL_FALSE) {

/* Check for logs */
if (log_length > 0) {
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
log = malloc(log_length + 1);
glGetProgramInfoLog(program, log_length, &log_length, log);
WARN("%s\n", log);
if (link_status == GL_FALSE)
WARN("%s\n", log);
else
DEBUG("%s", log);
free(log);
return -1;
}

/* Check for linking error */
if (link_status == GL_FALSE)
return -1;

return 0;
}

Expand Down

0 comments on commit e67d81a

Please sign in to comment.