diff options
author | Ian Romanick <[email protected]> | 2011-06-29 14:52:10 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2011-07-17 13:02:49 -0700 |
commit | 66f4ac988d5053c9782d1390541b04f4d9c50078 (patch) | |
tree | 14a41c35ab1b769de289328b9c815fce294f9cc0 /src/glsl/ir.h | |
parent | 7eed3d4808097606bf2854e687589a8503db435d (diff) |
linker: Only over-ride built-ins when a prototype has been seen
The GLSL spec says:
"If a built-in function is redeclared in a shader (i.e., a
prototype is visible) before a call to it, then the linker will
only attempt to resolve that call within the set of shaders that
are linked with it."
This patch enforces this behavior. When a function call is processed
a flag is set in the ir_call to indicate whether the previously seen
prototype is the built-in or not. At link time a call will only bind
to an instance of a function that matches the "want built-in" setting
in the ir_call.
This has the odd side effect that first call to abs() in the shader
below will call the built-in and the second will not:
float foo(float x) { return abs(x); }
float abs(float x) { return -x; }
float bar(float x) { return abs(x); }
This seems insane, but it matches what the spec says.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31744
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r-- | src/glsl/ir.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 42a3936976a..80ad3dd295e 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -991,6 +991,7 @@ public: assert(callee->return_type != NULL); type = callee->return_type; actual_parameters->move_nodes_to(& this->actual_parameters); + this->use_builtin = callee->is_builtin; } virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const; @@ -1054,6 +1055,9 @@ public: /* List of ir_rvalue of paramaters passed in this call. */ exec_list actual_parameters; + /** Should this call only bind to a built-in function? */ + bool use_builtin; + private: ir_call() : callee(NULL) |