summaryrefslogtreecommitdiff
path: root/src/glsl/ir_reader.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-08-11 16:53:52 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-08-13 19:09:36 -0700
commit43ff8f1a4b90554eae489cebb7e05f983dd9ad66 (patch)
treed9a63bb1ce1257b45aea4bbcae450959b75cc64c /src/glsl/ir_reader.cpp
parentd802ba110f78c3eee9541867cde819ada1b2c449 (diff)
glsl2: Rework builtin function generation.
Each language version/extension and target now has a "profile" containing all of the available builtin function prototypes. These are written in GLSL, and come directly out of the GLSL spec (except for expanding genType). A new builtins/ir/ folder contains the hand-written IR for each builtin, regardless of what version includes it. Only those definitions that have prototypes in the profile will be included. The autogenerated IR for texture builtins is no longer written to disk, so there's no longer any confusion as to what's hand-written or generated. All scripts are now in python instead of perl.
Diffstat (limited to 'src/glsl/ir_reader.cpp')
-rw-r--r--src/glsl/ir_reader.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
index 2def3efff56..3e221c0e5ff 100644
--- a/src/glsl/ir_reader.cpp
+++ b/src/glsl/ir_reader.cpp
@@ -68,7 +68,7 @@ static ir_dereference *read_record_ref(_mesa_glsl_parse_state *, s_list *);
void
_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
- const char *src)
+ const char *src, bool scan_for_protos)
{
s_expression *expr = s_expression::read_expression(state, src);
if (expr == NULL) {
@@ -76,9 +76,11 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
return;
}
- scan_for_prototypes(state, instructions, expr);
- if (state->error)
- return;
+ if (scan_for_protos) {
+ scan_for_prototypes(state, instructions, expr);
+ if (state->error)
+ return;
+ }
read_instructions(state, instructions, expr, NULL);
talloc_free(expr);
@@ -276,7 +278,12 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
}
ir_function_signature *sig = f->exact_matching_signature(&hir_parameters);
- if (sig != NULL) {
+ if (sig == NULL && skip_body) {
+ /* If scanning for prototypes, generate a new signature. */
+ sig = new(ctx) ir_function_signature(return_type);
+ sig->is_built_in = true;
+ f->add_signature(sig);
+ } else if (sig != NULL) {
const char *badvar = sig->qualifiers_match(&hir_parameters);
if (badvar != NULL) {
ir_read_error(st, list, "function `%s' parameter `%s' qualifiers "
@@ -290,10 +297,11 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
return;
}
} else {
- sig = new(ctx) ir_function_signature(return_type);
- sig->is_built_in = true;
- f->add_signature(sig);
+ /* No prototype for this body exists - skip it. */
+ st->symbols->pop_scope();
+ return;
}
+ assert(sig != NULL);
sig->replace_parameters(&hir_parameters);