[Mesa-dev] [PATCH v2 4/9] glsl: Generalize assignment and declaration IR sexp creation functions
Iago Toral Quiroga
itoral at igalia.com
Tue Sep 30 23:35:40 PDT 2014
From: Petri Latvala <petri.latvala at intel.com>
Already-existing and used declare_temp() and assign_x() functions can
then be implemented in terms of the general functions.
Signed-off-by: Petri Latvala <petri.latvala at intel.com>
---
src/glsl/tests/test_case_generator.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/glsl/tests/test_case_generator.py b/src/glsl/tests/test_case_generator.py
index d6754fc8..5df8420 100644
--- a/src/glsl/tests/test_case_generator.py
+++ b/src/glsl/tests/test_case_generator.py
@@ -127,19 +127,32 @@ def loop(statements):
check_sexp(statements)
return [['loop', statements]]
+def declare(var_type, var_name, decltype):
+ """Create a declaration of the form
+
+ (declare (<decltype>) <var_type> <var_name>)
+ """
+ return [['declare', [decltype], var_type, var_name]]
+
def declare_temp(var_type, var_name):
"""Create a declaration of the form
(declare (temporary) <var_type> <var_name)
"""
- return [['declare', ['temporary'], var_type, var_name]]
+ return declare(var_type, var_name, 'temporary')
+
+def assign(var_name, mask, value):
+ """Create a statement that assigns <value> to the variable <var_name>. The
+ assignment uses <mask> (a string) as the write mask.
+ """
+ check_sexp(value)
+ return [['assign', [mask], ['var_ref', var_name], value]]
def assign_x(var_name, value):
"""Create a statement that assigns <value> to the variable
<var_name>. The assignment uses the mask (x).
"""
- check_sexp(value)
- return [['assign', ['x'], ['var_ref', var_name], value]]
+ return assign(var_name, 'x', value)
def complex_if(var_prefix, statements):
"""Create a statement of the form
--
1.9.1
More information about the mesa-dev
mailing list