summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-07-20 11:29:46 -0700
committerIan Romanick <[email protected]>2010-07-21 15:52:58 -0700
commitd5be2acae379783c4aa31243e0a88a9e67e6ca7e (patch)
tree91ebf30796116f1b4d20b6f2fe420a085a59d59e /src/glsl/linker.cpp
parent4ccd3c548b9b9a2fee79342445f68d73525bfcdb (diff)
linker: Link built-in functions instead of including them in every shader
This is an invasive set of changes. Each user shader tracks a set of other shaders that contain built-in functions. During compilation, function prototypes are imported from these shaders. During linking, the shaders are linked with these built-in-function shaders just like with any other shader.
Diffstat (limited to 'src/glsl/linker.cpp')
-rw-r--r--src/glsl/linker.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 640e6eee8e0..7c30a40a6ce 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -739,7 +739,28 @@ link_intrastage_shaders(struct gl_shader_program *prog,
/* Resolve initializers for global variables in the linked shader.
*/
- link_function_calls(prog, linked, shader_list, num_shaders);
+ unsigned num_linking_shaders = num_shaders;
+ for (unsigned i = 0; i < num_shaders; i++)
+ num_linking_shaders += shader_list[i]->num_builtins_to_link;
+
+ gl_shader **linking_shaders =
+ (gl_shader **) calloc(num_linking_shaders, sizeof(gl_shader *));
+
+ memcpy(linking_shaders, shader_list,
+ sizeof(linking_shaders[0]) * num_shaders);
+
+ unsigned idx = num_shaders;
+ for (unsigned i = 0; i < num_shaders; i++) {
+ memcpy(&linking_shaders[idx], shader_list[i]->builtins_to_link,
+ sizeof(linking_shaders[0]) * shader_list[i]->num_builtins_to_link);
+ idx += shader_list[i]->num_builtins_to_link;
+ }
+
+ assert(idx == num_linking_shaders);
+
+ link_function_calls(prog, linked, linking_shaders, num_linking_shaders);
+
+ free(linking_shaders);
return linked;
}