glsl: Simplify the built-in function linking code.

Previously, we stored an array of up to 16 additional shaders to link,
as well as a count of how many each shader actually needed.

Since the built-in functions rewrite, all the built-ins are stored in a
single shader.  So all we need is a boolean indicating whether a shader
needs to link against built-ins or not.

During linking, we can avoid creating the temporary array if none of the
shaders being linked need built-ins.  Otherwise, it's simply a copy of
the array that has one additional element.  This is much simpler.

This patch saves approximately 128 bytes of memory per gl_shader object.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Kenneth Graunke
2013-11-23 12:11:34 -08:00
parent 1b557b1606
commit 5b331f6fcb
7 changed files with 33 additions and 38 deletions

View File

@@ -458,8 +458,8 @@ no_matching_function_error(const char *name,
print_function_prototypes(state, loc, state->symbols->get_function(name));
if (state->num_builtins_to_link) {
gl_shader *sh = state->builtins_to_link[0];
if (state->uses_builtin_functions) {
gl_shader *sh = _mesa_glsl_get_builtin_function_shader();
print_function_prototypes(state, loc, sh->symbols->get_function(name));
}
}