Mesa (master): glsl: Make it possible to disable a variable in the symbol table.
Paul Berry
stereotype441 at kemper.freedesktop.org
Thu Oct 10 21:46:57 UTC 2013
Module: Mesa
Branch: master
Commit: 3c83c96dcd1be26e24c07a3dff5df1ef84974901
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c83c96dcd1be26e24c07a3dff5df1ef84974901
Author: Paul Berry <stereotype441 at gmail.com>
Date: Tue Oct 1 16:33:56 2013 -0700
glsl: Make it possible to disable a variable in the symbol table.
In later patches, we'll use this in order to implement the required
behaviour that after the gl_PerVertex interface block has been
redeclared, only members of the redeclared interface block may be
used.
v2: Update the function name and comment to clarify that we aren't
actually removing the variable from the symbol table, just disabling
it.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glsl/glsl_symbol_table.cpp | 15 +++++++++++++++
src/glsl/glsl_symbol_table.h | 8 ++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index 6e916b4..11569f4 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -256,3 +256,18 @@ symbol_table_entry *glsl_symbol_table::get_entry(const char *name)
return (symbol_table_entry *)
_mesa_symbol_table_find_symbol(table, -1, name);
}
+
+void
+glsl_symbol_table::disable_variable(const char *name)
+{
+ /* Ideally we would remove the variable's entry from the symbol table, but
+ * that would be difficult. Fortunately, since this is only used for
+ * built-in variables, it won't be possible for the shader to re-introduce
+ * the variable later, so all we really need to do is to make sure that
+ * further attempts to access it using get_variable() will return NULL.
+ */
+ symbol_table_entry *entry = get_entry(name);
+ if (entry != NULL) {
+ entry->v = NULL;
+ }
+}
diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h
index 62d26b8..0e62448 100644
--- a/src/glsl/glsl_symbol_table.h
+++ b/src/glsl/glsl_symbol_table.h
@@ -121,6 +121,14 @@ public:
enum ir_variable_mode mode);
/*@}*/
+ /**
+ * Disable a previously-added variable so that it no longer appears to be
+ * in the symbol table. This is necessary when gl_PerVertex is redeclared,
+ * to ensure that previously-available built-in variables are no longer
+ * available.
+ */
+ void disable_variable(const char *name);
+
private:
symbol_table_entry *get_entry(const char *name);
More information about the mesa-commit
mailing list