glsl: Use a consistent technique for tracking link success/failure.

This patch changes link_shaders() so that it sets prog->LinkStatus to
true when it starts, and then relies on linker_error() to set it to
false if a link failure occurs.

Previously, link_shaders() would set prog->LinkStatus to true halfway
through its execution; as a result, linker functions that executed
during the first half of link_shaders() would have to do their own
success/failure tracking; if they didn't, then calling linker_error()
would add an error message to the log, but not cause the link to fail.
Since it wasn't always obvious from looking at a linker function
whether it was called before or after link_shaders() set
prog->LinkStatus to true, this carried a high risk of bugs.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Paul Berry
2013-07-27 11:08:31 -07:00
parent 659ec1c958
commit b95d237fe6
5 changed files with 75 additions and 82 deletions
+9 -10
View File
@@ -31,7 +31,7 @@
#include "linker.h"
#include "main/macros.h"
bool
void
validate_intrastage_interface_blocks(struct gl_shader_program *prog,
const gl_shader **shader_list,
unsigned num_shaders)
@@ -65,16 +65,15 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
} else if (old_iface_type != iface_type) {
linker_error(prog, "definitions of interface block `%s' do not"
" match\n", iface_type->name);
return false;
return;
}
}
}
return true;
}
bool
validate_interstage_interface_blocks(const gl_shader *producer,
void
validate_interstage_interface_blocks(struct gl_shader_program *prog,
const gl_shader *producer,
const gl_shader *consumer)
{
glsl_symbol_table interfaces;
@@ -105,9 +104,9 @@ validate_interstage_interface_blocks(const gl_shader *producer,
if (expected_type == NULL)
continue;
if (var->interface_type != expected_type)
return false;
if (var->interface_type != expected_type) {
linker_error(prog, "interface block mismatch between shader stages\n");
return;
}
}
return true;
}