summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang/slang_codegen.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-04-01 19:50:28 -0600
committerBrian Paul <brianp@vmware.com>2009-04-01 19:54:35 -0600
commit49fb750a6884c3f647f46270ffce8652f664f908 (patch)
tree8a666b370a04c14b14391c6d9281e0ccd032e339 /src/mesa/shader/slang/slang_codegen.c
parent1ab225017ed1ea8bd9e266d10ee56ab914bb28c1 (diff)
glsl: implement compiling/linking of separate compilation units
A shader program may consist of multiple shaders (source code units). If we find there are unresolved functions after compiling the unit that defines main(), we'll concatenate all the respective vertex or fragment shaders then recompile. This isn't foolproof but should work in most cases.
Diffstat (limited to 'src/mesa/shader/slang/slang_codegen.c')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index a7cfc45e6f..6d693c9027 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2199,12 +2199,13 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
name);
return NULL;
}
+
if (!fun->body) {
- slang_info_log_error(A->log,
- "Function '%s' prototyped but not defined. "
- "Separate compilation units not supported.",
- name);
- return NULL;
+ /* The function body may be in another compilation unit.
+ * We'll try concatenating the shaders and recompile at link time.
+ */
+ A->UnresolvedRefs = GL_TRUE;
+ return new_node1(IR_NOP, NULL);
}
/* type checking to be sure function's return type matches 'dest' type */
@@ -4648,6 +4649,14 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
printf("************* End codegen function ************\n\n");
#endif
+ if (A->UnresolvedRefs) {
+ /* Can't codegen at this time.
+ * At link time we'll concatenate all the vertex shaders and/or all
+ * the fragment shaders and try recompiling.
+ */
+ return GL_TRUE;
+ }
+
/* Emit program instructions */
success = _slang_emit_code(n, A->vartable, A->program, A->pragmas, GL_TRUE, A->log);
_slang_free_ir_tree(n);