From 0823a87a7520c79708d6990f761b871c41ebffdf Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 30 Aug 2013 00:06:30 -0700 Subject: [PATCH] glsl: Add a method to tell whether a built-in is available. 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 Reviewed-by: Matt Turner Reviewed-by: Paul Berry --- src/glsl/ir.cpp | 17 +++++++++++++++++ src/glsl/ir.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index d9fb808c4b1..5e6cdaa0638 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -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) { diff --git a/src/glsl/ir.h b/src/glsl/ir.h index a927e90ca1f..bd1c12cd90a 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -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; -- 2.30.2