summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/Makefile2
-rw-r--r--src/glsl/SConscript59
-rw-r--r--src/glsl/ast_to_hir.cpp71
-rw-r--r--src/glsl/builtins/ir/atan28
-rw-r--r--src/glsl/builtins/ir/distance6
-rw-r--r--src/glsl/builtins/ir/matrixCompMult54
-rw-r--r--src/glsl/builtins/ir/modf20
-rw-r--r--src/glsl/builtins/ir/noise232
-rw-r--r--src/glsl/builtins/ir/noise348
-rw-r--r--src/glsl/builtins/ir/noise472
-rw-r--r--src/glsl/builtins/ir/outerProduct54
-rw-r--r--src/glsl/builtins/ir/refract8
-rw-r--r--src/glsl/builtins/ir/smoothstep14
-rw-r--r--src/glsl/builtins/ir/step36
-rw-r--r--src/glsl/builtins/ir/transpose162
-rwxr-xr-xsrc/glsl/builtins/tools/generate_builtins.py17
-rw-r--r--src/glsl/glsl_parser_extras.cpp9
-rw-r--r--src/glsl/glsl_parser_extras.h2
-rw-r--r--src/glsl/ir.cpp49
-rw-r--r--src/glsl/ir.h10
-rw-r--r--src/glsl/ir_print_visitor.cpp3
-rw-r--r--src/glsl/ir_reader.cpp997
-rw-r--r--src/glsl/ir_set_program_inouts.cpp6
-rw-r--r--src/glsl/ir_variable.cpp32
-rw-r--r--src/glsl/lower_jumps.cpp2
-rw-r--r--src/glsl/main.cpp62
-rw-r--r--src/glsl/s_expression.cpp69
-rw-r--r--src/glsl/s_expression.h39
28 files changed, 1045 insertions, 918 deletions
diff --git a/src/glsl/Makefile b/src/glsl/Makefile
index 15f70298be3..c9525446633 100644
--- a/src/glsl/Makefile
+++ b/src/glsl/Makefile
@@ -174,7 +174,7 @@ glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
bison -v -o "$@" --defines=glcpp/glcpp-parse.h $<
builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o
- $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(TALLOC_LIBS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o -o builtin_compiler
+ $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o $(TALLOC_LIBS) -o $@
builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler
@echo Regenerating builtin_function.cpp...
diff --git a/src/glsl/SConscript b/src/glsl/SConscript
index 1757605f7cb..88a83fdb6fa 100644
--- a/src/glsl/SConscript
+++ b/src/glsl/SConscript
@@ -9,6 +9,7 @@ env = env.Clone()
env.Prepend(CPPPATH = [
'#src/mapi',
'#src/mesa',
+ '#src/glsl',
])
if env['platform'] == 'windows':
@@ -78,30 +79,54 @@ sources = [
'opt_tree_grafting.cpp',
's_expression.cpp',
'strtod.c',
-]
+]
-env.Prepend(LIBS = ['talloc'])
-env.Append(CPPPATH = ['#/src/glsl'])
-builtin_compiler = env.Program(
- target = 'builtin_compiler',
- source = sources + ['main.cpp', 'builtin_stubs.cpp',
- '#src/mesa/program/hash_table.c',
- '#src/mesa/program/symbol_table.c'],
-)
+if env['platform'] == common.host_platform:
+ if env['msvc']:
+ env.Prepend(CPPPATH = ['#/src/getopt'])
+ env.PrependUnique(LIBS = [getopt])
-env.CodeGenerate(
- target = 'builtin_function.cpp',
- script = 'builtins/tools/generate_builtins.py',
- source = builtin_compiler,
- command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
-)
+ if env['platform'] == 'windows':
+ env.Prepend(CPPPATH = ['#src/talloc'])
+ env.Prepend(LIBS = [talloc])
+ else:
+ env.Prepend(LIBS = ['talloc'])
+
+ builtin_compiler = env.Program(
+ target = 'builtin_compiler',
+ source = sources + ['main.cpp', 'builtin_stubs.cpp',
+ '#src/mesa/program/hash_table.c',
+ '#src/mesa/program/symbol_table.c'],
+ )
+
+ builtin_glsl_function = env.CodeGenerate(
+ target = 'builtin_function.cpp',
+ script = 'builtins/tools/generate_builtins.py',
+ source = builtin_compiler,
+ command = python_cmd + ' $SCRIPT $SOURCE > $TARGET'
+ )
+
+ env.Depends(builtin_glsl_function, ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
+
+ if env['msvc']:
+ # There is no LD_LIBRARY_PATH equivalent on Windows. We need to ensure
+ # talloc.dll is on the same dir as builtin_function.
+ talloc_dll_src = talloc.dir.File('talloc.dll')
+ talloc_dll_dst = builtin_compiler[0].dir.File('talloc.dll')
+ talloc_dll = env.Command(talloc_dll_dst, talloc_dll_src, Copy(talloc_dll_dst, talloc_dll_src))
+ env.Depends('builtin_function.cpp', talloc_dll)
+
+ Export('builtin_glsl_function')
+
+ if common.cross_compiling:
+ Return()
-env.Depends('builtin_function.cpp', ['builtins/tools/generate_builtins.py', 'builtins/tools/texture_builtins.py'] + Glob('builtins/ir/*'))
+sources += builtin_glsl_function
glsl = env.ConvenienceLibrary(
target = 'glsl',
- source = sources + [ 'builtin_function.cpp' ],
+ source = sources,
)
Export('glsl')
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index c4bd7e64e27..365a6e2676f 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1623,6 +1623,7 @@ ast_expression::hir(exec_list *instructions,
result = new(ctx) ir_dereference_variable(var);
if (var != NULL) {
+ var->used = true;
type = result->type;
} else {
_mesa_glsl_error(& loc, state, "`%s' undeclared",
@@ -1797,8 +1798,16 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
struct _mesa_glsl_parse_state *state,
YYLTYPE *loc)
{
- if (qual->flags.q.invariant)
- var->invariant = 1;
+ if (qual->flags.q.invariant) {
+ if (var->used) {
+ _mesa_glsl_error(loc, state,
+ "variable `%s' may not be redeclared "
+ "`invariant' after being used",
+ var->name);
+ } else {
+ var->invariant = 1;
+ }
+ }
/* FINISHME: Mark 'in' variables at global scope as read-only. */
if (qual->flags.q.constant || qual->flags.q.attribute
@@ -1948,6 +1957,52 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
}
}
+ /* Does the declaration use the 'layout' keyword?
+ */
+ const bool uses_layout = qual->flags.q.pixel_center_integer
+ || qual->flags.q.origin_upper_left
+ || qual->flags.q.explicit_location;
+
+ /* Does the declaration use the deprecated 'attribute' or 'varying'
+ * keywords?
+ */
+ const bool uses_deprecated_qualifier = qual->flags.q.attribute
+ || qual->flags.q.varying;
+
+ /* Is the 'layout' keyword used with parameters that allow relaxed checking.
+ * Many implementations of GL_ARB_fragment_coord_conventions_enable and some
+ * implementations (only Mesa?) GL_ARB_explicit_attrib_location_enable
+ * allowed the layout qualifier to be used with 'varying' and 'attribute'.
+ * These extensions and all following extensions that add the 'layout'
+ * keyword have been modified to require the use of 'in' or 'out'.
+ *
+ * The following extension do not allow the deprecated keywords:
+ *
+ * GL_AMD_conservative_depth
+ * GL_ARB_gpu_shader5
+ * GL_ARB_separate_shader_objects
+ * GL_ARB_tesselation_shader
+ * GL_ARB_transform_feedback3
+ * GL_ARB_uniform_buffer_object
+ *
+ * It is unknown whether GL_EXT_shader_image_load_store or GL_NV_gpu_shader5
+ * allow layout with the deprecated keywords.
+ */
+ const bool relaxed_layout_qualifier_checking =
+ state->ARB_fragment_coord_conventions_enable;
+
+ if (uses_layout && uses_deprecated_qualifier) {
+ if (relaxed_layout_qualifier_checking) {
+ _mesa_glsl_warning(loc, state,
+ "`layout' qualifier may not be used with "
+ "`attribute' or `varying'");
+ } else {
+ _mesa_glsl_error(loc, state,
+ "`layout' qualifier may not be used with "
+ "`attribute' or `varying'");
+ }
+ }
+
if (var->type->is_array() && state->language_version != 110) {
var->array_lvalue = true;
}
@@ -2005,6 +2060,11 @@ ast_declarator_list::hir(exec_list *instructions,
_mesa_glsl_error(& loc, state,
"`%s' cannot be marked invariant, fragment shader "
"inputs only\n", decl->identifier);
+ } else if (earlier->used) {
+ _mesa_glsl_error(& loc, state,
+ "variable `%s' may not be redeclared "
+ "`invariant' after being used",
+ earlier->name);
} else {
earlier->invariant = true;
}
@@ -2074,9 +2134,12 @@ ast_declarator_list::hir(exec_list *instructions,
*
* Local variables can only use the qualifier const."
*
- * This is relaxed in GLSL 1.30.
+ * This is relaxed in GLSL 1.30. It is also relaxed by any extension
+ * that adds the 'layout' keyword.
*/
- if (state->language_version < 130) {
+ if ((state->language_version < 130)
+ && !state->ARB_explicit_attrib_location_enable
+ && !state->ARB_fragment_coord_conventions_enable) {
if (this->type->qualifier.flags.q.out) {
_mesa_glsl_error(& loc, state,
"`out' qualifier in declaration of `%s' "
diff --git a/src/glsl/builtins/ir/atan b/src/glsl/builtins/ir/atan
index 3f97e0d46f1..cfecc1f1749 100644
--- a/src/glsl/builtins/ir/atan
+++ b/src/glsl/builtins/ir/atan
@@ -55,19 +55,19 @@
(
(declare () float r)
(if (expression bool > (expression float abs (var_ref x)) (constant float (0.000100))) (
- (assign (constant bool (1)) (x) (var_ref r) (call atan ((expression float / (var_ref y) (var_ref x)))))
+ (assign (x) (var_ref r) (call atan ((expression float / (var_ref y) (var_ref x)))))
(if (expression bool < (var_ref x) (constant float (0.000000)) ) (
(if (expression bool >= (var_ref y) (constant float (0.000000)) )
- ((assign (constant bool (1)) (x) (var_ref r) (expression float + (var_ref r) (constant float (3.141593)))))
- ((assign (constant bool (1)) (x) (var_ref r) (expression float - (var_ref r) (constant float (3.141593))))))
+ ((assign (x) (var_ref r) (expression float + (var_ref r) (constant float (3.141593)))))
+ ((assign (x) (var_ref r) (expression float - (var_ref r) (constant float (3.141593))))))
)
(
))
)
(
(declare () float sgn)
- (assign (constant bool (1)) (x) (var_ref sgn) (expression float sign (var_ref y)))
- (assign (constant bool (1)) (x) (var_ref r) (expression float * (var_ref sgn) (constant float (1.5707965))))
+ (assign (x) (var_ref sgn) (expression float sign (var_ref y)))
+ (assign (x) (var_ref r) (expression float * (var_ref sgn) (constant float (1.5707965))))
))
(return (var_ref r) )
@@ -80,10 +80,10 @@
(declare (in) vec2 y)
(declare (in) vec2 x))
((declare () vec2 r)
- (assign (constant bool (1)) (x) (var_ref r)
+ (assign (x) (var_ref r)
(call atan ((swiz x (var_ref y))
(swiz x (var_ref x)))))
- (assign (constant bool (1)) (y) (var_ref r)
+ (assign (y) (var_ref r)
(call atan ((swiz y (var_ref y))
(swiz y (var_ref x)))))
(return (var_ref r))))
@@ -93,13 +93,13 @@
(declare (in) vec3 y)
(declare (in) vec3 x))
((declare () vec3 r)
- (assign (constant bool (1)) (x) (var_ref r)
+ (assign (x) (var_ref r)
(call atan ((swiz x (var_ref y))
(swiz x (var_ref x)))))
- (assign (constant bool (1)) (y) (var_ref r)
+ (assign (y) (var_ref r)
(call atan ((swiz y (var_ref y))
(swiz y (var_ref x)))))
- (assign (constant bool (1)) (z) (var_ref r)
+ (assign (z) (var_ref r)
(call atan ((swiz z (var_ref y))
(swiz z (var_ref x)))))
(return (var_ref r))))
@@ -109,16 +109,16 @@
(declare (in) vec4 y)
(declare (in) vec4 x))
((declare () vec4 r)
- (assign (constant bool (1)) (x) (var_ref r)
+ (assign (x) (var_ref r)
(call atan ((swiz x (var_ref y))
(swiz x (var_ref x)))))
- (assign (constant bool (1)) (y) (var_ref r)
+ (assign (y) (var_ref r)
(call atan ((swiz y (var_ref y))
(swiz y (var_ref x)))))
- (assign (constant bool (1)) (z) (var_ref r)
+ (assign (z) (var_ref r)
(call atan ((swiz z (var_ref y))
(swiz z (var_ref x)))))
- (assign (constant bool (1)) (w) (var_ref r)
+ (assign (w) (var_ref r)
(call atan ((swiz w (var_ref y))
(swiz w (var_ref x)))))
(return (var_ref r)))))
diff --git a/src/glsl/builtins/ir/distance b/src/glsl/builtins/ir/distance
index 7789ca6314d..c249f8c9962 100644
--- a/src/glsl/builtins/ir/distance
+++ b/src/glsl/builtins/ir/distance
@@ -10,7 +10,7 @@
(declare (in) vec2 p0)
(declare (in) vec2 p1))
((declare () vec2 p)
- (assign (constant bool (1)) (xy) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))
+ (assign (xy) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))
(return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
(signature float
@@ -18,7 +18,7 @@
(declare (in) vec3 p0)
(declare (in) vec3 p1))
((declare () vec3 p)
- (assign (constant bool (1)) (xyz) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))
+ (assign (xyz) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))
(return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
(signature float
@@ -26,6 +26,6 @@
(declare (in) vec4 p0)
(declare (in) vec4 p1))
((declare () vec4 p)
- (assign (constant bool (1)) (xyzw) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))
+ (assign (xyzw) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))
(return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
))
diff --git a/src/glsl/builtins/ir/matrixCompMult b/src/glsl/builtins/ir/matrixCompMult
index 4be9b03e31e..2400f11afad 100644
--- a/src/glsl/builtins/ir/matrixCompMult
+++ b/src/glsl/builtins/ir/matrixCompMult
@@ -4,8 +4,8 @@
(declare (in) mat2 x)
(declare (in) mat2 y))
((declare () mat2 z)
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(return (var_ref z))))
(signature mat3
@@ -13,9 +13,9 @@
(declare (in) mat3 x)
(declare (in) mat3 y))
((declare () mat3 z)
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(return (var_ref z))))
(signature mat4
@@ -23,10 +23,10 @@
(declare (in) mat4 x)
(declare (in) mat4 y))
((declare () mat4 z)
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (3))) (expression vec4 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (3))) (expression vec4 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
(return (var_ref z))))
(signature mat2x3
@@ -34,8 +34,8 @@
(declare (in) mat2x3 x)
(declare (in) mat2x3 y))
((declare () mat2x3 z)
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(return (var_ref z))))
(signature mat3x2
@@ -43,9 +43,9 @@
(declare (in) mat3x2 x)
(declare (in) mat3x2 y))
((declare () mat3x2 z)
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(return (var_ref z))))
(signature mat2x4
@@ -53,8 +53,8 @@
(declare (in) mat2x4 x)
(declare (in) mat2x4 y))
((declare () mat2x4 z)
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
(return (var_ref z))))
(signature mat4x2
@@ -62,10 +62,10 @@
(declare (in) mat4x2 x)
(declare (in) mat4x2 y))
((declare () mat4x2 z)
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref z) (constant int (3))) (expression vec2 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (0))) (expression vec2 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (1))) (expression vec2 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (2))) (expression vec2 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
+ (assign (xy) (array_ref (var_ref z) (constant int (3))) (expression vec2 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
(return (var_ref z))))
(signature mat3x4
@@ -73,9 +73,9 @@
(declare (in) mat3x4 x)
(declare (in) mat3x4 y))
((declare () mat3x4 z)
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (0))) (expression vec4 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (1))) (expression vec4 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xyzw) (array_ref (var_ref z) (constant int (2))) (expression vec4 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
(return (var_ref z))))
(signature mat4x3
@@ -83,9 +83,9 @@
(declare (in) mat4x3 x)
(declare (in) mat4x3 y))
((declare () mat4x3 z)
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref z) (constant int (3))) (expression vec3 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (0))) (expression vec3 * (array_ref (var_ref x) (constant int (0))) (array_ref (var_ref y) (constant int (0)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (1))) (expression vec3 * (array_ref (var_ref x) (constant int (1))) (array_ref (var_ref y) (constant int (1)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (2))) (expression vec3 * (array_ref (var_ref x) (constant int (2))) (array_ref (var_ref y) (constant int (2)))))
+ (assign (xyz) (array_ref (var_ref z) (constant int (3))) (expression vec3 * (array_ref (var_ref x) (constant int (3))) (array_ref (var_ref y) (constant int (3)))))
(return (var_ref z))))
))
diff --git a/src/glsl/builtins/ir/modf b/src/glsl/builtins/ir/modf
index 2b935a91a7c..f4f631567bd 100644
--- a/src/glsl/builtins/ir/modf
+++ b/src/glsl/builtins/ir/modf
@@ -4,9 +4,8 @@
(declare (in) float x)
(declare (out) float i))
((declare () float t)
- (assign (constant bool (1)) (x) (var_ref t)
- (expression float trunc (var_ref x)))
- (assign (constant bool (1)) (x) (var_ref i) (var_ref t))
+ (assign (x) (var_ref t) (expression float trunc (var_ref x)))
+ (assign (x) (var_ref i) (var_ref t))
(return (expression float - (var_ref x) (var_ref t)))))
(signature vec2
@@ -14,9 +13,8 @@
(declare (in) vec2 x)
(declare (out) vec2 i))
((declare () vec2 t)
- (assign (constant bool (1)) (xy) (var_ref t)
- (expression vec2 trunc (var_ref x)))
- (assign (constant bool (1)) (xy) (var_ref i) (var_ref t))
+ (assign (xy) (var_ref t) (expression vec2 trunc (var_ref x)))
+ (assign (xy) (var_ref i) (var_ref t))
(return (expression vec2 - (var_ref x) (var_ref t)))))
(signature vec3
@@ -24,9 +22,8 @@
(declare (in) vec3 x)
(declare (out) vec3 i))
((declare () vec3 t)
- (assign (constant bool (1)) (xyz) (var_ref t)
- (expression vec3 trunc (var_ref x)))
- (assign (constant bool (1)) (xyz) (var_ref i) (var_ref t))
+ (assign (xyz) (var_ref t) (expression vec3 trunc (var_ref x)))
+ (assign (xyz) (var_ref i) (var_ref t))
(return (expression vec3 - (var_ref x) (var_ref t)))))
(signature vec4
@@ -34,8 +31,7 @@
(declare (in) vec4 x)
(declare (out) vec4 i))
((declare () vec4 t)
- (assign (constant bool (1)) (xyzw) (var_ref t)
- (expression vec4 trunc (var_ref x)))
- (assign (constant bool (1)) (xyzw) (var_ref i) (var_ref t))
+ (assign (xyzw) (var_ref t) (expression vec4 trunc (var_ref x)))
+ (assign (xyzw) (var_ref i) (var_ref t))
(return (expression vec4 - (var_ref x) (var_ref t)))))
))
diff --git a/src/glsl/builtins/ir/noise2 b/src/glsl/builtins/ir/noise2
index 383fccfadfb..d3366145fed 100644
--- a/src/glsl/builtins/ir/noise2
+++ b/src/glsl/builtins/ir/noise2
@@ -6,10 +6,10 @@
(declare () float b)
(declare () vec2 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
(return (var_ref t))
))
@@ -20,10 +20,10 @@
(declare () float b)
(declare () vec2 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
(return (var_ref t))
))
@@ -36,10 +36,10 @@
(declare () float b)
(declare () vec2 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
(return (var_ref t))
))
@@ -52,10 +52,10 @@
(declare () float b)
(declare () vec2 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0)))))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
(return (var_ref t))
))
))
diff --git a/src/glsl/builtins/ir/noise3 b/src/glsl/builtins/ir/noise3
index ed7ad5190f2..1d8aa3f30d0 100644
--- a/src/glsl/builtins/ir/noise3
+++ b/src/glsl/builtins/ir/noise3
@@ -7,13 +7,13 @@
(declare () float c)
(declare () vec3 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))
- (assign (constant bool (1)) (x) (var_ref c) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0)))))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))
+ (assign (x) (var_ref c) (expression float noise (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
- (assign (constant bool (1)) (z) (var_ref t) (var_ref c))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
+ (assign (z) (var_ref t) (var_ref c))
(return (var_ref t))
))
@@ -25,13 +25,13 @@
(declare () float c)
(declare () vec3 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))
- (assign (constant bool (1)) (x) (var_ref c) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0)))))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))
+ (assign (x) (var_ref c) (expression float noise (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
- (assign (constant bool (1)) (z) (var_ref t) (var_ref c))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
+ (assign (z) (var_ref t) (var_ref c))
(return (var_ref t))
))
@@ -43,13 +43,13 @@
(declare () float c)
(declare () vec3 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))
- (assign (constant bool (1)) (x) (var_ref c) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0)))))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))
+ (assign (x) (var_ref c) (expression float noise (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
- (assign (constant bool (1)) (z) (var_ref t) (var_ref c))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
+ (assign (z) (var_ref t) (var_ref c))
(return (var_ref t))
))
@@ -61,13 +61,13 @@
(declare () float c)
(declare () vec3 t)
- (assign (constant bool (1)) (x) (var_ref a) (expression float noise (var_ref p)))
- (assign (constant bool (1)) (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0)))))
- (assign (constant bool (1)) (x) (var_ref c) (expression float noise (expression float + (var_ref p) (constant float (1559.0)))))
+ (assign (x) (var_ref a) (expression float noise (var_ref p)))
+ (assign (x) (var_ref b) (expression float noise (expression float + (var_ref p) (constant float (601.0)))))
+ (assign (x) (var_ref c) (expression float noise (expression float + (var_ref p) (constant float (1559.0)))))
- (assign (constant bool (1)) (x) (var_ref t) (var_ref a))
- (assign (constant bool (1)) (y) (var_ref t) (var_ref b))
- (assign (constant bool (1)) (z) (var_ref t) (var_ref c))
+ (assign (x) (var_ref t) (var_ref a))
+ (assign (y) (var_ref t) (var_ref b))
+ (assign (z) (var_ref t) (var_ref c))
(return (var_ref t))
))
))
diff --git a/src/glsl/builtins/ir/noise4 b/src/glsl/builtins/ir/noise4
index 77a2529a180..d0894fd5e3e 100644
--- a/src/glsl/builtins/ir/noise4
+++ b/src/glsl/builtins/ir/noise4
@@ -9,17 +9,17 @@
(declare () vec4 _r)
(declare () vec4 _p)
- (assign (constant bool (1)) (xyzw) (var_ref _p) (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0))) )
+ (assign (xyzw) (var_ref _p) (expression vec4 + (var_ref p) (constant vec4 (1559.0 113.0 1861.0 797.0))) )
- (assign (constant bool (1)) (x) (var_ref _x) (expression float noise(var_ref p)))
- (assign (constant bool (1)) (x) (var_ref _y) (expression float noise(expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))
- (assign (constant bool (1)) (x) (var_ref _z) (expression float noise(var_ref _p)))
- (assign (constant bool (1)) (x) (var_ref _w) (expression float noise(expression vec4 + (var_ref _p) (constant vec4 (601.0 313.0 29.0 277.0)))))
+ (assign (x) (var_ref _x) (expression float noise(var_ref p)))
+ (assign (x) (var_ref _y) (expression float noise(expression vec4 + (var_ref p) (constant vec4 (601.0 313.0 29.0 277.0)))))
+ (assign (x) (var_ref _z) (expression float noise(var_ref _p)))
+ (assign (x) (var_ref _w) (expression float noise(expression vec4 + (var_ref _p) (constant vec4 (601.0 313.0 29.0 277.0)))))
- (assign (constant bool (1)) (x) (var_ref _r) (var_ref _x))
- (assign (constant bool (1)) (y) (var_ref _r) (var_ref _y))
- (assign (constant bool (1)) (z) (var_ref _r) (var_ref _z))
- (assign (constant bool (1)) (w) (var_ref _r) (var_ref _w))
+ (assign (x) (var_ref _r) (var_ref _x))
+ (assign (y) (var_ref _r) (var_ref _y))
+ (assign (z) (var_ref _r) (var_ref _z))
+ (assign (w) (var_ref _r) (var_ref _w))
(return (var_ref _r))
))
@@ -33,17 +33,17 @@
(declare () vec4 _r)
(declare () vec3 _p)
- (assign (constant bool (1)) (xyz) (var_ref _p) (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0))) )
+ (assign (xyz) (var_ref _p) (expression vec3 + (var_ref p) (constant vec3 (1559.0 113.0 1861.0))) )
- (assign (constant bool (1)) (x) (var_ref _x) (expression float noise(var_ref p)))
- (assign (constant bool (1)) (x) (var_ref _y) (expression float noise(expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))
- (assign (constant bool (1)) (x) (var_ref _z) (expression float noise(var_ref _p)))
- (assign (constant bool (1)) (x) (var_ref _w) (expression float noise(expression vec3 + (var_ref _p) (constant vec3 (601.0 313.0 29.0)))))
+ (assign (x) (var_ref _x) (expression float noise(var_ref p)))
+ (assign (x) (var_ref _y) (expression float noise(expression vec3 + (var_ref p) (constant vec3 (601.0 313.0 29.0)))))
+ (assign (x) (var_ref _z) (expression float noise(var_ref _p)))
+ (assign (x) (var_ref _w) (expression float noise(expression vec3 + (var_ref _p) (constant vec3 (601.0 313.0 29.0)))))
- (assign (constant bool (1)) (x) (var_ref _r) (var_ref _x))
- (assign (constant bool (1)) (y) (var_ref _r) (var_ref _y))
- (assign (constant bool (1)) (z) (var_ref _r) (var_ref _z))
- (assign (constant bool (1)) (w) (var_ref _r) (var_ref _w))
+ (assign (x) (var_ref _r) (var_ref _x))
+ (assign (y) (var_ref _r) (var_ref _y))
+ (assign (z) (var_ref _r) (var_ref _z))
+ (assign (w) (var_ref _r) (var_ref _w))
(return (var_ref _r))
))
@@ -57,17 +57,17 @@
(declare () vec4 _r)
(declare () vec2 _p)
- (assign (constant bool (1)) (xy) (var_ref _p) (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0))) )
+ (assign (xy) (var_ref _p) (expression vec2 + (var_ref p) (constant vec2 (1559.0 113.0))) )
- (assign (constant bool (1)) (x) (var_ref _x) (expression float noise(var_ref p)))
- (assign (constant bool (1)) (x) (var_ref _y) (expression float noise(expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))
- (assign (constant bool (1)) (x) (var_ref _z) (expression float noise(var_ref _p)))
- (assign (constant bool (1)) (x) (var_ref _w) (expression float noise(expression vec2 + (var_ref _p) (constant vec2 (601.0 313.0)))))
+ (assign (x) (var_ref _x) (expression float noise(var_ref p)))
+ (assign (x) (var_ref _y) (expression float noise(expression vec2 + (var_ref p) (constant vec2 (601.0 313.0)))))
+ (assign (x) (var_ref _z) (expression float noise(var_ref _p)))
+ (assign (x) (var_ref _w) (expression float noise(expression vec2 + (var_ref _p) (constant vec2 (601.0 313.0)))))
- (assign (constant bool (1)) (x) (var_ref _r) (var_ref _x))
- (assign (constant bool (1)) (y) (var_ref _r) (var_ref _y))
- (assign (constant bool (1)) (z) (var_ref _r) (var_ref _z))
- (assign (constant bool (1)) (w) (var_ref _r) (var_ref _w))
+ (assign (x) (var_ref _r) (var_ref _x))
+ (assign (y) (var_ref _r) (var_ref _y))
+ (assign (z) (var_ref _r) (var_ref _z))
+ (assign (w) (var_ref _r) (var_ref _w))
(return (var_ref _r))
))
@@ -81,17 +81,17 @@
(declare () vec4 _r)
(declare () float _p)
- (assign (constant bool (1)) (x) (var_ref _p) (expression float + (var_ref p) (constant float (1559.0))) )
+ (assign (x) (var_ref _p) (expression float + (var_ref p) (constant float (1559.0))) )
- (assign (constant bool (1)) (x) (var_ref _x) (expression float noise(var_ref p)))
- (assign (constant bool (1)) (x) (var_ref _y) (expression float noise(expression float + (var_ref p) (constant float (601.0 313.0 29.0 277.0)))))
- (assign (constant bool (1)) (x) (var_ref _z) (expression float noise(var_ref _p)))
- (assign (constant bool (1)) (x) (var_ref _w) (expression float noise(expression float + (var_ref _p) (constant float (601.0 313.0 29.0 277.0)))))
+ (assign (x) (var_ref _x) (expression float noise(var_ref p)))
+ (assign (x) (var_ref _y) (expression float noise(expression float + (var_ref p) (constant float (601.0 313.0 29.0 277.0)))))
+ (assign (x) (var_ref _z) (expression float noise(var_ref _p)))
+ (assign (x) (var_ref _w) (expression float noise(expression float + (var_ref _p) (constant float (601.0 313.0 29.0 277.0)))))
- (assign (constant bool (1)) (x) (var_ref _r) (var_ref _x))
- (assign (constant bool (1)) (y) (var_ref _r) (var_ref _y))
- (assign (constant bool (1)) (z) (var_ref _r) (var_ref _z))
- (assign (constant bool (1)) (w) (var_ref _r) (var_ref _w))
+ (assign (x) (var_ref _r) (var_ref _x))
+ (assign (y) (var_ref _r) (var_ref _y))
+ (assign (z) (var_ref _r) (var_ref _z))
+ (assign (w) (var_ref _r) (var_ref _w))
(return (var_ref _r))
))
))
diff --git a/src/glsl/builtins/ir/outerProduct b/src/glsl/builtins/ir/outerProduct
index 61d46261548..0e3f375bbac 100644
--- a/src/glsl/builtins/ir/outerProduct
+++ b/src/glsl/builtins/ir/outerProduct
@@ -4,8 +4,8 @@
(declare (in) vec2 u)
(declare (in) vec2 v))
((declare () mat2 m)
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
(return (var_ref m))))
(signature mat2x3
@@ -13,8 +13,8 @@
(declare (in) vec3 u)
(declare (in) vec2 v))
((declare () mat2x3 m)
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
(return (var_ref m))))
(signature mat2x4
@@ -22,8 +22,8 @@
(declare (in) vec4 u)
(declare (in) vec2 v))
((declare () mat2x4 m)
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
(return (var_ref m))))
(signature mat3x2
@@ -31,9 +31,9 @@
(declare (in) vec2 u)
(declare (in) vec3 v))
((declare () mat3x2 m)
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))
(return (var_ref m))
))
@@ -42,9 +42,9 @@
(declare (in) vec3 u)
(declare (in) vec3 v))
((declare () mat3 m)
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))
(return (var_ref m))))
(signature mat3x4
@@ -52,9 +52,9 @@
(declare (in) vec4 u)
(declare (in) vec3 v))
((declare () mat3x4 m)
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))
(return (var_ref m))))
(signature mat4x2
@@ -62,10 +62,10 @@
(declare (in) vec2 u)
(declare (in) vec4 v))
((declare () mat4x2 m)
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))
- (assign (constant bool (1)) (xy) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (0))) (expression vec2 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (1))) (expression vec2 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (2))) (expression vec2 * (var_ref u) (swiz z (var_ref v))))
+ (assign (xy) (array_ref (var_ref m) (constant int (3))) (expression vec2 * (var_ref u) (swiz w (var_ref v))))
(return (var_ref m))))
(signature mat4x3
@@ -73,10 +73,10 @@
(declare (in) vec3 u)
(declare (in) vec4 v))
((declare () mat4x3 m)
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))
- (assign (constant bool (1)) (xyz) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (0))) (expression vec3 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (1))) (expression vec3 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (2))) (expression vec3 * (var_ref u) (swiz z (var_ref v))))
+ (assign (xyz) (array_ref (var_ref m) (constant int (3))) (expression vec3 * (var_ref u) (swiz w (var_ref v))))
(return (var_ref m))))
(signature mat4
@@ -84,9 +84,9 @@
(declare (in) vec4 u)
(declare (in) vec4 v))
((declare () mat4 m)
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))
- (assign (constant bool (1)) (xyzw) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (0))) (expression vec4 * (var_ref u) (swiz x (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (1))) (expression vec4 * (var_ref u) (swiz y (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (2))) (expression vec4 * (var_ref u) (swiz z (var_ref v))))
+ (assign (xyzw) (array_ref (var_ref m) (constant int (3))) (expression vec4 * (var_ref u) (swiz w (var_ref v))))
(return (var_ref m))))
))
diff --git a/src/glsl/builtins/ir/refract b/src/glsl/builtins/ir/refract
index f6319b0ed47..60899f01cec 100644
--- a/src/glsl/builtins/ir/refract
+++ b/src/glsl/builtins/ir/refract
@@ -5,7 +5,7 @@
(declare (in) float n)
(declare (in) float eta))
((declare () float k)
- (assign (constant bool (1)) (x) (var_ref k)
+ (assign (x) (var_ref k)
(expression float - (constant float (1.0))
(expression float * (var_ref eta)
(expression float * (var_ref eta)
@@ -30,7 +30,7 @@
(declare (in) vec2 n)
(declare (in) float eta))
((declare () float k)
- (assign (constant bool (1)) (x) (var_ref k)
+ (assign (x) (var_ref k)
(expression float - (constant float (1.0))
(expression float * (var_ref eta)
(expression float * (var_ref eta)
@@ -55,7 +55,7 @@
(declare (in) vec3 n)
(declare (in) float eta))
((declare () float k)
- (assign (constant bool (1)) (x) (var_ref k)
+ (assign (x) (var_ref k)
(expression float - (constant float (1.0))
(expression float * (var_ref eta)
(expression float * (var_ref eta)
@@ -80,7 +80,7 @@
(declare (in) vec4 n)
(declare (in) float eta))
((declare () float k)
- (assign (constant bool (1)) (x) (var_ref k)
+ (assign (x) (var_ref k)
(expression float - (constant float (1.0))
(expression float * (var_ref eta)
(expression float * (var_ref eta)
diff --git a/src/glsl/builtins/ir/smoothstep b/src/glsl/builtins/ir/smoothstep
index b283f73d8d3..94c98b29e53 100644
--- a/src/glsl/builtins/ir/smoothstep
+++ b/src/glsl/builtins/ir/smoothstep
@@ -5,7 +5,7 @@
(declare (in) float edge1)
(declare (in) float x))
((declare () float t)
- (assign (constant bool (1)) (x) (var_ref t)
+ (assign (x) (var_ref t)
(expression float max
(expression float min
(expression float / (expression float - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
@@ -18,7 +18,7 @@
(declare (in) float edge1)
(declare (in) vec2 x))
((declare () vec2 t)
- (assign (constant bool (1)) (xy) (var_ref t)
+ (assign (xy) (var_ref t)
(expression vec2 max
(expression vec2 min
(expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
@@ -32,7 +32,7 @@
(declare (in) float edge1)
(declare (in) vec3 x))
((declare () vec3 t)
- (assign (constant bool (1)) (xyz) (var_ref t)
+ (assign (xyz) (var_ref t)
(expression vec3 max
(expression vec3 min
(expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
@@ -47,7 +47,7 @@
(declare (in) float edge1)
(declare (in) vec4 x))
((declare () vec4 t)
- (assign (constant bool (1)) (xyzw) (var_ref t)
+ (assign (xyzw) (var_ref t)
(expression vec4 max
(expression vec4 min
(expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression float - (var_ref edge1) (var_ref edge0)))
@@ -61,7 +61,7 @@
(declare (in) vec2 edge1)
(declare (in) vec2 x))
((declare () vec2 t)
- (assign (constant bool (1)) (xy) (var_ref t)
+ (assign (xy) (var_ref t)
(expression vec2 max
(expression vec2 min
(expression vec2 / (expression vec2 - (var_ref x) (var_ref edge0)) (expression vec2 - (var_ref edge1) (var_ref edge0)))
@@ -75,7 +75,7 @@
(declare (in) vec3 edge1)
(declare (in) vec3 x))
((declare () vec3 t)
- (assign (constant bool (1)) (xyz) (var_ref t)
+ (assign (xyz) (var_ref t)
(expression vec3 max
(expression vec3 min
(expression vec3 / (expression vec3 - (var_ref x) (var_ref edge0)) (expression vec3 - (var_ref edge1) (var_ref edge0)))
@@ -89,7 +89,7 @@
(declare (in) vec4 edge1)
(declare (in) vec4 x))
((declare () vec4 t)
- (assign (constant bool (1)) (xyzw) (var_ref t)
+ (assign (xyzw) (var_ref t)
(expression vec4 max
(expression vec4 min
(expression vec4 / (expression vec4 - (var_ref x) (var_ref edge0)) (expression vec4 - (var_ref edge1) (var_ref edge0)))
diff --git a/src/glsl/builtins/ir/step b/src/glsl/builtins/ir/step
index 7aec9d7a6cc..efcd7bc8023 100644
--- a/src/glsl/builtins/ir/step
+++ b/src/glsl/builtins/ir/step
@@ -10,8 +10,8 @@
(declare (in) float edge)
(declare (in) vec2 x))
((declare () vec2 t)
- (assign (constant bool (1)) (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
- (assign (constant bool (1)) (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
+ (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
+ (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
(return (var_ref t))))
(signature vec3
@@ -19,9 +19,9 @@
(declare (in) float edge)
(declare (in) vec3 x))
((declare () vec3 t)
- (assign (constant bool (1)) (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
- (assign (constant bool (1)) (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
- (assign (constant bool (1)) (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))
+ (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
+ (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
+ (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))
(return (var_ref t))))
(signature vec4
@@ -29,10 +29,10 @@
(declare (in) float edge)
(declare (in) vec4 x))
((declare () vec4 t)
- (assign (constant bool (1)) (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
- (assign (constant bool (1)) (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
- (assign (constant bool (1)) (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))
- (assign (constant bool (1)) (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))
+ (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(var_ref edge))))
+ (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(var_ref edge))))
+ (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(var_ref edge))))
+ (assign (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(var_ref edge))))
(return (var_ref t))))
(signature vec2
@@ -40,8 +40,8 @@
(declare (in) vec2 edge)
(declare (in) vec2 x))
((declare () vec2 t)
- (assign (constant bool (1)) (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
- (assign (constant bool (1)) (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
+ (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
+ (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
(return (var_ref t))))
(signature vec3
@@ -49,9 +49,9 @@
(declare (in) vec3 edge)
(declare (in) vec3 x))
((declare () vec3 t)
- (assign (constant bool (1)) (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
- (assign (constant bool (1)) (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
- (assign (constant bool (1)) (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))
+ (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
+ (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
+ (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))
(return (var_ref t))))
(signature vec4
@@ -59,10 +59,10 @@
(declare (in) vec4 edge)
(declare (in) vec4 x))
((declare () vec4 t)
- (assign (constant bool (1)) (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
- (assign (constant bool (1)) (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
- (assign (constant bool (1)) (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))
- (assign (constant bool (1)) (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))
+ (assign (x) (var_ref t) (expression float b2f (expression bool >= (swiz x (var_ref x))(swiz x (var_ref edge)))))
+ (assign (y) (var_ref t) (expression float b2f (expression bool >= (swiz y (var_ref x))(swiz y (var_ref edge)))))
+ (assign (z) (var_ref t) (expression float b2f (expression bool >= (swiz z (var_ref x))(swiz z (var_ref edge)))))
+ (assign (w) (var_ref t) (expression float b2f (expression bool >= (swiz w (var_ref x))(swiz w (var_ref edge)))))
(return (var_ref t))))
))
diff --git a/src/glsl/builtins/ir/transpose b/src/glsl/builtins/ir/transpose
index 4bed4489bf4..043327d235b 100644
--- a/src/glsl/builtins/ir/transpose
+++ b/src/glsl/builtins/ir/transpose
@@ -3,135 +3,135 @@
(parameters
(declare (in) mat2 m))
((declare () mat2 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
(return (var_ref t))))
(signature mat3x2
(parameters
(declare (in) mat2x3 m))
((declare () mat3x2 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
(return (var_ref t))))
(signature mat4x2
(parameters
(declare (in) mat2x4 m))
((declare () mat4x2 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))
(return (var_ref t))))
(signature mat2x3
(parameters
(declare (in) mat3x2 m))
((declare () mat2x3 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
(return (var_ref t))))
(signature mat3
(parameters
(declare (in) mat3 m))
((declare () mat3 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
+ (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
(return (var_ref t))))
(signature mat4x3
(parameters
(declare (in) mat3x4 m))
((declare () mat4x3 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))
+ (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2)))))
(return (var_ref t))))
(signature mat2x4
(parameters
(declare (in) mat4x2 m))
((declare () mat2x4 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
+ (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))
+ (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))
(return (var_ref t))))
(signature mat3x4
(parameters
(declare (in) mat4x3 m))
((declare () mat3x4 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
+ (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
+ (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))
+ (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))
+ (assign (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3)))))
(return (var_ref t))))
(signature mat4
(parameters
(declare (in) mat4 m))
((declare () mat4 t)
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3)))))
- (assign (constant bool (1)) (w) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (3)))))
+ (assign (x) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (0)))))
+ (assign (x) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (0)))))
+ (assign (y) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (1)))))
+ (assign (y) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (1)))))
+ (assign (z) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (2)))))
+ (assign (z) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (2)))))
+ (assign (w) (array_ref (var_ref t) (constant int (0))) (swiz x (array_ref (var_ref m) (constant int (3)))))
+ (assign (w) (array_ref (var_ref t) (constant int (1))) (swiz y (array_ref (var_ref m) (constant int (3)))))
+ (assign (w) (array_ref (var_ref t) (constant int (2))) (swiz z (array_ref (var_ref m) (constant int (3)))))
+ (assign (w) (array_ref (var_ref t) (constant int (3))) (swiz w (array_ref (var_ref m) (constant int (3)))))
(return (var_ref t))))
)
diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py
index 8b11338e8c7..3a938a022da 100755
--- a/src/glsl/builtins/tools/generate_builtins.py
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -1,7 +1,10 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+from __future__ import with_statement
+
import re
+import sys
from glob import glob
from os import path
from subprocess import Popen, PIPE
@@ -14,8 +17,8 @@ builtins_dir = path.join(path.dirname(path.abspath(__file__)), "..")
# Get the path to the standalone GLSL compiler
if len(argv) != 2:
- print "Usage:", argv[0], "<path to compiler>"
- sys.exit(1)
+ print "Usage:", argv[0], "<path to compiler>"
+ sys.exit(1)
compiler = argv[1]
@@ -60,8 +63,8 @@ def run_compiler(args):
output = p.communicate()[0]
# Clean up output a bit by killing whitespace before a closing paren.
- kill_paren_whitespace = re.compile(r'[ \n]*\)', re.MULTILINE);
- output = kill_paren_whitespace.sub(')', output);
+ kill_paren_whitespace = re.compile(r'[ \n]*\)', re.MULTILINE)
+ output = kill_paren_whitespace.sub(')', output)
# Also toss any duplicate newlines
output = output.replace('\n\n', '\n')
@@ -76,12 +79,12 @@ def write_profile(filename, profile):
return
# Kill any global variable declarations. We don't want them.
- kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE);
+ kill_globals = re.compile(r'^\(declare.*\n', re.MULTILINE)
proto_ir = kill_globals.sub('', proto_ir)
# Kill pointer addresses. They're not necessary in prototypes and just
# clutter the diff output.
- proto_ir = re.sub(r'@0x[0-9a-f]+', '', proto_ir);
+ proto_ir = re.sub(r'@0x[0-9a-f]+', '', proto_ir)
print 'static const char prototypes_for_' + profile + '[] ='
print stringify(proto_ir), ';'
@@ -235,7 +238,7 @@ _mesa_glsl_initialize_functions(struct _mesa_glsl_parse_state *state)
state->num_builtins_to_link = 0;
"""
- i=0
+ i = 0
for (filename, profile) in profiles:
if profile.endswith('_vert'):
check = 'state->target == vertex_shader && '
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 8dbe66927dc..cbeacd5633f 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -180,6 +180,15 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
}
+ } else if (strcmp(name, "GL_ARB_draw_instanced") == 0) {
+ /* This extension is only supported in vertex shaders.
+ */
+ if (state->target != vertex_shader) {
+ unsupported = true;
+ } else {
+ state->ARB_draw_instanced_enable = (ext_mode != extension_disable);
+ state->ARB_draw_instanced_warn = (ext_mode == extension_warn);
+ }
} else if (strcmp(name, "GL_ARB_explicit_attrib_location") == 0) {
state->ARB_explicit_attrib_location_enable =
(ext_mode != extension_disable);
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 39c10b99e83..030d27a2627 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -132,6 +132,8 @@ struct _mesa_glsl_parse_state {
/*@{*/
unsigned ARB_draw_buffers_enable:1;
unsigned ARB_draw_buffers_warn:1;
+ unsigned ARB_draw_instanced_enable:1;
+ unsigned ARB_draw_instanced_warn:1;
unsigned ARB_explicit_attrib_location_enable:1;
unsigned ARB_explicit_attrib_location_warn:1;
unsigned ARB_fragment_coord_conventions_enable:1;
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index b8b0fed9d1c..460d43b02e1 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -261,12 +261,38 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
case ir_unop_floor:
case ir_unop_fract:
case ir_unop_round_even:
+ case ir_unop_sin:
case ir_unop_cos:
+ case ir_unop_sin_reduced:
+ case ir_unop_cos_reduced:
case ir_unop_dFdx:
case ir_unop_dFdy:
this->type = op0->type;
break;
+ case ir_unop_f2i:
+ case ir_unop_b2i:
+ this->type = glsl_type::get_instance(GLSL_TYPE_INT,
+ op0->type->vector_elements, 1);
+ break;
+
+ case ir_unop_b2f:
+ case ir_unop_i2f:
+ case ir_unop_u2f:
+ this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
+ op0->type->vector_elements, 1);
+ break;
+
+ case ir_unop_f2b:
+ case ir_unop_i2b:
+ this->type = glsl_type::get_instance(GLSL_TYPE_BOOL,
+ op0->type->vector_elements, 1);
+ break;
+
+ case ir_unop_noise:
+ this->type = glsl_type::float_type;
+ break;
+
case ir_unop_any:
this->type = glsl_type::bool_type;
break;
@@ -302,6 +328,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
case ir_binop_max:
case ir_binop_pow:
case ir_binop_mul:
+ case ir_binop_div:
+ case ir_binop_mod:
if (op0->type->is_scalar()) {
this->type = op1->type;
} else if (op1->type->is_scalar()) {
@@ -315,7 +343,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
break;
case ir_binop_logic_and:
+ case ir_binop_logic_xor:
case ir_binop_logic_or:
+ case ir_binop_bit_and:
+ case ir_binop_bit_xor:
+ case ir_binop_bit_or:
if (op0->type->is_scalar()) {
this->type = op1->type;
} else if (op1->type->is_scalar()) {
@@ -323,10 +355,26 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
}
break;
+ case ir_binop_equal:
+ case ir_binop_nequal:
+ case ir_binop_lequal:
+ case ir_binop_gequal:
+ case ir_binop_less:
+ case ir_binop_greater:
+ assert(op0->type == op1->type);
+ this->type = glsl_type::get_instance(GLSL_TYPE_BOOL,
+ op0->type->vector_elements, 1);
+ break;
+
case ir_binop_dot:
this->type = glsl_type::float_type;
break;
+ case ir_binop_lshift:
+ case ir_binop_rshift:
+ this->type = op0->type;
+ break;
+
default:
assert(!"not reached: missing automatic type setup for ir_expression");
this->type = glsl_type::float_type;
@@ -1277,6 +1325,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
this->constant_value = NULL;
this->origin_upper_left = false;
this->pixel_center_integer = false;
+ this->used = false;
if (type && type->base_type == GLSL_TYPE_SAMPLER)
this->read_only = true;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 9668c9439ad..7b83c2836ee 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -225,6 +225,7 @@ enum ir_variable_mode {
ir_var_in,
ir_var_out,
ir_var_inout,
+ ir_var_system_value, /**< Ex: front-face, instance-id, etc. */
ir_var_temporary /**< Temporary variable generated during compilation. */
};
@@ -295,6 +296,15 @@ public:
unsigned invariant:1;
/**
+ * Has this variable been used for reading or writing?
+ *
+ * Several GLSL semantic checks require knowledge of whether or not a
+ * variable has been used. For example, it is an error to redeclare a
+ * variable as invariant after it has been used.
+ */
+ unsigned used:1;
+
+ /**
* Storage class of the variable.
*
* \sa ir_variable_mode
diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp
index 0aa0b0a5d32..c56bafd00c5 100644
--- a/src/glsl/ir_print_visitor.cpp
+++ b/src/glsl/ir_print_visitor.cpp
@@ -281,9 +281,6 @@ void ir_print_visitor::visit(ir_assignment *ir)
if (ir->condition)
ir->condition->accept(this);
- else
- printf("(constant bool (1))");
-
char mask[5];
unsigned j = 0;
diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
index 5a718d3b756..40901dc6c92 100644
--- a/src/glsl/ir_reader.cpp
+++ b/src/glsl/ir_reader.cpp
@@ -21,8 +21,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <cstdarg>
-
extern "C" {
#include <talloc.h>
}
@@ -34,69 +32,78 @@ extern "C" {
const static bool debug = false;
-static void ir_read_error(_mesa_glsl_parse_state *, s_expression *,
- const char *fmt, ...);
-static const glsl_type *read_type(_mesa_glsl_parse_state *, s_expression *);
-
-static void scan_for_prototypes(_mesa_glsl_parse_state *, exec_list *,
- s_expression *);
-static ir_function *read_function(_mesa_glsl_parse_state *, s_list *,
- bool skip_body);
-static void read_function_sig(_mesa_glsl_parse_state *, ir_function *,
- s_list *, bool skip_body);
-
-static void read_instructions(_mesa_glsl_parse_state *, exec_list *,
- s_expression *, ir_loop *);
-static ir_instruction *read_instruction(_mesa_glsl_parse_state *,
- s_expression *, ir_loop *);
-static ir_variable *read_declaration(_mesa_glsl_parse_state *, s_list *);
-static ir_if *read_if(_mesa_glsl_parse_state *, s_list *, ir_loop *);
-static ir_loop *read_loop(_mesa_glsl_parse_state *st, s_list *list);
-static ir_return *read_return(_mesa_glsl_parse_state *, s_list *);
-
-static ir_rvalue *read_rvalue(_mesa_glsl_parse_state *, s_expression *);
-static ir_assignment *read_assignment(_mesa_glsl_parse_state *, s_list *);
-static ir_expression *read_expression(_mesa_glsl_parse_state *, s_list *);
-static ir_call *read_call(_mesa_glsl_parse_state *, s_list *);
-static ir_swizzle *read_swizzle(_mesa_glsl_parse_state *, s_list *);
-static ir_constant *read_constant(_mesa_glsl_parse_state *, s_list *);
-static ir_texture *read_texture(_mesa_glsl_parse_state *, s_list *);
-
-static ir_dereference *read_dereference(_mesa_glsl_parse_state *,
- s_expression *);
-static ir_dereference_variable *
-read_var_ref(_mesa_glsl_parse_state *, s_list *);
-static ir_dereference_array *
-read_array_ref(_mesa_glsl_parse_state *, s_list *);
-static ir_dereference_record *
-read_record_ref(_mesa_glsl_parse_state *, s_list *);
+class ir_reader {
+public:
+ ir_reader(_mesa_glsl_parse_state *);
+
+ void read(exec_list *instructions, const char *src, bool scan_for_protos);
+
+private:
+ void *mem_ctx;
+ _mesa_glsl_parse_state *state;
+
+ void ir_read_error(s_expression *, const char *fmt, ...);
+
+ const glsl_type *read_type(s_expression *);
+
+ void scan_for_prototypes(exec_list *, s_expression *);
+ ir_function *read_function(s_expression *, bool skip_body);
+ void read_function_sig(ir_function *, s_expression *, bool skip_body);
+
+ void read_instructions(exec_list *, s_expression *, ir_loop *);
+ ir_instruction *read_instruction(s_expression *, ir_loop *);
+ ir_variable *read_declaration(s_expression *);
+ ir_if *read_if(s_expression *, ir_loop *);
+ ir_loop *read_loop(s_expression *);
+ ir_return *read_return(s_expression *);
+ ir_rvalue *read_rvalue(s_expression *);
+ ir_assignment *read_assignment(s_expression *);
+ ir_expression *read_expression(s_expression *);
+ ir_call *read_call(s_expression *);
+ ir_swizzle *read_swizzle(s_expression *);
+ ir_constant *read_constant(s_expression *);
+ ir_texture *read_texture(s_expression *);
+
+ ir_dereference *read_dereference(s_expression *);
+};
+
+ir_reader::ir_reader(_mesa_glsl_parse_state *state) : state(state)
+{
+ this->mem_ctx = state;
+}
void
_mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
const char *src, bool scan_for_protos)
{
- s_expression *expr = s_expression::read_expression(state, src);
+ ir_reader r(state);
+ r.read(instructions, src, scan_for_protos);
+}
+
+void
+ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
+{
+ s_expression *expr = s_expression::read_expression(mem_ctx, src);
if (expr == NULL) {
- ir_read_error(state, NULL, "couldn't parse S-Expression.");
+ ir_read_error(NULL, "couldn't parse S-Expression.");
return;
}
if (scan_for_protos) {
- scan_for_prototypes(state, instructions, expr);
+ scan_for_prototypes(instructions, expr);
if (state->error)
return;
}
- read_instructions(state, instructions, expr, NULL);
+ read_instructions(instructions, expr, NULL);
talloc_free(expr);
if (debug)
validate_ir_tree(instructions);
}
-static void
-ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr,
- const char *fmt, ...)
+void
+ir_reader::ir_read_error(s_expression *expr, const char *fmt, ...)
{
va_list ap;
@@ -121,68 +128,43 @@ ir_read_error(_mesa_glsl_parse_state *state, s_expression *expr,
}
}
-static const glsl_type *
-read_type(_mesa_glsl_parse_state *st, s_expression *expr)
+const glsl_type *
+ir_reader::read_type(s_expression *expr)
{
- s_list *list = SX_AS_LIST(expr);
- if (list != NULL) {
- s_symbol *type_sym = SX_AS_SYMBOL(list->subexpressions.get_head());
- if (type_sym == NULL) {
- ir_read_error(st, expr, "expected type (array ...) or (struct ...)");
+ s_expression *s_base_type;
+ s_int *s_size;
+
+ s_pattern pat[] = { "array", s_base_type, s_size };
+ if (MATCH(expr, pat)) {
+ const glsl_type *base_type = read_type(s_base_type);
+ if (base_type == NULL) {
+ ir_read_error(NULL, "when reading base type of array type");
return NULL;
}
- if (strcmp(type_sym->value(), "array") == 0) {
- if (list->length() != 3) {
- ir_read_error(st, expr, "expected type (array <type> <int>)");
- return NULL;
- }
- // Read base type
- s_expression *base_expr = (s_expression*) type_sym->next;
- const glsl_type *base_type = read_type(st, base_expr);
- if (base_type == NULL) {
- ir_read_error(st, NULL, "when reading base type of array");
- return NULL;
- }
-
- // Read array size
- s_int *size = SX_AS_INT(base_expr->next);
- if (size == NULL) {
- ir_read_error(st, expr, "found non-integer array size");
- return NULL;
- }
-
- return glsl_type::get_array_instance(base_type, size->value());
- } else if (strcmp(type_sym->value(), "struct") == 0) {
- assert(false); // FINISHME
- } else {
- ir_read_error(st, expr, "expected (array ...) or (struct ...); "
- "found (%s ...)", type_sym->value());
- return NULL;
- }
+ return glsl_type::get_array_instance(base_type, s_size->value());
}
s_symbol *type_sym = SX_AS_SYMBOL(expr);
if (type_sym == NULL) {
- ir_read_error(st, expr, "expected <type> (symbol or list)");
+ ir_read_error(expr, "expected <type>");
return NULL;
}
- const glsl_type *type = st->symbols->get_type(type_sym->value());
+ const glsl_type *type = state->symbols->get_type(type_sym->value());
if (type == NULL)
- ir_read_error(st, expr, "invalid type: %s", type_sym->value());
+ ir_read_error(expr, "invalid type: %s", type_sym->value());
return type;
}
-static void
-scan_for_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions,
- s_expression *expr)
+void
+ir_reader::scan_for_prototypes(exec_list *instructions, s_expression *expr)
{
s_list *list = SX_AS_LIST(expr);
if (list == NULL) {
- ir_read_error(st, expr, "Expected (<instruction> ...); found an atom.");
+ ir_read_error(expr, "Expected (<instruction> ...); found an atom.");
return;
}
@@ -195,94 +177,73 @@ scan_for_prototypes(_mesa_glsl_parse_state *st, exec_list *instructions,
if (tag == NULL || strcmp(tag->value(), "function") != 0)
continue; // not a (function ...); ignore it.
- ir_function *f = read_function(st, sub, true);
+ ir_function *f = read_function(sub, true);
if (f == NULL)
return;
instructions->push_tail(f);
}
}
-static ir_function *
-read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body)
+ir_function *
+ir_reader::read_function(s_expression *expr, bool skip_body)
{
- void *ctx = st;
bool added = false;
- if (list->length() < 3) {
- ir_read_error(st, list, "Expected (function <name> (signature ...) ...)");
- return NULL;
- }
+ s_symbol *name;
- s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next);
- if (name == NULL) {
- ir_read_error(st, list, "Expected (function <name> ...)");
+ s_pattern pat[] = { "function", name };
+ if (!PARTIAL_MATCH(expr, pat)) {
+ ir_read_error(expr, "Expected (function <name> (signature ...) ...)");
return NULL;
}
- ir_function *f = st->symbols->get_function(name->value());
+ ir_function *f = state->symbols->get_function(name->value());
if (f == NULL) {
- f = new(ctx) ir_function(name->value());
- added = st->symbols->add_function(f);
+ f = new(mem_ctx) ir_function(name->value());
+ added = state->symbols->add_function(f);
assert(added);
}
- exec_list_iterator it = list->subexpressions.iterator();
+ exec_list_iterator it = ((s_list *) expr)->subexpressions.iterator();
it.next(); // skip "function" tag
it.next(); // skip function name
for (/* nothing */; it.has_next(); it.next()) {
- s_list *siglist = SX_AS_LIST(it.get());
- if (siglist == NULL) {
- ir_read_error(st, list, "Expected (function (signature ...) ...)");
- return NULL;
- }
-
- s_symbol *tag = SX_AS_SYMBOL(siglist->subexpressions.get_head());
- if (tag == NULL || strcmp(tag->value(), "signature") != 0) {
- ir_read_error(st, siglist, "Expected (signature ...)");
- return NULL;
- }
-
- read_function_sig(st, f, siglist, skip_body);
+ s_expression *s_sig = (s_expression *) it.get();
+ read_function_sig(f, s_sig, skip_body);
}
return added ? f : NULL;
}
-static void
-read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
- bool skip_body)
+void
+ir_reader::read_function_sig(ir_function *f, s_expression *expr, bool skip_body)
{
- void *ctx = st;
- if (list->length() != 4) {
- ir_read_error(st, list, "Expected (signature <type> (parameters ...) "
- "(<instruction> ...))");
+ s_expression *type_expr;
+ s_list *paramlist;
+ s_list *body_list;
+
+ s_pattern pat[] = { "signature", type_expr, paramlist, body_list };
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "Expected (signature <type> (parameters ...) "
+ "(<instruction> ...))");
return;
}
- s_expression *type_expr = (s_expression*) list->subexpressions.head->next;
- const glsl_type *return_type = read_type(st, type_expr);
+ const glsl_type *return_type = read_type(type_expr);
if (return_type == NULL)
return;
- s_list *paramlist = SX_AS_LIST(type_expr->next);
- s_list *body_list = SX_AS_LIST(type_expr->next->next);
- if (paramlist == NULL || body_list == NULL) {
- ir_read_error(st, list, "Expected (signature <type> (parameters ...) "
- "(<instruction> ...))");
- return;
- }
s_symbol *paramtag = SX_AS_SYMBOL(paramlist->subexpressions.get_head());
if (paramtag == NULL || strcmp(paramtag->value(), "parameters") != 0) {
- ir_read_error(st, paramlist, "Expected (parameters ...)");
+ ir_read_error(paramlist, "Expected (parameters ...)");
return;
}
// Read the parameters list into a temporary place.
exec_list hir_parameters;
- st->symbols->push_scope();
+ state->symbols->push_scope();
exec_list_iterator it = paramlist->subexpressions.iterator();
for (it.next() /* skip "parameters" */; it.has_next(); it.next()) {
- s_list *decl = SX_AS_LIST(it.get());
- ir_variable *var = read_declaration(st, decl);
+ ir_variable *var = read_declaration((s_expression *) it.get());
if (var == NULL)
return;
@@ -292,25 +253,25 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
ir_function_signature *sig = f->exact_matching_signature(&hir_parameters);
if (sig == NULL && skip_body) {
/* If scanning for prototypes, generate a new signature. */
- sig = new(ctx) ir_function_signature(return_type);
+ sig = new(mem_ctx) ir_function_signature(return_type);
sig->is_builtin = true;
f->add_signature(sig);
} else if (sig != NULL) {
const char *badvar = sig->qualifiers_match(&hir_parameters);
if (badvar != NULL) {
- ir_read_error(st, list, "function `%s' parameter `%s' qualifiers "
+ ir_read_error(expr, "function `%s' parameter `%s' qualifiers "
"don't match prototype", f->name, badvar);
return;
}
if (sig->return_type != return_type) {
- ir_read_error(st, list, "function `%s' return type doesn't "
+ ir_read_error(expr, "function `%s' return type doesn't "
"match prototype", f->name);
return;
}
} else {
/* No prototype for this body exists - skip it. */
- st->symbols->pop_scope();
+ state->symbols->pop_scope();
return;
}
assert(sig != NULL);
@@ -319,39 +280,39 @@ read_function_sig(_mesa_glsl_parse_state *st, ir_function *f, s_list *list,
if (!skip_body && !body_list->subexpressions.is_empty()) {
if (sig->is_defined) {
- ir_read_error(st, list, "function %s redefined", f->name);
+ ir_read_error(expr, "function %s redefined", f->name);
return;
}
- st->current_function = sig;
- read_instructions(st, &sig->body, body_list, NULL);
- st->current_function = NULL;
+ state->current_function = sig;
+ read_instructions(&sig->body, body_list, NULL);
+ state->current_function = NULL;
sig->is_defined = true;
}
- st->symbols->pop_scope();
+ state->symbols->pop_scope();
}
-static void
-read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions,
- s_expression *expr, ir_loop *loop_ctx)
+void
+ir_reader::read_instructions(exec_list *instructions, s_expression *expr,
+ ir_loop *loop_ctx)
{
// Read in a list of instructions
s_list *list = SX_AS_LIST(expr);
if (list == NULL) {
- ir_read_error(st, expr, "Expected (<instruction> ...); found an atom.");
+ ir_read_error(expr, "Expected (<instruction> ...); found an atom.");
return;
}
foreach_iter(exec_list_iterator, it, list->subexpressions) {
s_expression *sub = (s_expression*) it.get();
- ir_instruction *ir = read_instruction(st, sub, loop_ctx);
+ ir_instruction *ir = read_instruction(sub, loop_ctx);
if (ir != NULL) {
/* Global variable declarations should be moved to the top, before
* any functions that might use them. Functions are added to the
* instruction stream when scanning for prototypes, so without this
* hack, they always appear before variable declarations.
*/
- if (st->current_function == NULL && ir->as_variable() != NULL)
+ if (state->current_function == NULL && ir->as_variable() != NULL)
instructions->push_head(ir);
else
instructions->push_tail(ir);
@@ -360,88 +321,74 @@ read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions,
}
-static ir_instruction *
-read_instruction(_mesa_glsl_parse_state *st, s_expression *expr,
- ir_loop *loop_ctx)
+ir_instruction *
+ir_reader::read_instruction(s_expression *expr, ir_loop *loop_ctx)
{
- void *ctx = st;
s_symbol *symbol = SX_AS_SYMBOL(expr);
if (symbol != NULL) {
if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL)
- return new(ctx) ir_loop_jump(ir_loop_jump::jump_break);
+ return new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_break);
if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL)
- return new(ctx) ir_loop_jump(ir_loop_jump::jump_continue);
+ return new(mem_ctx) ir_loop_jump(ir_loop_jump::jump_continue);
}
s_list *list = SX_AS_LIST(expr);
if (list == NULL || list->subexpressions.is_empty()) {
- ir_read_error(st, expr, "Invalid instruction.\n");
+ ir_read_error(expr, "Invalid instruction.\n");
return NULL;
}
s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head());
if (tag == NULL) {
- ir_read_error(st, expr, "expected instruction tag");
+ ir_read_error(expr, "expected instruction tag");
return NULL;
}
ir_instruction *inst = NULL;
if (strcmp(tag->value(), "declare") == 0) {
- inst = read_declaration(st, list);
+ inst = read_declaration(list);
} else if (strcmp(tag->value(), "assign") == 0) {
- inst = read_assignment(st, list);
+ inst = read_assignment(list);
} else if (strcmp(tag->value(), "if") == 0) {
- inst = read_if(st, list, loop_ctx);
+ inst = read_if(list, loop_ctx);
} else if (strcmp(tag->value(), "loop") == 0) {
- inst = read_loop(st, list);
+ inst = read_loop(list);
} else if (strcmp(tag->value(), "return") == 0) {
- inst = read_return(st, list);
+ inst = read_return(list);
} else if (strcmp(tag->value(), "function") == 0) {
- inst = read_function(st, list, false);
+ inst = read_function(list, false);
} else {
- inst = read_rvalue(st, list);
+ inst = read_rvalue(list);
if (inst == NULL)
- ir_read_error(st, NULL, "when reading instruction");
+ ir_read_error(NULL, "when reading instruction");
}
return inst;
}
-
-static ir_variable *
-read_declaration(_mesa_glsl_parse_state *st, s_list *list)
+ir_variable *
+ir_reader::read_declaration(s_expression *expr)
{
- void *ctx = st;
- if (list->length() != 4) {
- ir_read_error(st, list, "expected (declare (<qualifiers>) <type> "
- "<name>)");
- return NULL;
- }
+ s_list *s_quals;
+ s_expression *s_type;
+ s_symbol *s_name;
- s_list *quals = SX_AS_LIST(list->subexpressions.head->next);
- if (quals == NULL) {
- ir_read_error(st, list, "expected a list of variable qualifiers");
+ s_pattern pat[] = { "declare", s_quals, s_type, s_name };
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (declare (<qualifiers>) <type> <name>)");
return NULL;
}
- s_expression *type_expr = (s_expression*) quals->next;
- const glsl_type *type = read_type(st, type_expr);
+ const glsl_type *type = read_type(s_type);
if (type == NULL)
return NULL;
- s_symbol *var_name = SX_AS_SYMBOL(type_expr->next);
- if (var_name == NULL) {
- ir_read_error(st, list, "expected variable name, found non-symbol");
- return NULL;
- }
-
- ir_variable *var = new(ctx) ir_variable(type, var_name->value(),
- ir_var_auto);
+ ir_variable *var = new(mem_ctx) ir_variable(type, s_name->value(),
+ ir_var_auto);
- foreach_iter(exec_list_iterator, it, quals->subexpressions) {
+ foreach_iter(exec_list_iterator, it, s_quals->subexpressions) {
s_symbol *qualifier = SX_AS_SYMBOL(it.get());
if (qualifier == NULL) {
- ir_read_error(st, list, "qualifier list must contain only symbols");
- delete var;
+ ir_read_error(expr, "qualifier list must contain only symbols");
return NULL;
}
@@ -467,44 +414,42 @@ read_declaration(_mesa_glsl_parse_state *st, s_list *list)
} else if (strcmp(qualifier->value(), "noperspective") == 0) {
var->interpolation = ir_var_noperspective;
} else {
- ir_read_error(st, list, "unknown qualifier: %s", qualifier->value());
- delete var;
+ ir_read_error(expr, "unknown qualifier: %s", qualifier->value());
return NULL;
}
}
// Add the variable to the symbol table
- st->symbols->add_variable(var);
+ state->symbols->add_variable(var);
return var;
}
-static ir_if *
-read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx)
+ir_if *
+ir_reader::read_if(s_expression *expr, ir_loop *loop_ctx)
{
- void *ctx = st;
- if (list->length() != 4) {
- ir_read_error(st, list, "expected (if <condition> (<then> ...) "
- "(<else> ...))");
+ s_expression *s_cond;
+ s_expression *s_then;
+ s_expression *s_else;
+
+ s_pattern pat[] = { "if", s_cond, s_then, s_else };
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (if <condition> (<then>...) (<else>...))");
return NULL;
}
- s_expression *cond_expr = (s_expression*) list->subexpressions.head->next;
- ir_rvalue *condition = read_rvalue(st, cond_expr);
+ ir_rvalue *condition = read_rvalue(s_cond);
if (condition == NULL) {
- ir_read_error(st, NULL, "when reading condition of (if ...)");
+ ir_read_error(NULL, "when reading condition of (if ...)");
return NULL;
}
- s_expression *then_expr = (s_expression*) cond_expr->next;
- s_expression *else_expr = (s_expression*) then_expr->next;
+ ir_if *iff = new(mem_ctx) ir_if(condition);
- ir_if *iff = new(ctx) ir_if(condition);
-
- read_instructions(st, &iff->then_instructions, then_expr, loop_ctx);
- read_instructions(st, &iff->else_instructions, else_expr, loop_ctx);
- if (st->error) {
+ read_instructions(&iff->then_instructions, s_then, loop_ctx);
+ read_instructions(&iff->else_instructions, s_else, loop_ctx);
+ if (state->error) {
delete iff;
iff = NULL;
}
@@ -512,27 +457,23 @@ read_if(_mesa_glsl_parse_state *st, s_list *list, ir_loop *loop_ctx)
}
-static ir_loop *
-read_loop(_mesa_glsl_parse_state *st, s_list *list)
+ir_loop *
+ir_reader::read_loop(s_expression *expr)
{
- void *ctx = st;
- if (list->length() != 6) {
- ir_read_error(st, list, "expected (loop <counter> <from> <to> "
- "<increment> <body>)");
+ s_expression *s_counter, *s_from, *s_to, *s_inc, *s_body;
+
+ s_pattern pat[] = { "loop", s_counter, s_from, s_to, s_inc, s_body };
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (loop <counter> <from> <to> "
+ "<increment> <body>)");
return NULL;
}
- s_expression *count_expr = (s_expression*) list->subexpressions.head->next;
- s_expression *from_expr = (s_expression*) count_expr->next;
- s_expression *to_expr = (s_expression*) from_expr->next;
- s_expression *inc_expr = (s_expression*) to_expr->next;
- s_expression *body_expr = (s_expression*) inc_expr->next;
-
// FINISHME: actually read the count/from/to fields.
- ir_loop *loop = new(ctx) ir_loop;
- read_instructions(st, &loop->body_instructions, body_expr, loop);
- if (st->error) {
+ ir_loop *loop = new(mem_ctx) ir_loop;
+ read_instructions(&loop->body_instructions, s_body, loop);
+ if (state->error) {
delete loop;
loop = NULL;
}
@@ -540,29 +481,29 @@ read_loop(_mesa_glsl_parse_state *st, s_list *list)
}
-static ir_return *
-read_return(_mesa_glsl_parse_state *st, s_list *list)
+ir_return *
+ir_reader::read_return(s_expression *expr)
{
- void *ctx = st;
- if (list->length() != 2) {
- ir_read_error(st, list, "expected (return <rvalue>)");
+ s_expression *s_retval;
+
+ s_pattern pat[] = { "return", s_retval};
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (return <rvalue>)");
return NULL;
}
- s_expression *expr = (s_expression*) list->subexpressions.head->next;
-
- ir_rvalue *retval = read_rvalue(st, expr);
+ ir_rvalue *retval = read_rvalue(s_retval);
if (retval == NULL) {
- ir_read_error(st, NULL, "when reading return value");
+ ir_read_error(NULL, "when reading return value");
return NULL;
}
- return new(ctx) ir_return(retval);
+ return new(mem_ctx) ir_return(retval);
}
-static ir_rvalue *
-read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr)
+ir_rvalue *
+ir_reader::read_rvalue(s_expression *expr)
{
s_list *list = SX_AS_LIST(expr);
if (list == NULL || list->subexpressions.is_empty())
@@ -570,68 +511,63 @@ read_rvalue(_mesa_glsl_parse_state *st, s_expression *expr)
s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head());
if (tag == NULL) {
- ir_read_error(st, expr, "expected rvalue tag");
+ ir_read_error(expr, "expected rvalue tag");
return NULL;
}
- ir_rvalue *rvalue = read_dereference(st, list);
- if (rvalue != NULL || st->error)
+ ir_rvalue *rvalue = read_dereference(list);
+ if (rvalue != NULL || state->error)
return rvalue;
else if (strcmp(tag->value(), "swiz") == 0) {
- rvalue = read_swizzle(st, list);
+ rvalue = read_swizzle(list);
} else if (strcmp(tag->value(), "expression") == 0) {
- rvalue = read_expression(st, list);
+ rvalue = read_expression(list);
} else if (strcmp(tag->value(), "call") == 0) {
- rvalue = read_call(st, list);
+ rvalue = read_call(list);
} else if (strcmp(tag->value(), "constant") == 0) {
- rvalue = read_constant(st, list);
+ rvalue = read_constant(list);
} else {
- rvalue = read_texture(st, list);
- if (rvalue == NULL && !st->error)
- ir_read_error(st, expr, "unrecognized rvalue tag: %s", tag->value());
+ rvalue = read_texture(list);
+ if (rvalue == NULL && !state->error)
+ ir_read_error(expr, "unrecognized rvalue tag: %s", tag->value());
}
return rvalue;
}
-static ir_assignment *
-read_assignment(_mesa_glsl_parse_state *st, s_list *list)
+ir_assignment *
+ir_reader::read_assignment(s_expression *expr)
{
- void *ctx = st;
- if (list->length() != 5) {
- ir_read_error(st, list, "expected (assign <condition> (<write mask>) "
- "<lhs> <rhs>)");
- return NULL;
- }
-
- s_expression *cond_expr = (s_expression*) list->subexpressions.head->next;
- s_list *mask_list = SX_AS_LIST(cond_expr->next);
- s_expression *lhs_expr = (s_expression*) cond_expr->next->next;
- s_expression *rhs_expr = (s_expression*) lhs_expr->next;
+ s_expression *cond_expr = NULL;
+ s_expression *lhs_expr, *rhs_expr;
+ s_list *mask_list;
- ir_rvalue *condition = read_rvalue(st, cond_expr);
- if (condition == NULL) {
- ir_read_error(st, NULL, "when reading condition of assignment");
+ s_pattern pat4[] = { "assign", mask_list, lhs_expr, rhs_expr };
+ s_pattern pat5[] = { "assign", cond_expr, mask_list, lhs_expr, rhs_expr };
+ if (!MATCH(expr, pat4) && !MATCH(expr, pat5)) {
+ ir_read_error(expr, "expected (assign [<condition>] (<write mask>) "
+ "<lhs> <rhs>)");
return NULL;
}
- if (mask_list == NULL || mask_list->length() > 1) {
- ir_read_error(st, mask_list, "expected () or (<write mask>)");
- return NULL;
+ ir_rvalue *condition = NULL;
+ if (cond_expr != NULL) {
+ condition = read_rvalue(cond_expr);
+ if (condition == NULL) {
+ ir_read_error(NULL, "when reading condition of assignment");
+ return NULL;
+ }
}
unsigned mask = 0;
- if (mask_list->length() == 1) {
- s_symbol *mask_symbol = SX_AS_SYMBOL(mask_list->subexpressions.head);
- if (mask_symbol == NULL) {
- ir_read_error(st, list, "expected a write mask; found non-symbol");
- return NULL;
- }
+ s_symbol *mask_symbol;
+ s_pattern mask_pat[] = { mask_symbol };
+ if (MATCH(mask_list, mask_pat)) {
const char *mask_str = mask_symbol->value();
unsigned mask_length = strlen(mask_str);
if (mask_length > 4) {
- ir_read_error(st, list, "invalid write mask: %s", mask_str);
+ ir_read_error(expr, "invalid write mask: %s", mask_str);
return NULL;
}
@@ -639,47 +575,46 @@ read_assignment(_mesa_glsl_parse_state *st, s_list *list)
for (unsigned i = 0; i < mask_length; i++) {
if (mask_str[i] < 'w' || mask_str[i] > 'z') {
- ir_read_error(st, list, "write mask contains invalid character: %c",
+ ir_read_error(expr, "write mask contains invalid character: %c",
mask_str[i]);
return NULL;
}
mask |= 1 << idx_map[mask_str[i] - 'w'];
}
+ } else if (!mask_list->subexpressions.is_empty()) {
+ ir_read_error(mask_list, "expected () or (<write mask>)");
+ return NULL;
}
- ir_dereference *lhs = read_dereference(st, lhs_expr);
+ ir_dereference *lhs = read_dereference(lhs_expr);
if (lhs == NULL) {
- ir_read_error(st, NULL, "when reading left-hand side of assignment");
+ ir_read_error(NULL, "when reading left-hand side of assignment");
return NULL;
}
- ir_rvalue *rhs = read_rvalue(st, rhs_expr);
+ ir_rvalue *rhs = read_rvalue(rhs_expr);
if (rhs == NULL) {
- ir_read_error(st, NULL, "when reading right-hand side of assignment");
+ ir_read_error(NULL, "when reading right-hand side of assignment");
return NULL;
}
if (mask == 0 && (lhs->type->is_vector() || lhs->type->is_scalar())) {
- ir_read_error(st, list, "non-zero write mask required.");
+ ir_read_error(expr, "non-zero write mask required.");
return NULL;
}
- return new(ctx) ir_assignment(lhs, rhs, condition, mask);
+ return new(mem_ctx) ir_assignment(lhs, rhs, condition, mask);
}
-static ir_call *
-read_call(_mesa_glsl_parse_state *st, s_list *list)
+ir_call *
+ir_reader::read_call(s_expression *expr)
{
- void *ctx = st;
- if (list->length() != 3) {
- ir_read_error(st, list, "expected (call <name> (<param> ...))");
- return NULL;
- }
+ s_symbol *name;
+ s_list *params;
- s_symbol *name = SX_AS_SYMBOL(list->subexpressions.head->next);
- s_list *params = SX_AS_LIST(list->subexpressions.head->next->next);
- if (name == NULL || params == NULL) {
- ir_read_error(st, list, "expected (call <name> (<param> ...))");
+ s_pattern pat[] = { "call", name, params };
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (call <name> (<param> ...))");
return NULL;
}
@@ -687,173 +622,156 @@ read_call(_mesa_glsl_parse_state *st, s_list *list)
foreach_iter(exec_list_iterator, it, params->subexpressions) {
s_expression *expr = (s_expression*) it.get();
- ir_rvalue *param = read_rvalue(st, expr);
+ ir_rvalue *param = read_rvalue(expr);
if (param == NULL) {
- ir_read_error(st, list, "when reading parameter to function call");
+ ir_read_error(expr, "when reading parameter to function call");
return NULL;
}
parameters.push_tail(param);
}
- ir_function *f = st->symbols->get_function(name->value());
+ ir_function *f = state->symbols->get_function(name->value());
if (f == NULL) {
- ir_read_error(st, list, "found call to undefined function %s",
+ ir_read_error(expr, "found call to undefined function %s",
name->value());
return NULL;
}
ir_function_signature *callee = f->matching_signature(&parameters);
if (callee == NULL) {
- ir_read_error(st, list, "couldn't find matching signature for function "
+ ir_read_error(expr, "couldn't find matching signature for function "
"%s", name->value());
return NULL;
}
- return new(ctx) ir_call(callee, &parameters);
+ return new(mem_ctx) ir_call(callee, &parameters);
}
-static ir_expression *
-read_expression(_mesa_glsl_parse_state *st, s_list *list)
+ir_expression *
+ir_reader::read_expression(s_expression *expr)
{
- void *ctx = st;
- const unsigned list_length = list->length();
- if (list_length < 4) {
- ir_read_error(st, list, "expected (expression <type> <operator> "
- "<operand> [<operand>])");
+ s_expression *s_type;
+ s_symbol *s_op;
+ s_expression *s_arg1;
+
+ s_pattern pat[] = { "expression", s_type, s_op, s_arg1 };
+ if (!PARTIAL_MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (expression <type> <operator> "
+ "<operand> [<operand>])");
return NULL;
}
+ s_expression *s_arg2 = (s_expression *) s_arg1->next; // may be tail sentinel
- s_expression *type_expr = (s_expression*) list->subexpressions.head->next;
- const glsl_type *type = read_type(st, type_expr);
+ const glsl_type *type = read_type(s_type);
if (type == NULL)
return NULL;
/* Read the operator */
- s_symbol *op_sym = SX_AS_SYMBOL(type_expr->next);
- if (op_sym == NULL) {
- ir_read_error(st, list, "expected operator, found non-symbol");
- return NULL;
- }
-
- ir_expression_operation op = ir_expression::get_operator(op_sym->value());
+ ir_expression_operation op = ir_expression::get_operator(s_op->value());
if (op == (ir_expression_operation) -1) {
- ir_read_error(st, list, "invalid operator: %s", op_sym->value());
+ ir_read_error(expr, "invalid operator: %s", s_op->value());
return NULL;
}
- /* Now that we know the operator, check for the right number of operands */
- if (ir_expression::get_num_operands(op) == 2) {
- if (list_length != 5) {
- ir_read_error(st, list, "expected (expression <type> %s <operand> "
- " <operand>)", op_sym->value());
- return NULL;
- }
- } else {
- if (list_length != 4) {
- ir_read_error(st, list, "expected (expression <type> %s <operand>)",
- op_sym->value());
- return NULL;
- }
+ unsigned num_operands = ir_expression::get_num_operands(op);
+ if (num_operands == 1 && !s_arg1->next->is_tail_sentinel()) {
+ ir_read_error(expr, "expected (expression <type> %s <operand>)",
+ s_op->value());
+ return NULL;
}
- s_expression *exp1 = (s_expression*) (op_sym->next);
- ir_rvalue *arg1 = read_rvalue(st, exp1);
+ ir_rvalue *arg1 = read_rvalue(s_arg1);
+ ir_rvalue *arg2 = NULL;
if (arg1 == NULL) {
- ir_read_error(st, NULL, "when reading first operand of %s",
- op_sym->value());
+ ir_read_error(NULL, "when reading first operand of %s", s_op->value());
return NULL;
}
- ir_rvalue *arg2 = NULL;
- if (ir_expression::get_num_operands(op) == 2) {
- s_expression *exp2 = (s_expression*) (exp1->next);
- arg2 = read_rvalue(st, exp2);
+ if (num_operands == 2) {
+ if (s_arg2->is_tail_sentinel() || !s_arg2->next->is_tail_sentinel()) {
+ ir_read_error(expr, "expected (expression <type> %s <operand> "
+ "<operand>)", s_op->value());
+ return NULL;
+ }
+ arg2 = read_rvalue(s_arg2);
if (arg2 == NULL) {
- ir_read_error(st, NULL, "when reading second operand of %s",
- op_sym->value());
+ ir_read_error(NULL, "when reading second operand of %s",
+ s_op->value());
return NULL;
}
}
- return new(ctx) ir_expression(op, type, arg1, arg2);
+ return new(mem_ctx) ir_expression(op, type, arg1, arg2);
}
-static ir_swizzle *
-read_swizzle(_mesa_glsl_parse_state *st, s_list *list)
+ir_swizzle *
+ir_reader::read_swizzle(s_expression *expr)
{
- if (list->length() != 3) {
- ir_read_error(st, list, "expected (swiz <swizzle> <rvalue>)");
- return NULL;
- }
+ s_symbol *swiz;
+ s_expression *sub;
- s_symbol *swiz = SX_AS_SYMBOL(list->subexpressions.head->next);
- if (swiz == NULL) {
- ir_read_error(st, list, "expected a valid swizzle; found non-symbol");
+ s_pattern pat[] = { "swiz", swiz, sub };
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (swiz <swizzle> <rvalue>)");
return NULL;
}
if (strlen(swiz->value()) > 4) {
- ir_read_error(st, list, "expected a valid swizzle; found %s",
- swiz->value());
+ ir_read_error(expr, "expected a valid swizzle; found %s", swiz->value());
return NULL;
}
- s_expression *sub = (s_expression*) swiz->next;
- ir_rvalue *rvalue = read_rvalue(st, sub);
+ ir_rvalue *rvalue = read_rvalue(sub);
if (rvalue == NULL)
return NULL;
ir_swizzle *ir = ir_swizzle::create(rvalue, swiz->value(),
rvalue->type->vector_elements);
if (ir == NULL)
- ir_read_error(st, list, "invalid swizzle");
+ ir_read_error(expr, "invalid swizzle");
return ir;
}
-static ir_constant *
-read_constant(_mesa_glsl_parse_state *st, s_list *list)
+ir_constant *
+ir_reader::read_constant(s_expression *expr)
{
- void *ctx = st;
- if (list->length() != 3) {
- ir_read_error(st, list, "expected (constant <type> (...))");
+ s_expression *type_expr;
+ s_list *values;
+
+ s_pattern pat[] = { "constant", type_expr, values };
+ if (!MATCH(expr, pat)) {
+ ir_read_error(expr, "expected (constant <type> (...))");
return NULL;
}
- s_expression *type_expr = (s_expression*) list->subexpressions.head->next;
- const glsl_type *type = read_type(st, type_expr);
+ const glsl_type *type = read_type(type_expr);
if (type == NULL)
return NULL;
- s_list *values = SX_AS_LIST(type_expr->next);
if (values == NULL) {
- ir_read_error(st, list, "expected (constant <type> (...))");
+ ir_read_error(expr, "expected (constant <type> (...))");
return NULL;
}
if (type->is_array()) {
- const unsigned elements_supplied = values->length();
- if (elements_supplied != type->length) {
- ir_read_error(st, values, "expected exactly %u array elements, "
- "given %u", type->length, elements_supplied);
- return NULL;
- }
-
+ unsigned elements_supplied = 0;
exec_list elements;
foreach_iter(exec_list_iterator, it, values->subexpressions) {
- s_expression *expr = (s_expression *) it.get();
- s_list *elt = SX_AS_LIST(expr);
- if (elt == NULL) {
- ir_read_error(st, expr, "expected (constant ...) array element");
- return NULL;
- }
-
- ir_constant *ir_elt = read_constant(st, elt);
+ s_expression *elt = (s_expression *) it.get();
+ ir_constant *ir_elt = read_constant(elt);
if (ir_elt == NULL)
return NULL;
elements.push_tail(ir_elt);
+ elements_supplied++;
+ }
+
+ if (elements_supplied != type->length) {
+ ir_read_error(values, "expected exactly %u array elements, "
+ "given %u", type->length, elements_supplied);
+ return NULL;
}
- return new(ctx) ir_constant(type, &elements);
+ return new(mem_ctx) ir_constant(type, &elements);
}
const glsl_type *const base_type = type->get_base_type();
@@ -864,7 +782,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list)
int k = 0;
foreach_iter(exec_list_iterator, it, values->subexpressions) {
if (k >= 16) {
- ir_read_error(st, values, "expected at most 16 numbers");
+ ir_read_error(values, "expected at most 16 numbers");
return NULL;
}
@@ -873,14 +791,14 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list)
if (base_type->base_type == GLSL_TYPE_FLOAT) {
s_number *value = SX_AS_NUMBER(expr);
if (value == NULL) {
- ir_read_error(st, values, "expected numbers");
+ ir_read_error(values, "expected numbers");
return NULL;
}
data.f[k] = value->fvalue();
} else {
s_int *value = SX_AS_INT(expr);
if (value == NULL) {
- ir_read_error(st, values, "expected integers");
+ ir_read_error(values, "expected integers");
return NULL;
}
@@ -898,246 +816,185 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list)
break;
}
default:
- ir_read_error(st, values, "unsupported constant type");
+ ir_read_error(values, "unsupported constant type");
return NULL;
}
}
++k;
}
- return new(ctx) ir_constant(type, &data);
+ return new(mem_ctx) ir_constant(type, &data);
}
-static ir_dereference *
-read_dereference(_mesa_glsl_parse_state *st, s_expression *expr)
+ir_dereference *
+ir_reader::read_dereference(s_expression *expr)
{
- s_list *list = SX_AS_LIST(expr);
- if (list == NULL || list->subexpressions.is_empty())
- return NULL;
-
- s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head);
- assert(tag != NULL);
-
- if (strcmp(tag->value(), "var_ref") == 0)
- return read_var_ref(st, list);
- if (strcmp(tag->value(), "array_ref") == 0)
- return read_array_ref(st, list);
- if (strcmp(tag->value(), "record_ref") == 0)
- return read_record_ref(st, list);
- return NULL;
-}
-
-static ir_dereference_variable *
-read_var_ref(_mesa_glsl_parse_state *st, s_list *list)
-{
- void *ctx = st;
- if (list->length() != 2) {
- ir_read_error(st, list, "expected (var_ref <variable name>)");
- return NULL;
- }
- s_symbol *var_name = SX_AS_SYMBOL(list->subexpressions.head->next);
- if (var_name == NULL) {
- ir_read_error(st, list, "expected (var_ref <variable name>)");
- return NULL;
- }
-
- ir_variable *var = st->symbols->get_variable(var_name->value());
- if (var == NULL) {
- ir_read_error(st, list, "undeclared variable: %s", var_name->value());
- return NULL;
- }
-
- return new(ctx) ir_dereference_variable(var);
-}
-
-static ir_dereference_array *
-read_array_ref(_mesa_glsl_parse_state *st, s_list *list)
-{
- void *ctx = st;
- if (list->length() != 3) {
- ir_read_error(st, list, "expected (array_ref <rvalue> <index>)");
- return NULL;
- }
-
- s_expression *subj_expr = (s_expression*) list->subexpressions.head->next;
- ir_rvalue *subject = read_rvalue(st, subj_expr);
- if (subject == NULL) {
- ir_read_error(st, NULL, "when reading the subject of an array_ref");
- return NULL;
- }
-
- s_expression *idx_expr = (s_expression*) subj_expr->next;
- ir_rvalue *idx = read_rvalue(st, idx_expr);
- return new(ctx) ir_dereference_array(subject, idx);
-}
-
-static ir_dereference_record *
-read_record_ref(_mesa_glsl_parse_state *st, s_list *list)
-{
- void *ctx = st;
- if (list->length() != 3) {
- ir_read_error(st, list, "expected (record_ref <rvalue> <field>)");
- return NULL;
- }
-
- s_expression *subj_expr = (s_expression*) list->subexpressions.head->next;
- ir_rvalue *subject = read_rvalue(st, subj_expr);
- if (subject == NULL) {
- ir_read_error(st, NULL, "when reading the subject of a record_ref");
- return NULL;
- }
+ s_symbol *s_var;
+ s_expression *s_subject;
+ s_expression *s_index;
+ s_symbol *s_field;
+
+ s_pattern var_pat[] = { "var_ref", s_var };
+ s_pattern array_pat[] = { "array_ref", s_subject, s_index };
+ s_pattern record_pat[] = { "record_ref", s_subject, s_field };
+
+ if (MATCH(expr, var_pat)) {
+ ir_variable *var = state->symbols->get_variable(s_var->value());
+ if (var == NULL) {
+ ir_read_error(expr, "undeclared variable: %s", s_var->value());
+ return NULL;
+ }
+ return new(mem_ctx) ir_dereference_variable(var);
+ } else if (MATCH(expr, array_pat)) {
+ ir_rvalue *subject = read_rvalue(s_subject);
+ if (subject == NULL) {
+ ir_read_error(NULL, "when reading the subject of an array_ref");
+ return NULL;
+ }
- s_symbol *field = SX_AS_SYMBOL(subj_expr->next);
- if (field == NULL) {
- ir_read_error(st, list, "expected (record_ref ... <field name>)");
- return NULL;
+ ir_rvalue *idx = read_rvalue(s_index);
+ if (subject == NULL) {
+ ir_read_error(NULL, "when reading the index of an array_ref");
+ return NULL;
+ }
+ return new(mem_ctx) ir_dereference_array(subject, idx);
+ } else if (MATCH(expr, record_pat)) {
+ ir_rvalue *subject = read_rvalue(s_subject);
+ if (subject == NULL) {
+ ir_read_error(NULL, "when reading the subject of a record_ref");
+ return NULL;
+ }
+ return new(mem_ctx) ir_dereference_record(subject, s_field->value());
}
- return new(ctx) ir_dereference_record(subject, field->value());
-}
-
-static bool
-valid_texture_list_length(ir_texture_opcode op, s_list *list)
-{
- unsigned required_length = 7;
- if (op == ir_txf)
- required_length = 5;
- else if (op == ir_tex)
- required_length = 6;
-
- return list->length() == required_length;
+ return NULL;
}
-static ir_texture *
-read_texture(_mesa_glsl_parse_state *st, s_list *list)
+ir_texture *
+ir_reader::read_texture(s_expression *expr)
{
- void *ctx = st;
- s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head);
- assert(tag != NULL);
-
- ir_texture_opcode op = ir_texture::get_opcode(tag->value());
- if (op == (ir_texture_opcode) -1)
- return NULL;
-
- if (!valid_texture_list_length(op, list)) {
- ir_read_error(st, NULL, "invalid list size in (%s ...)", tag->value());
- return NULL;
+ s_symbol *tag = NULL;
+ s_expression *s_sampler = NULL;
+ s_expression *s_coord = NULL;
+ s_list *s_offset = NULL;
+ s_expression *s_proj = NULL;
+ s_list *s_shadow = NULL;
+ s_expression *s_lod = NULL;
+
+ ir_texture_opcode op;
+
+ s_pattern tex_pattern[] =
+ { "tex", s_sampler, s_coord, s_offset, s_proj, s_shadow };
+ s_pattern txf_pattern[] =
+ { "txf", s_sampler, s_coord, s_offset, s_lod };
+ s_pattern other_pattern[] =
+ { tag, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod };
+
+ if (MATCH(expr, tex_pattern)) {
+ op = ir_tex;
+ } else if (MATCH(expr, txf_pattern)) {
+ op = ir_txf;
+ } else if (MATCH(expr, other_pattern)) {
+ op = ir_texture::get_opcode(tag->value());
+ if (op == -1)
+ return NULL;
}
- ir_texture *tex = new(ctx) ir_texture(op);
+ ir_texture *tex = new(mem_ctx) ir_texture(op);
// Read sampler (must be a deref)
- s_expression *sampler_expr = (s_expression *) tag->next;
- ir_dereference *sampler = read_dereference(st, sampler_expr);
+ ir_dereference *sampler = read_dereference(s_sampler);
if (sampler == NULL) {
- ir_read_error(st, NULL, "when reading sampler in (%s ...)", tag->value());
+ ir_read_error(NULL, "when reading sampler in (%s ...)",
+ tex->opcode_string());
return NULL;
}
tex->set_sampler(sampler);
// Read coordinate (any rvalue)
- s_expression *coordinate_expr = (s_expression *) sampler_expr->next;
- tex->coordinate = read_rvalue(st, coordinate_expr);
+ tex->coordinate = read_rvalue(s_coord);
if (tex->coordinate == NULL) {
- ir_read_error(st, NULL, "when reading coordinate in (%s ...)",
- tag->value());
+ ir_read_error(NULL, "when reading coordinate in (%s ...)",
+ tex->opcode_string());
return NULL;
}
// Read texel offset, i.e. (0 0 0)
- s_list *offset_list = SX_AS_LIST(coordinate_expr->next);
- if (offset_list == NULL || offset_list->length() != 3) {
- ir_read_error(st, offset_list, "expected (<int> <int> <int>)");
- return NULL;
- }
- s_int *offset_x = SX_AS_INT(offset_list->subexpressions.head);
- s_int *offset_y = SX_AS_INT(offset_list->subexpressions.head->next);
- s_int *offset_z = SX_AS_INT(offset_list->subexpressions.head->next->next);
- if (offset_x == NULL || offset_y == NULL || offset_z == NULL) {
- ir_read_error(st, offset_list, "expected (<int> <int> <int>)");
+ s_int *offset_x;
+ s_int *offset_y;
+ s_int *offset_z;
+ s_pattern offset_pat[] = { offset_x, offset_y, offset_z };
+ if (!MATCH(s_offset, offset_pat)) {
+ ir_read_error(s_offset, "expected (<int> <int> <int>)");
return NULL;
}
tex->offsets[0] = offset_x->value();
tex->offsets[1] = offset_y->value();
tex->offsets[2] = offset_z->value();
- if (op == ir_txf) {
- s_expression *lod_expr = (s_expression *) offset_list->next;
- tex->lod_info.lod = read_rvalue(st, lod_expr);
- if (tex->lod_info.lod == NULL) {
- ir_read_error(st, NULL, "when reading LOD in (txf ...)");
- return NULL;
- }
- } else {
- s_expression *proj_expr = (s_expression *) offset_list->next;
- s_int *proj_as_int = SX_AS_INT(proj_expr);
+ if (op != ir_txf) {
+ s_int *proj_as_int = SX_AS_INT(s_proj);
if (proj_as_int && proj_as_int->value() == 1) {
tex->projector = NULL;
} else {
- tex->projector = read_rvalue(st, proj_expr);
+ tex->projector = read_rvalue(s_proj);
if (tex->projector == NULL) {
- ir_read_error(st, NULL, "when reading projective divide in (%s ..)",
- tag->value());
+ ir_read_error(NULL, "when reading projective divide in (%s ..)",
+ tex->opcode_string());
return NULL;
}
}
- s_list *shadow_list = SX_AS_LIST(proj_expr->next);
- if (shadow_list == NULL) {
- ir_read_error(st, NULL, "shadow comparitor must be a list");
- return NULL;
- }
- if (shadow_list->subexpressions.is_empty()) {
- tex->shadow_comparitor= NULL;
+ if (s_shadow->subexpressions.is_empty()) {
+ tex->shadow_comparitor = NULL;
} else {
- tex->shadow_comparitor = read_rvalue(st, shadow_list);
+ tex->shadow_comparitor = read_rvalue(s_shadow);
if (tex->shadow_comparitor == NULL) {
- ir_read_error(st, NULL, "when reading shadow comparitor in (%s ..)",
- tag->value());
+ ir_read_error(NULL, "when reading shadow comparitor in (%s ..)",
+ tex->opcode_string());
return NULL;
}
}
- s_expression *lod_expr = (s_expression *) shadow_list->next;
-
- switch (op) {
- case ir_txb:
- tex->lod_info.bias = read_rvalue(st, lod_expr);
- if (tex->lod_info.bias == NULL) {
- ir_read_error(st, NULL, "when reading LOD bias in (txb ...)");
- return NULL;
- }
- break;
- case ir_txl:
- tex->lod_info.lod = read_rvalue(st, lod_expr);
- if (tex->lod_info.lod == NULL) {
- ir_read_error(st, NULL, "when reading LOD in (txl ...)");
- return NULL;
- }
- break;
- case ir_txd: {
- s_list *lod_list = SX_AS_LIST(lod_expr);
- if (lod_list->length() != 2) {
- ir_read_error(st, lod_expr, "expected (dPdx dPdy) in (txd ...)");
- return NULL;
- }
- s_expression *dx_expr = (s_expression *) lod_list->subexpressions.head;
- s_expression *dy_expr = (s_expression *) dx_expr->next;
+ }
- tex->lod_info.grad.dPdx = read_rvalue(st, dx_expr);
- if (tex->lod_info.grad.dPdx == NULL) {
- ir_read_error(st, NULL, "when reading dPdx in (txd ...)");
- return NULL;
- }
- tex->lod_info.grad.dPdy = read_rvalue(st, dy_expr);
- if (tex->lod_info.grad.dPdy == NULL) {
- ir_read_error(st, NULL, "when reading dPdy in (txd ...)");
- return NULL;
- }
- break;
+ switch (op) {
+ case ir_txb:
+ tex->lod_info.bias = read_rvalue(s_lod);
+ if (tex->lod_info.bias == NULL) {
+ ir_read_error(NULL, "when reading LOD bias in (txb ...)");
+ return NULL;
+ }
+ break;
+ case ir_txl:
+ case ir_txf:
+ tex->lod_info.lod = read_rvalue(s_lod);
+ if (tex->lod_info.lod == NULL) {
+ ir_read_error(NULL, "when reading LOD in (%s ...)",
+ tex->opcode_string());
+ return NULL;
+ }
+ break;
+ case ir_txd: {
+ s_expression *s_dx, *s_dy;
+ s_pattern dxdy_pat[] = { s_dx, s_dy };
+ if (!MATCH(s_lod, dxdy_pat)) {
+ ir_read_error(s_lod, "expected (dPdx dPdy) in (txd ...)");
+ return NULL;
+ }
+ tex->lod_info.grad.dPdx = read_rvalue(s_dx);
+ if (tex->lod_info.grad.dPdx == NULL) {
+ ir_read_error(NULL, "when reading dPdx in (txd ...)");
+ return NULL;
+ }
+ tex->lod_info.grad.dPdy = read_rvalue(s_dy);
+ if (tex->lod_info.grad.dPdy == NULL) {
+ ir_read_error(NULL, "when reading dPdy in (txd ...)");
+ return NULL;
}
- default:
- // tex doesn't have any extra parameters and txf was handled earlier.
- break;
- };
+ break;
}
+ default:
+ // tex doesn't have any extra parameters.
+ break;
+ };
return tex;
}
diff --git a/src/glsl/ir_set_program_inouts.cpp b/src/glsl/ir_set_program_inouts.cpp
index 714281539ac..085456533c5 100644
--- a/src/glsl/ir_set_program_inouts.cpp
+++ b/src/glsl/ir_set_program_inouts.cpp
@@ -79,6 +79,8 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len)
for (int i = 0; i < len; i++) {
if (var->mode == ir_var_in)
prog->InputsRead |= BITFIELD64_BIT(var->location + offset + i);
+ else if (var->mode == ir_var_system_value)
+ prog->SystemValuesRead |= (1 << (var->location + offset + i));
else
prog->OutputsWritten |= BITFIELD64_BIT(var->location + offset + i);
}
@@ -134,7 +136,8 @@ ir_visitor_status
ir_set_program_inouts_visitor::visit(ir_variable *ir)
{
if (ir->mode == ir_var_in ||
- ir->mode == ir_var_out) {
+ ir->mode == ir_var_out ||
+ ir->mode == ir_var_system_value) {
hash_table_insert(this->ht, ir, ir);
}
@@ -158,5 +161,6 @@ do_set_program_inouts(exec_list *instructions, struct gl_program *prog)
prog->InputsRead = 0;
prog->OutputsWritten = 0;
+ prog->SystemValuesRead = 0;
visit_list_elements(&v, instructions);
}
diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp
index 5b8281e16e3..73da28faf4f 100644
--- a/src/glsl/ir_variable.cpp
+++ b/src/glsl/ir_variable.cpp
@@ -30,6 +30,11 @@ static void generate_ARB_draw_buffers_variables(exec_list *,
struct _mesa_glsl_parse_state *,
bool, _mesa_glsl_parser_targets);
+static void
+generate_ARB_draw_instanced_variables(exec_list *,
+ struct _mesa_glsl_parse_state *,
+ bool, _mesa_glsl_parser_targets);
+
static ir_variable *
add_variable(const char *name, enum ir_variable_mode mode, int slot,
const glsl_type *type, exec_list *instructions,
@@ -41,6 +46,7 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot,
case ir_var_auto:
case ir_var_in:
case ir_var_uniform:
+ case ir_var_system_value:
var->read_only = true;
break;
case ir_var_inout:
@@ -324,8 +330,13 @@ initialize_vs_variables(exec_list *instructions,
generate_130_vs_variables(instructions, state);
break;
}
+
+ if (state->ARB_draw_instanced_enable)
+ generate_ARB_draw_instanced_variables(instructions, state, false,
+ vertex_shader);
}
+
/* This function should only be called for ES, not desktop GL. */
static void
generate_100ES_fs_variables(exec_list *instructions,
@@ -422,6 +433,27 @@ generate_ARB_draw_buffers_variables(exec_list *instructions,
}
}
+
+static void
+generate_ARB_draw_instanced_variables(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state,
+ bool warn,
+ _mesa_glsl_parser_targets target)
+{
+ /* gl_InstanceIDARB is only available in the vertex shader.
+ */
+ if (target == vertex_shader) {
+ ir_variable *const inst =
+ add_variable("gl_InstanceIDARB", ir_var_system_value,
+ SYSTEM_VALUE_INSTANCE_ID,
+ glsl_type::int_type, instructions, state->symbols);
+
+ if (warn)
+ inst->warn_extension = "GL_ARB_draw_instanced";
+ }
+}
+
+
static void
generate_ARB_shader_stencil_export_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state,
diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp
index d99e0aa7398..dd2601d1aad 100644
--- a/src/glsl/lower_jumps.cpp
+++ b/src/glsl/lower_jumps.cpp
@@ -66,7 +66,7 @@ enum jump_strength
strength_always_clears_execute_flag,
strength_continue,
strength_break,
- strength_return,
+ strength_return
};
struct block_record
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index c8fc2676253..9b041aafe42 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -24,11 +24,6 @@
#include <cstdio>
#include <getopt.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
@@ -78,6 +73,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
ctx->API = api;
ctx->Extensions.ARB_draw_buffers = GL_TRUE;
+ ctx->Extensions.ARB_draw_instanced = GL_TRUE;
ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
ctx->Extensions.EXT_texture_array = GL_TRUE;
ctx->Extensions.NV_texture_rectangle = GL_TRUE;
@@ -110,38 +106,40 @@ static char *
load_text_file(void *ctx, const char *file_name)
{
char *text = NULL;
- struct stat st;
- ssize_t total_read = 0;
- int fd = open(file_name, O_RDONLY);
+ size_t size;
+ size_t total_read = 0;
+ FILE *fp = fopen(file_name, "rb");
- if (fd < 0) {
+ if (!fp) {
return NULL;
}
- if (fstat(fd, & st) == 0) {
- text = (char *) talloc_size(ctx, st.st_size + 1);
- if (text != NULL) {
- do {
- ssize_t bytes = read(fd, text + total_read,
- st.st_size - total_read);
- if (bytes < 0) {
- free(text);
- text = NULL;
- break;
- }
-
- if (bytes == 0) {
- break;
- }
-
- total_read += bytes;
- } while (total_read < st.st_size);
-
- text[total_read] = '\0';
- }
+ fseek(fp, 0L, SEEK_END);
+ size = ftell(fp);
+ fseek(fp, 0L, SEEK_SET);
+
+ text = (char *) talloc_size(ctx, size + 1);
+ if (text != NULL) {
+ do {
+ size_t bytes = fread(text + total_read,
+ 1, size - total_read, fp);
+ if (bytes < size - total_read) {
+ free(text);
+ text = NULL;
+ break;
+ }
+
+ if (bytes == 0) {
+ break;
+ }
+
+ total_read += bytes;
+ } while (total_read < size);
+
+ text[total_read] = '\0';
}
- close(fd);
+ fclose(fp);
return text;
}
@@ -188,7 +186,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
const char *source = shader->Source;
state->error = preprocess(state, &source, &state->info_log,
- state->extensions, ctx->API);
+ state->extensions, ctx->API) != 0;
if (!state->error) {
_mesa_glsl_lexer_ctor(state, source);
diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp
index e420cd6e7ec..6edbf62e488 100644
--- a/src/glsl/s_expression.cpp
+++ b/src/glsl/s_expression.cpp
@@ -38,14 +38,15 @@ s_list::s_list()
{
}
-unsigned
-s_list::length() const
+static void
+skip_whitespace(const char *& src)
{
- unsigned i = 0;
- foreach_iter(exec_list_iterator, it, this->subexpressions) {
- i++;
+ src += strspn(src, " \v\t\r\n");
+ /* Also skip Scheme-style comments: semi-colon 'til end of line */
+ if (src[0] == ';') {
+ src += strcspn(src, "\n");
+ skip_whitespace(src);
}
- return i;
}
static s_expression *
@@ -53,10 +54,9 @@ read_atom(void *ctx, const char *& src)
{
s_expression *expr = NULL;
- // Skip leading spaces.
- src += strspn(src, " \v\t\r\n");
+ skip_whitespace(src);
- size_t n = strcspn(src, "( \v\t\r\n)");
+ size_t n = strcspn(src, "( \v\t\r\n);");
if (n == 0)
return NULL; // no atom
@@ -90,8 +90,7 @@ s_expression::read_expression(void *ctx, const char *&src)
if (atom != NULL)
return atom;
- // Skip leading spaces.
- src += strspn(src, " \v\t\r\n");
+ skip_whitespace(src);
if (src[0] == '(') {
++src;
@@ -101,7 +100,7 @@ s_expression::read_expression(void *ctx, const char *&src)
while ((expr = read_expression(ctx, src)) != NULL) {
list->subexpressions.push_tail(expr);
}
- src += strspn(src, " \v\t\r\n");
+ skip_whitespace(src);
if (src[0] != ')') {
printf("Unclosed expression (check your parenthesis).\n");
return NULL;
@@ -139,3 +138,49 @@ void s_list::print()
printf(")");
}
+// --------------------------------------------------
+
+bool
+s_pattern::match(s_expression *expr)
+{
+ switch (type)
+ {
+ case EXPR: *p_expr = expr; break;
+ case LIST: if (expr->is_list()) *p_list = (s_list *) expr; break;
+ case SYMBOL: if (expr->is_symbol()) *p_symbol = (s_symbol *) expr; break;
+ case NUMBER: if (expr->is_number()) *p_number = (s_number *) expr; break;
+ case INT: if (expr->is_int()) *p_int = (s_int *) expr; break;
+ case STRING:
+ s_symbol *sym = SX_AS_SYMBOL(expr);
+ if (sym != NULL && strcmp(sym->value(), literal) == 0)
+ return true;
+ return false;
+ };
+
+ return *p_expr == expr;
+}
+
+bool
+s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial)
+{
+ s_list *list = SX_AS_LIST(top);
+ if (list == NULL)
+ return false;
+
+ unsigned i = 0;
+ foreach_iter(exec_list_iterator, it, list->subexpressions) {
+ if (i >= n)
+ return partial; /* More actual items than the pattern expected */
+
+ s_expression *expr = (s_expression *) it.get();
+ if (expr == NULL || !pattern[i].match(expr))
+ return false;
+
+ i++;
+ }
+
+ if (i < n)
+ return false; /* Less actual items than the pattern expected */
+
+ return true;
+}
diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h
index 29d800e394a..795f3fccea7 100644
--- a/src/glsl/s_expression.h
+++ b/src/glsl/s_expression.h
@@ -26,9 +26,11 @@
#ifndef S_EXPRESSION_H
#define S_EXPRESSION_H
+#include "main/core.h" /* for Elements */
#include "strtod.h"
#include "list.h"
+/* Type-safe downcasting macros (also safe to pass NULL) */
#define SX_AS_(t,x) ((x) && ((s_expression*) x)->is_##t()) ? ((s_##t*) (x)) \
: NULL
#define SX_AS_LIST(x) SX_AS_(list, x)
@@ -36,6 +38,10 @@
#define SX_AS_NUMBER(x) SX_AS_(number, x)
#define SX_AS_INT(x) SX_AS_(int, x)
+/* Pattern matching macros */
+#define MATCH(list, pat) s_match(list, Elements(pat), pat, false)
+#define PARTIAL_MATCH(list, pat) s_match(list, Elements(pat), pat, true)
+
/* For our purposes, S-Expressions are:
* - <int>
* - <float>
@@ -133,11 +139,42 @@ public:
s_list();
virtual bool is_list() const { return true; }
- unsigned length() const;
void print();
exec_list subexpressions;
};
+// ------------------------------------------------------------
+
+/**
+ * Part of a pattern to match - essentially a record holding a pointer to the
+ * storage for the component to match, along with the appropriate type.
+ */
+class s_pattern {
+public:
+ s_pattern(s_expression *&s) : p_expr(&s), type(EXPR) { }
+ s_pattern(s_list *&s) : p_list(&s), type(LIST) { }
+ s_pattern(s_symbol *&s) : p_symbol(&s), type(SYMBOL) { }
+ s_pattern(s_number *&s) : p_number(&s), type(NUMBER) { }
+ s_pattern(s_int *&s) : p_int(&s), type(INT) { }
+ s_pattern(const char *str) : literal(str), type(STRING) { }
+
+ bool match(s_expression *expr);
+
+private:
+ union {
+ s_expression **p_expr;
+ s_list **p_list;
+ s_symbol **p_symbol;
+ s_number **p_number;
+ s_int **p_int;
+ const char *literal;
+ };
+ enum { EXPR, LIST, SYMBOL, NUMBER, INT, STRING } type;
+};
+
+bool
+s_match(s_expression *top, unsigned n, s_pattern *pattern, bool partial);
+
#endif /* S_EXPRESSION_H */