glsl: Add a method to tell whether a built-in is available.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 30 Aug 2013 07:06:30 +0000 (00:06 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 9 Sep 2013 18:52:16 +0000 (11:52 -0700)
We can simply call the stored predicate function.  If state is NULL,
just report that the function is available.

v2: Add a comment (requested by Paul Berry).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/ir.cpp
src/glsl/ir.h

index d9fb808..5e6cdaa 100644 (file)
@@ -1596,6 +1596,23 @@ ir_function_signature::is_builtin() const
 }
 
 
+bool
+ir_function_signature::is_builtin_available(const _mesa_glsl_parse_state *state) const
+{
+   /* We can't call the predicate without a state pointer, so just say that
+    * the signature is available.  At compile time, we need the filtering,
+    * but also receive a valid state pointer.  At link time, we're resolving
+    * imported built-in prototypes to their definitions, which will always
+    * be an exact match.  So we can skip the filtering.
+    */
+   if (state == NULL)
+      return true;
+
+   assert(builtin_info != NULL);
+   return builtin_info(state);
+}
+
+
 static bool
 modes_match(unsigned a, unsigned b)
 {
index a927e90..bd1c12c 100644 (file)
@@ -686,6 +686,9 @@ public:
    /** Whether or not this function signature is a built-in. */
    bool is_builtin() const;
 
+   /** Whether or not a built-in is available for this shader. */
+   bool is_builtin_available(const _mesa_glsl_parse_state *state) const;
+
    /** Body of instructions in the function. */
    struct exec_list body;